Skip to content

Commit d3c4409

Browse files
nithyashree675Nithya
andauthored
guarantee final pipeline (#340)
Co-authored-by: Nithya <[email protected]>
1 parent 70ab3c8 commit d3c4409

File tree

6 files changed

+27
-3
lines changed

6 files changed

+27
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
* 0.10.1:
2+
- Feature: Guarantee pipeline before merging
13
* 0.10.0:
24
- Feature: implement HTTPS support for cloning (#225) #283
35
- Feature: Make CI work with GitHub Actions #308

marge/app.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def time_interval(str_interval):
3232
) from err
3333

3434

35-
def _parse_config(args):
35+
def _parse_config(args): # pylint: disable=too-many-statements
3636

3737
def regexp(str_regex):
3838
try:
@@ -237,6 +237,12 @@ def regexp(str_regex):
237237
action='store_true',
238238
help='Run marge-bot as a single CLI command, not a service'
239239
)
240+
parser.add_argument(
241+
'--guarantee-final-pipeline',
242+
action='store_true',
243+
help='Guaranteed final pipeline when assigned to marge-bot'
244+
)
245+
240246
config = parser.parse_args(args)
241247

242248
if config.use_merge_strategy and config.batch:
@@ -342,6 +348,7 @@ def main(args=None):
342348
use_no_ff_batches=options.use_no_ff_batches,
343349
use_merge_commit_batches=options.use_merge_commit_batches,
344350
skip_ci_batches=options.skip_ci_batches,
351+
guarantee_final_pipeline=options.guarantee_final_pipeline,
345352
),
346353
batch=options.batch,
347354
cli=options.cli,

marge/job.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,7 @@ class Fusion(enum.Enum):
460460
'use_no_ff_batches',
461461
'use_merge_commit_batches',
462462
'skip_ci_batches',
463+
'guarantee_final_pipeline',
463464
]
464465

465466

@@ -476,6 +477,7 @@ def default(
476477
add_tested=False, add_part_of=False, add_reviewers=False, reapprove=False,
477478
approval_timeout=None, embargo=None, ci_timeout=None, fusion=Fusion.rebase,
478479
use_no_ff_batches=False, use_merge_commit_batches=False, skip_ci_batches=False,
480+
guarantee_final_pipeline=False,
479481
):
480482
approval_timeout = approval_timeout or timedelta(seconds=0)
481483
embargo = embargo or IntervalUnion.empty()
@@ -492,6 +494,7 @@ def default(
492494
use_no_ff_batches=use_no_ff_batches,
493495
use_merge_commit_batches=use_merge_commit_batches,
494496
skip_ci_batches=skip_ci_batches,
497+
guarantee_final_pipeline=guarantee_final_pipeline,
495498
)
496499

497500

marge/single_merge_job.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class SingleMergeJob(MergeJob):
1313
def __init__(self, *, api, user, project, repo, options, merge_request):
1414
super().__init__(api=api, user=user, project=project, repo=repo, options=options)
1515
self._merge_request = merge_request
16+
self._options = options
1617

1718
def execute(self):
1819
merge_request = self._merge_request
@@ -61,7 +62,17 @@ def update_merge_request_and_accept(self, approvals):
6162
merge_request.comment("Someone skipped the queue! Will have to try again...")
6263
continue
6364

64-
log.info('Commit id to merge %r (into: %r)', actual_sha, target_sha)
65+
if _updated_sha == actual_sha and self._options.guarantee_final_pipeline:
66+
log.info('No commits on target branch to fuse, triggering pipeline...')
67+
merge_request.comment("jenkins retry")
68+
time.sleep(30)
69+
70+
log.info(
71+
'Commit id to merge %r into: %r (updated sha: %r)',
72+
actual_sha,
73+
target_sha,
74+
_updated_sha
75+
)
6576
time.sleep(5)
6677

6778
sha_now = Commit.last_on_branch(source_project.id, merge_request.source_branch, api).id

tests/test_job.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ def test_default(self):
217217
use_no_ff_batches=False,
218218
use_merge_commit_batches=False,
219219
skip_ci_batches=False,
220+
guarantee_final_pipeline=False,
220221
)
221222

222223
def test_default_ci_time(self):

version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.10.0
1+
0.10.1

0 commit comments

Comments
 (0)