From 3165261ecd7468c5f30eec0f50b4b43e556b7194 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=A0pa=C4=8Dek?= Date: Mon, 5 Aug 2024 10:21:46 +0200 Subject: [PATCH 1/5] Mark backports CI job as non-interruptible Previously CI job for the autobackport bot inherited "interruptible: true" global configuration. This caused premature termination of the job when another merge was finished before the autobackport job ran to completion. --- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 42849553c3..526c251b4e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1953,6 +1953,8 @@ pairwise: - $PAIRWISE_TESTING backports: + # finish backport attempt even if another MR was merged while the job was running (or queued) + interruptible: false <<: *base_image stage: postmerge rules: From d1c64d588b5d2b293d6b4a366372c61043caba30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=A0pa=C4=8Dek?= Date: Mon, 5 Aug 2024 10:48:34 +0200 Subject: [PATCH 2/5] Automatically adjust MR metadata after merge 1. Set milestone to 'Not released yet' after merge We will set milestone to actual version number when we actually tag a particular version. This will get rid of mass MR reassignment when we do last minute changes to a release plan etc. 2. Adjust No CHANGES and Release Notes MR labels to match gitchangelog workflow. --- .gitlab-ci.yml | 41 +++++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 526c251b4e..f63965f81c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1952,25 +1952,46 @@ pairwise: variables: - $PAIRWISE_TESTING -backports: - # finish backport attempt even if another MR was merged while the job was running (or queued) - interruptible: false +.post_merge_template: &post_merge <<: *base_image stage: postmerge - rules: - - if: '$CI_PIPELINE_SOURCE == "push" && ($CI_COMMIT_REF_NAME =~ /^bind-9.[0-9]+$/ || $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH)' + needs: [] + # post-merge processes should run even if another MR was merged while the job was running (or queued) + interruptible: false variables: # automated commits will inherit identification from the user who pressed Merge button GIT_COMMITTER_NAME: $GITLAB_USER_NAME GIT_COMMITTER_EMAIL: $GITLAB_USER_EMAIL # avoid leftover branches from previous jobs GIT_STRATEGY: clone - # assumed max depth of a MR for backport - GIT_DEPTH: 200 + # assumed max depth of a MR for backport or a rebased force-push + GIT_DEPTH: 1000 + before_script: + # force-pushes should not trigger process automation (happens only in -sub branches) + - > + echo "previous branch tip: $CI_COMMIT_BEFORE_SHA" + - set +o pipefail; git log --format='%H' | grep --silent "$CI_COMMIT_BEFORE_SHA" && PREVIOUS_TIP_REACHABLE=1 + - test "$PREVIOUS_TIP_REACHABLE" != "1" && echo "force-push detected, stop" && exit 1 + # non-fast-forward merges are disabled so we have to have merge commit on top + - MERGE_REQUEST_ID="$(git log -1 --format='%b' | sed --silent -e 's/^See merge request [^!]\+!//p')" + - > + : stop if this is not a merge request + - test "$MERGE_REQUEST_ID" -ge 0 + - git clone --depth 1 https://gitlab.isc.org/isc-projects/bind9-qa.git + +backports: + <<: *post_merge + rules: + # -sub branches are handled manually + - if: '$CI_PIPELINE_SOURCE == "push" && ($CI_COMMIT_REF_NAME =~ /^bind-9.[0-9]+$/ || $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH)' script: # CI job token is not sufficient for push operations - git remote get-url origin | sed -e "s/gitlab-ci-token:$CI_JOB_TOKEN/oauth2:$BIND_TEAM_WRITE_TOKEN/" | xargs git remote set-url --push origin - # force-pushing is disabled so we have to have merge request on top - - MERGE_REQUEST_ID="$(git log -1 --format='%b' | sed --silent -e 's/^See merge request [^!]\+!//p')" - - git clone --depth 1 https://gitlab.isc.org/isc-projects/bind9-qa.git - bind9-qa/releng/backport_mr.py $CI_PROJECT_ID "$MERGE_REQUEST_ID" + +merged-metadata: + <<: *post_merge + rules: + - if: '$CI_PIPELINE_SOURCE == "push" && ($CI_COMMIT_REF_NAME =~ /^bind-9.[0-9]+(-sub)?$/ || $CI_COMMIT_REF_NAME =~ /^bind-9.[0-9]+.[0-9]+-release$/ || $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH)' + script: + - bind9-qa/releng/after_merge.py "$CI_PROJECT_ID" "$MERGE_REQUEST_ID" From edf0e6415a356a8d192cbaf9f193878c4ef7e9f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=A0pa=C4=8Dek?= Date: Thu, 22 Aug 2024 17:17:15 +0200 Subject: [PATCH 3/5] Remove 'No CHANGES' check from dangerfile This label is now handled automatically by 'merged-metadata' CI job. --- dangerfile.py | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/dangerfile.py b/dangerfile.py index 00f3a8a44c..b3b84059c7 100644 --- a/dangerfile.py +++ b/dangerfile.py @@ -331,31 +331,6 @@ elif not approved: "It should not be merged until it is approved." ) -############################################################################### -# Changelog entries -############################################################################### -# -# FAIL if any of the following is true: -# -# * The merge request title doesn't produce a changelog entry, but it does not have -# the "No CHANGES" label set. -# -# * The merge request title produces a changelog entry, but it has the "No CHANGES" -# label set. - -changes_modified = mr_title_audience in ["usr", "pkg", "dev"] -no_changes_label_set = "No CHANGES" in mr_labels -if not changes_modified and not no_changes_label_set: - fail( - "MR title doesn't produce a new changelog entry. " - "Add a `dev:`|`usr:`|`pkg:` audience to MR title or set the *No CHANGES* label." - ) -if changes_modified and no_changes_label_set: - fail( - "MR title produces a new changelog entry. Unset the *No Changes* label " - "or remove the `dev:`|`usr:`|`pkg:` audience from the MR title." - ) - ############################################################################### # RELEASE NOTES ############################################################################### From 146743d5a3163adffbd69523a776046ec622e6ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=A0pa=C4=8Dek?= Date: Thu, 22 Aug 2024 17:21:43 +0200 Subject: [PATCH 4/5] Remove 'Release notes' label check from dangerfile This label is now handled automatically by 'merged-metadata' CI job. --- dangerfile.py | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/dangerfile.py b/dangerfile.py index b3b84059c7..d272dda236 100644 --- a/dangerfile.py +++ b/dangerfile.py @@ -364,15 +364,8 @@ elif not approved: # linked with the `Closes` or `Fixes` keyword in the MR description. release_notes_changed = mr_title_audience in ["usr", "pkg"] -release_notes_label_set = "Release Notes" in mr_labels if not release_notes_changed: - if release_notes_label_set: - fail( - "This merge request has the *Release Notes* label set. " - "Update the MR title to include `usr:`|`pkg:` audience or " - "unset the *Release Notes* label." - ) - elif "Customer" in mr_labels: + if "Customer" in mr_labels and not release_notes_changed: warn( "This merge request has the *Customer* label set. " "Update the MR title to include `usr:`|`pkg:` audience " @@ -388,20 +381,6 @@ if not release_notes_changed: "means that it adds support for a new RR type or removes support " "for an existing one. Update the MR title to include `usr:` audience." ) -if release_notes_changed and not release_notes_label_set: - fail( - "The MR title produces a release note. Set the *Release Notes* label " - "or remove the `usr:`|`pkg:` audience from the MR title." - ) -if ( - release_notes_label_set - and no_changes_label_set - and not ("Documentation" in mr_labels or "Release" in mr_labels) -): - fail( - "This merge request is labeled with both *Release notes* and *No CHANGES*. " - "A user-visible change should also be mentioned in the changelog." - ) if release_notes_changed and not mr_issue_link_regex.search( danger.gitlab.mr.description From 73b950dc29ba1a381fa8d1c47d12f3d2ee79cbe9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=A0pa=C4=8Dek?= Date: Fri, 23 Aug 2024 09:34:20 +0200 Subject: [PATCH 5/5] Remove milestone check from dangerfile Milestone is automatically set by 'merged-metadata' CI job to 'Not released yet' so it does not matter what the original value was. --- dangerfile.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/dangerfile.py b/dangerfile.py index d272dda236..93127eaaf5 100644 --- a/dangerfile.py +++ b/dangerfile.py @@ -202,15 +202,6 @@ for commit in danger.git.commits: f"```{line}``` ({len(line)} > 72 characters)." ) -############################################################################### -# MILESTONE -############################################################################### -# -# FAIL if the merge request is not assigned to any milestone. - -if not danger.gitlab.mr.milestone: - fail("Please assign this merge request to a milestone.") - ############################################################################### # BACKPORT & VERSION LABELS ###############################################################################