From d3c440966f9bc3f41d82e65f58850e8609e17e5d Mon Sep 17 00:00:00 2001 From: Nithya Date: Tue, 10 May 2022 12:00:25 +0100 Subject: [PATCH] guarantee final pipeline (#340) Co-authored-by: Nithya --- CHANGELOG.md | 2 ++ marge/app.py | 9 ++++++++- marge/job.py | 3 +++ marge/single_merge_job.py | 13 ++++++++++++- tests/test_job.py | 1 + version | 2 +- 6 files changed, 27 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0233cba3..67168183 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ + * 0.10.1: + - Feature: Guarantee pipeline before merging * 0.10.0: - Feature: implement HTTPS support for cloning (#225) #283 - Feature: Make CI work with GitHub Actions #308 diff --git a/marge/app.py b/marge/app.py index 49402d7b..db40ce1c 100644 --- a/marge/app.py +++ b/marge/app.py @@ -32,7 +32,7 @@ def time_interval(str_interval): ) from err -def _parse_config(args): +def _parse_config(args): # pylint: disable=too-many-statements def regexp(str_regex): try: @@ -237,6 +237,12 @@ def regexp(str_regex): action='store_true', help='Run marge-bot as a single CLI command, not a service' ) + parser.add_argument( + '--guarantee-final-pipeline', + action='store_true', + help='Guaranteed final pipeline when assigned to marge-bot' + ) + config = parser.parse_args(args) if config.use_merge_strategy and config.batch: @@ -342,6 +348,7 @@ def main(args=None): use_no_ff_batches=options.use_no_ff_batches, use_merge_commit_batches=options.use_merge_commit_batches, skip_ci_batches=options.skip_ci_batches, + guarantee_final_pipeline=options.guarantee_final_pipeline, ), batch=options.batch, cli=options.cli, diff --git a/marge/job.py b/marge/job.py index 7c0cd444..c93bf556 100644 --- a/marge/job.py +++ b/marge/job.py @@ -460,6 +460,7 @@ class Fusion(enum.Enum): 'use_no_ff_batches', 'use_merge_commit_batches', 'skip_ci_batches', + 'guarantee_final_pipeline', ] @@ -476,6 +477,7 @@ def default( add_tested=False, add_part_of=False, add_reviewers=False, reapprove=False, approval_timeout=None, embargo=None, ci_timeout=None, fusion=Fusion.rebase, use_no_ff_batches=False, use_merge_commit_batches=False, skip_ci_batches=False, + guarantee_final_pipeline=False, ): approval_timeout = approval_timeout or timedelta(seconds=0) embargo = embargo or IntervalUnion.empty() @@ -492,6 +494,7 @@ def default( use_no_ff_batches=use_no_ff_batches, use_merge_commit_batches=use_merge_commit_batches, skip_ci_batches=skip_ci_batches, + guarantee_final_pipeline=guarantee_final_pipeline, ) diff --git a/marge/single_merge_job.py b/marge/single_merge_job.py index 7d3cb590..1f8155ba 100644 --- a/marge/single_merge_job.py +++ b/marge/single_merge_job.py @@ -13,6 +13,7 @@ class SingleMergeJob(MergeJob): def __init__(self, *, api, user, project, repo, options, merge_request): super().__init__(api=api, user=user, project=project, repo=repo, options=options) self._merge_request = merge_request + self._options = options def execute(self): merge_request = self._merge_request @@ -61,7 +62,17 @@ def update_merge_request_and_accept(self, approvals): merge_request.comment("Someone skipped the queue! Will have to try again...") continue - log.info('Commit id to merge %r (into: %r)', actual_sha, target_sha) + if _updated_sha == actual_sha and self._options.guarantee_final_pipeline: + log.info('No commits on target branch to fuse, triggering pipeline...') + merge_request.comment("jenkins retry") + time.sleep(30) + + log.info( + 'Commit id to merge %r into: %r (updated sha: %r)', + actual_sha, + target_sha, + _updated_sha + ) time.sleep(5) sha_now = Commit.last_on_branch(source_project.id, merge_request.source_branch, api).id diff --git a/tests/test_job.py b/tests/test_job.py index 4818b293..22036d10 100644 --- a/tests/test_job.py +++ b/tests/test_job.py @@ -217,6 +217,7 @@ def test_default(self): use_no_ff_batches=False, use_merge_commit_batches=False, skip_ci_batches=False, + guarantee_final_pipeline=False, ) def test_default_ci_time(self): diff --git a/version b/version index 78bc1abd..57121573 100644 --- a/version +++ b/version @@ -1 +1 @@ -0.10.0 +0.10.1