From 56831eea3948f281963dc84fda6b35b1201585b2 Mon Sep 17 00:00:00 2001 From: Gary Verhaegen Date: Thu, 7 Oct 2021 12:13:05 +0200 Subject: [PATCH 1/2] test release rotation: factor out selection CHANGELOG_BEGIN CHANGELOG_END --- azure-pipelines.yml | 3 ++- ci/bash-lib.yml | 4 ++++ ci/cron/tuesday.yml | 2 +- ci/cron/wednesday.yml | 18 ++++++++---------- ci/prs.yml | 2 +- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 2f87856f9fb2..717854a7c634 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -131,10 +131,11 @@ jobs: condition: and(succeeded(), not(eq(variables['skip-github'], 'TRUE'))) - bash: | set -euo pipefail + source $(bash-lib) msg=$(git log -n1 --format=%b HEAD | head -1) # Keep this line in sync with RELEASE_PR_NOTIF in ci/cron/wednesday.yml if [ "$msg" = "This PR has been created by a script, which is not very smart" ]; then - pr_handler="<@$(awk '/^[^#]/ {print $1}' release/rotation | head -n 1)>" + pr_handler="<@$(next_in_rotation)>" else pr_handler="" fi diff --git a/ci/bash-lib.yml b/ci/bash-lib.yml index 110c44c1872c..106448b71673 100644 --- a/ci/bash-lib.yml +++ b/ci/bash-lib.yml @@ -8,6 +8,7 @@ steps: - bash: | set -euo pipefail TMP=$(mktemp) + PROJ_DIR="$(pwd)" cat > $TMP <<'END' escape_slack() { local r @@ -148,6 +149,9 @@ steps: echo "Setting '$1' to '$2'" echo "##vso[task.setvariable variable=$1;isOutput=true]$2" } + next_in_rotation() { + awk '/^[^#]/ {print $1}' "$PROJ_DIR/release/rotation" | head -n 1 + } END echo "##vso[task.setvariable variable=${{parameters.var_name}}]$TMP" diff --git a/ci/cron/tuesday.yml b/ci/cron/tuesday.yml index e8bf95632273..f54945105701 100644 --- a/ci/cron/tuesday.yml +++ b/ci/cron/tuesday.yml @@ -28,6 +28,6 @@ jobs: source "$(bash_lib)" - RELEASE_MANAGER=$(awk '/^[^#]/ {print $1}' release/rotation | head -n 1) + RELEASE_MANAGER=$(next_in_rotation) tell_slack "$(echo -e "Hi <@$RELEASE_MANAGER>! According to the , you are in charge of the release tomorrow. Please make sure you plan accordingly, or find a replacement.\n\nIf anyone knows of any reason to delay or block the release (e.g. a PR that needs to get merged first), please make it known in thread before EOD.")" diff --git a/ci/cron/wednesday.yml b/ci/cron/wednesday.yml index 9860c0695758..639a3d6351a9 100644 --- a/ci/cron/wednesday.yml +++ b/ci/cron/wednesday.yml @@ -88,14 +88,12 @@ jobs: # labels, PRs are issues as far as the GH API is concerned. } rotate() { - # limitation: comments in the middle of the rotation will be hoisted to the top - local comments rotation - comments=$(mktemp) - rotation=$(mktemp) - awk '/^#/' release/rotation > $comments - awk '/^[^#]/' release/rotation > $rotation - cp $comments release/rotation - (tail -n +2 $rotation; head -1 $rotation) >> release/rotation + local tmp next + tmp=$(mktemp) + next=$(next_in_rotation) + grep -v "$next" release/rotation > $tmp + grep "$next" release/rotation >> $tmp + mv $tmp release/rotation } release_message() { local handler=$1 @@ -123,8 +121,8 @@ jobs: reset - NEXT_SLACK=$(awk '/^[^#]/ {print $1}' release/rotation | head -n 1) - NEXT_GH=$(awk '/^[^#]/ {print $2}' release/rotation | head -n 1) + NEXT_SLACK=$(next_in_rotation) + NEXT_GH=$(grep "$NEXT_SLACK" release/rotation | awk '{print $2}') PREV="v$(head -1 LATEST | awk '{print $2}')" ./release.sh new snapshot diff --git a/ci/prs.yml b/ci/prs.yml index 842919c25104..8e51ab9f4602 100644 --- a/ci/prs.yml +++ b/ci/prs.yml @@ -123,7 +123,7 @@ jobs: # API, there is still value in getting the notification on Slack, as # we do have the build number and from there we can click through to # the PR. Hence the `|| echo ""`. - PR_HANDLER=$(awk '/^[^#]/ {print $1}' release/rotation | head -n 1) + PR_HANDLER=$(next_in_rotation) case "$(status)" in Succeeded*) From ebfb5535c9595eab1ab697c75c933eb61f143baa Mon Sep 17 00:00:00 2001 From: Gary Verhaegen Date: Thu, 7 Oct 2021 13:49:46 +0200 Subject: [PATCH 2/2] review comment --- azure-pipelines.yml | 2 +- ci/bash-lib.yml | 8 +++++++- ci/cron/tuesday.yml | 2 +- ci/cron/wednesday.yml | 6 +++--- ci/prs.yml | 2 +- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 717854a7c634..1f47df8b3f8d 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -135,7 +135,7 @@ jobs: msg=$(git log -n1 --format=%b HEAD | head -1) # Keep this line in sync with RELEASE_PR_NOTIF in ci/cron/wednesday.yml if [ "$msg" = "This PR has been created by a script, which is not very smart" ]; then - pr_handler="<@$(next_in_rotation)>" + pr_handler="<@$(next_in_rotation_slack)>" else pr_handler="" fi diff --git a/ci/bash-lib.yml b/ci/bash-lib.yml index 106448b71673..73195ac836c5 100644 --- a/ci/bash-lib.yml +++ b/ci/bash-lib.yml @@ -150,7 +150,13 @@ steps: echo "##vso[task.setvariable variable=$1;isOutput=true]$2" } next_in_rotation() { - awk '/^[^#]/ {print $1}' "$PROJ_DIR/release/rotation" | head -n 1 + awk '/^[^#]/ {print $0}' "$PROJ_DIR/release/rotation" | head -n 1 + } + next_in_rotation_slack() { + next_in_rotation | awk '{print $1}' + } + next_in_rotation_github() { + next_in_rotation | awk '{print $2}' } END diff --git a/ci/cron/tuesday.yml b/ci/cron/tuesday.yml index f54945105701..afecd4c1ab84 100644 --- a/ci/cron/tuesday.yml +++ b/ci/cron/tuesday.yml @@ -28,6 +28,6 @@ jobs: source "$(bash_lib)" - RELEASE_MANAGER=$(next_in_rotation) + RELEASE_MANAGER=$(next_in_rotation_slack) tell_slack "$(echo -e "Hi <@$RELEASE_MANAGER>! According to the , you are in charge of the release tomorrow. Please make sure you plan accordingly, or find a replacement.\n\nIf anyone knows of any reason to delay or block the release (e.g. a PR that needs to get merged first), please make it known in thread before EOD.")" diff --git a/ci/cron/wednesday.yml b/ci/cron/wednesday.yml index 639a3d6351a9..17febeb222aa 100644 --- a/ci/cron/wednesday.yml +++ b/ci/cron/wednesday.yml @@ -92,7 +92,7 @@ jobs: tmp=$(mktemp) next=$(next_in_rotation) grep -v "$next" release/rotation > $tmp - grep "$next" release/rotation >> $tmp + echo "$next" >> $tmp mv $tmp release/rotation } release_message() { @@ -121,8 +121,8 @@ jobs: reset - NEXT_SLACK=$(next_in_rotation) - NEXT_GH=$(grep "$NEXT_SLACK" release/rotation | awk '{print $2}') + NEXT_SLACK=$(next_in_rotation_slack) + NEXT_GH=$(next_in_rotation_github) PREV="v$(head -1 LATEST | awk '{print $2}')" ./release.sh new snapshot diff --git a/ci/prs.yml b/ci/prs.yml index 8e51ab9f4602..213b5e68b053 100644 --- a/ci/prs.yml +++ b/ci/prs.yml @@ -123,7 +123,7 @@ jobs: # API, there is still value in getting the notification on Slack, as # we do have the build number and from there we can click through to # the PR. Hence the `|| echo ""`. - PR_HANDLER=$(next_in_rotation) + PR_HANDLER=$(next_in_rotation_slack) case "$(status)" in Succeeded*)