Skip to content

Commit

Permalink
[ADD] merge bot: towncrier support
Browse files Browse the repository at this point in the history
  • Loading branch information
sbidoul committed Mar 25, 2020
1 parent 4e653ae commit 99e3e52
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 4 deletions.
4 changes: 3 additions & 1 deletion Dockerfile
Expand Up @@ -21,11 +21,13 @@ RUN set -x \
RUN set -x \
&& python3 -m venv /ocamt \
&& /ocamt/bin/pip install wheel
# TODO update sha to get oca-towncrier
RUN set -x \
&& /ocamt/bin/pip install -e git+https://github.com/OCA/maintainer-tools@5dbc86310d80229ef0f2f5851933414be719308b#egg=oca-maintainers-tools \
&& ln -s /ocamt/bin/oca-gen-addons-table /usr/local/bin/ \
&& ln -s /ocamt/bin/oca-gen-addon-readme /usr/local/bin/ \
&& ln -s /ocamt/bin/oca-gen-addon-icon /usr/local/bin/
&& ln -s /ocamt/bin/oca-gen-addon-icon /usr/local/bin/ \
&& ln -s /ocamt/bin/oca-towncrier /usr/local/bin/
RUN set -x \
&& /ocamt/bin/pip install setuptools-odoo>=2.5.0 \
&& ln -s /ocamt/bin/setuptools-odoo-make-default /usr/local/bin/
Expand Down
4 changes: 2 additions & 2 deletions README.rst
Expand Up @@ -74,8 +74,8 @@ can be used to ask the bot to the following:
* run the main branch operations (see above) on it
* optionally bump the version number of the addons modified by the PR
* merge when tests on the rebased branch are green
* when the version was bumped, generate a wheel and rsync it to the PEP 503
simple index
* when the version was bumped, udate the changelog with ``oca-towncrier``,
generate a wheel and rsync it to the PEP 503 simple index

TODO (help wanted)
------------------
Expand Down
2 changes: 1 addition & 1 deletion environment.sample
Expand Up @@ -34,7 +34,7 @@ ODOO_PASSWORD=
# Available tasks:
# delete_branch,tag_approved,tag_ready_to_merge,gen_addons_table,
# gen_addons_readme,gen_addons_icon,setuptools_odoo,mention_maintainer,
# merge_bot,tag_needs_review
# merge_bot,merge_bot_towncrier,tag_needs_review
#BOT_TASKS=all

# Root of the PEP 503 simple index where wheels are published
Expand Down
2 changes: 2 additions & 0 deletions newsfragments/106.feature
@@ -0,0 +1,2 @@
Make the "ocabot merge" command update ``HISTORY.rst`` from news fragments in
``readme/newsfragments`` using `towncrier <https://pypi.org/project/towncrier/>`_.
37 changes: 37 additions & 0 deletions src/oca_github_bot/tasks/merge_bot.py
Expand Up @@ -15,6 +15,8 @@
)
from ..manifest import (
bump_manifest_version,
bump_version,
get_manifest,
git_modified_addon_dirs,
is_addon_dir,
is_maintainer,
Expand Down Expand Up @@ -55,6 +57,30 @@ def _get_merge_bot_intro_message():
return MERGE_BOT_INTRO_MESSAGES[i]


@switchable("merge_bot_towncrier")
def _merge_bot_towncrier(org, repo, target_branch, addon_dirs, bumpversion_mode, cwd):
for addon_dir in addon_dirs:
# Run oca-towncrier: this updates and git add readme/HISTORY.rst
# if readme/newsfragments contains files and does nothing otherwise.
_logger.info(f"oca-towncrier {org}/{repo}@{target_branch} for {addon_dirs}")
version = bump_version(get_manifest(addon_dir)["version"], bumpversion_mode)
check_call(
[
"oca-towncrier",
"--org",
org,
"--repo",
repo,
"--addon-dir",
addon_dir,
"--version",
version,
"--commit",
],
cwd=cwd,
)


def _merge_bot_merge_pr(org, repo, merge_bot_branch, cwd, dry_run=False):
pr, target_branch, username, bumpversion_mode = parse_merge_bot_branch(
merge_bot_branch
Expand Down Expand Up @@ -103,6 +129,17 @@ def _merge_bot_merge_pr(org, repo, merge_bot_branch, cwd, dry_run=False):
d for d in modified_addon_dirs if is_addon_dir(d, installable_only=True)
]

# update HISTORY.rst using towncrier, before generating README.rst
if bumpversion_mode:
_merge_bot_towncrier(
org,
repo,
target_branch,
modified_installable_addon_dirs,
bumpversion_mode,
cwd,
)

if modified_addon_dirs:
# this includes setup.py and README.rst generation
main_branch_bot_actions(org, repo, target_branch, cwd=cwd)
Expand Down

0 comments on commit 99e3e52

Please sign in to comment.