Skip to content

Commit

Permalink
Revert "[DEL] runbot_subject_skip: Deprecated because is now supporte…
Browse files Browse the repository at this point in the history
…d officially"

This reverts commit 90306b0.
  • Loading branch information
moylop260 authored and hbrunn committed May 31, 2018
1 parent 97cf7b3 commit c3dc110
Show file tree
Hide file tree
Showing 7 changed files with 163 additions and 0 deletions.
74 changes: 74 additions & 0 deletions runbot_subject_skip/README.rst
@@ -0,0 +1,74 @@
.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png
:target: https://www.gnu.org/licenses/agpl
:alt: License: AGPL-3

===================
runbot_subject_skip
===================

This module skip a build based on the commit message.
Inspired by Travis-CI: https://docs.travis-ci.com/user/customizing-the-build#Skipping-a-build

Usage
=====

To use this module, you need create a commit message with the following keywords:
- "[skip ci]" or "[ci skip]" uppercase or lowercase in anywhere

The builds will be skipped.


.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/146/11.0


Known issues / Roadmap
======================

* Just is used the first line of the commit message but in travis they are using all lines.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues
<https://github.com/OCA/runbot-addons/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smash it by providing detailed and welcomed feedback.

Credits
=======

Images
------

* Odoo Community Association: `Icon <https://odoo-community.org/logo.png>`_.

Contributors
------------

* Moisés López <moylop260@vauxoo.com> (https://www.vauxoo.com)

Do not contact contributors directly about support or help with technical issues.

Funders
-------

The development of this module has been financially supported by:

* Vauxoo (https://www.vauxoo.com)

Maintainer
----------

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

This module is maintained by the OCA.

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

To contribute to this module, please visit https://odoo-community.org.
2 changes: 2 additions & 0 deletions runbot_subject_skip/__init__.py
@@ -0,0 +1,2 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from . import models
18 changes: 18 additions & 0 deletions runbot_subject_skip/__manifest__.py
@@ -0,0 +1,18 @@
# Copyright <2018> <Vauxoo info@vauxoo.com>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Runbot subject skip",
"summary": "Skip build if commit message has '[ci skip]'",
"version": "11.0.1.0.0",
"category": "runbot",
"website": "https://github.com/OCA/runbot-addons",
"author": "Vauxoo, Odoo Community Association (OCA)",
"license": "AGPL-3",
"depends": [
"runbot",
],
"data": [
],
"application": False,
"installable": True,
}
2 changes: 2 additions & 0 deletions runbot_subject_skip/models/__init__.py
@@ -0,0 +1,2 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from . import runbot_build
26 changes: 26 additions & 0 deletions runbot_subject_skip/models/runbot_build.py
@@ -0,0 +1,26 @@
# Copyright <2018> <Vauxoo info@vauxoo.com>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

import re

from odoo import api, models

SKIP_WORDS = ['[ci skip]', '[skip ci]']
SKIP_WORDS_RE = re.compile("|".join(map(re.escape, SKIP_WORDS)))


class RunbotBuild(models.Model):
_inherit = "runbot.build"

def subject_skip(self):
"""Skip build if there is a commit message with one SKIP_WORDS"""
for build in self.filtered(lambda b:
SKIP_WORDS_RE.search(b.subject.lower())):
build._log('subject_skip', 'The commit message skipped this build')
build._skip()

@api.model
def create(self, values):
build = super().create(values)
build.subject_skip()
return build
2 changes: 2 additions & 0 deletions runbot_subject_skip/tests/__init__.py
@@ -0,0 +1,2 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from . import test_runbot_skip_build
39 changes: 39 additions & 0 deletions runbot_subject_skip/tests/test_runbot_skip_build.py
@@ -0,0 +1,39 @@
# Copyright <2018> <Vauxoo info@vauxoo.com>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

import logging

from odoo.tests.common import TransactionCase

_logger = logging.getLogger(__name__)


class TestRunbotSkipBuild(TransactionCase):

def test_skip_build(self):
"""Test the [ci skip] feature"""
repo = self.env["runbot.repo"].create({
"name": "https://github.com/ORG/REPO.git",
})
branch = self.env["runbot.branch"].create({
"name": "refs/heads/master",
"repo_id": repo.id,
})
build = self.env["runbot.build"].create({
"name": "HEAD",
"branch_id": branch.id,
"subject": "Test [ci skip] feature",
})
self.assertEqual(
build.state, 'done', "State should be done")
self.assertEqual(
build.result, 'skipped', "Result should be skipped")
build = self.env["runbot.build"].create({
"name": "HEAD",
"branch_id": branch.id,
"subject": "Test no ci skip feature",
})
self.assertEqual(
build.state, 'pending', "State should be pending")
self.assertNotEqual(
build.result, 'skipped', "Result shouldn't be skipped")

0 comments on commit c3dc110

Please sign in to comment.