Skip to content

Commit

Permalink
[ADD] extra arguments for 3 commands oca-gen-addons-table, oca-gen-ad…
Browse files Browse the repository at this point in the history
…don-readme, oca-gen-addon-icon
  • Loading branch information
legalsylvain committed Mar 27, 2020
1 parent 4e653ae commit 03f7676
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 5 deletions.
10 changes: 10 additions & 0 deletions environment.sample
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,13 @@ ODOO_PASSWORD=
# Root of the PEP 503 simple index where wheels are published
# (publishing disabled if empty)
SIMPLE_INDEX_ROOT=/app/run/simple-index

# Space separated list of extra arguments, for the calls of the
# following command
# * oca-gen-addons-table
# * oca-gen-addon-readme
# * oca-gen-addon-icon
# Exemple : GEN_ADDON_README_EXTRA_ARGS=--no-gen-html
#GEN_ADDONS_TABLE_EXTRA_ARGS=
#GEN_ADDON_README_EXTRA_ARGS=
#GEN_ADDON_ICON_EXTRA_ARGS=
10 changes: 10 additions & 0 deletions newsfragments/103.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
**Features**

- Add three new settings available in the ``environment`` file that allow to add extra argument, when calling various libraries :
* ``GEN_ADDONS_TABLE_EXTRA_ARGS`` for ``oca-gen-addons-table``
* ``GEN_ADDON_README_EXTRA_ARGS`` for ``oca-gen-addon-readme``
* ``GEN_ADDON_ICON_EXTRA_ARGS`` for ``oca-gen-addon-icon``

Exemple :

``GEN_ADDON_README_EXTRA_ARGS=--no-gen-html``, will prevent to generate html file from fragments.
18 changes: 18 additions & 0 deletions src/oca_github_bot/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,24 @@ def func_wrapper(*args, **kwargs):
# gen_addons_readme,gen_addons_icon,setuptools_odoo,merge_bot,tag_needs_review
BOT_TASKS = os.environ.get("BOT_TASKS", "all").split(",")

GEN_ADDONS_TABLE_EXTRA_ARGS = (
os.environ.get("GEN_ADDONS_TABLE_EXTRA_ARGS", "")
and os.environ.get("GEN_ADDONS_TABLE_EXTRA_ARGS").split(" ")
or []
)

GEN_ADDON_README_EXTRA_ARGS = (
os.environ.get("GEN_ADDON_README_EXTRA_ARGS", "")
and os.environ.get("GEN_ADDON_README_EXTRA_ARGS").split(" ")
or []
)

GEN_ADDON_ICON_EXTRA_ARGS = (
os.environ.get("GEN_ADDON_ICON_EXTRA_ARGS", "")
and os.environ.get("GEN_ADDON_ICON_EXTRA_ARGS").split(" ")
or []
)

GITHUB_STATUS_IGNORED = [
"ci/runbot",
"codecov/project",
Expand Down
4 changes: 3 additions & 1 deletion src/oca_github_bot/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ def call(cmd, cwd):
return subprocess.call(cmd, cwd=cwd)


def check_call(cmd, cwd, log_error=True):
def check_call(cmd, cwd, log_error=True, extra_cmd_args=False):
if extra_cmd_args:
cmd += extra_cmd_args
cp = subprocess.run(
cmd,
universal_newlines=True,
Expand Down
20 changes: 16 additions & 4 deletions src/oca_github_bot/tasks/main_branch_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@

from .. import github, manifest
from ..build_wheels import build_and_publish_wheels
from ..config import SIMPLE_INDEX_ROOT, switchable
from ..config import (
GEN_ADDON_ICON_EXTRA_ARGS,
GEN_ADDON_README_EXTRA_ARGS,
GEN_ADDONS_TABLE_EXTRA_ARGS,
SIMPLE_INDEX_ROOT,
switchable,
)
from ..github import git_push_if_needed, temporary_clone
from ..process import check_call
from ..queue import getLogger, task
Expand All @@ -16,7 +22,9 @@
def _gen_addons_table(org, repo, branch, cwd):
_logger.info("oca-gen-addons-table in %s/%s@%s", org, repo, branch)
gen_addons_table_cmd = ["oca-gen-addons-table", "--commit"]
check_call(gen_addons_table_cmd, cwd=cwd)
check_call(
gen_addons_table_cmd, cwd=cwd, extra_cmd_args=GEN_ADDONS_TABLE_EXTRA_ARGS
)


@switchable("gen_addons_readme")
Expand All @@ -34,7 +42,9 @@ def _gen_addons_readme(org, repo, branch, cwd):
cwd,
"--commit",
]
check_call(gen_addon_readme_cmd, cwd=cwd)
check_call(
gen_addon_readme_cmd, cwd=cwd, extra_cmd_args=GEN_ADDON_README_EXTRA_ARGS
)


@switchable("gen_addons_icon")
Expand All @@ -56,7 +66,9 @@ def _setuptools_odoo_make_default(org, repo, branch, cwd):
"--clean",
"--commit",
]
check_call(make_default_setup_cmd, cwd=cwd)
check_call(
make_default_setup_cmd, cwd=cwd, extra_cmd_args=GEN_ADDON_ICON_EXTRA_ARGS
)


def main_branch_bot_actions(org, repo, branch, cwd):
Expand Down

0 comments on commit 03f7676

Please sign in to comment.