From 392723ec6e643f694a66e47941e5c8ae670e219f Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Thu, 6 May 2021 18:47:37 +0200 Subject: ci: error out if someone sends a PR to the wrong branch --- src/ci/scripts/verify-channel.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 src/ci/scripts/verify-channel.sh (limited to 'src/ci/scripts') diff --git a/src/ci/scripts/verify-channel.sh b/src/ci/scripts/verify-channel.sh new file mode 100755 index 00000000000..7945512738e --- /dev/null +++ b/src/ci/scripts/verify-channel.sh @@ -0,0 +1,28 @@ +#!/bin/bash +# We want to make sure all PRs are targeting the right branch when they're +# opened, otherwise we risk (for example) to land a beta-specific change to the +# master branch. This script ensures the branch of the PR matches the channel. + +set -euo pipefail +IFS=$'\n\t' + +source "$(cd "$(dirname "$0")" && pwd)/../shared.sh" + +declare -A CHANNEL_BRANCH +CHANNEL_BRANCH["nightly"]="master" +CHANNEL_BRANCH["beta"]="beta" +CHANNEL_BRANCH["stable"]="stable" + +if isCiBranch auto || isCiBranch try; then + echo "channel verification is only executed on PR builds" + exit +fi + +channel=$(cat "$(ciCheckoutPath)/src/ci/channel") +branch="$(ciBaseBranch)" +if [[ "${branch}" != "${CHANNEL_BRANCH[$channel]}" ]]; then + echo "error: PRs changing the \`${channel}\` channel should be sent to the \ +\`${CHANNEL_BRANCH[$channel]}\` branch!" + + exit 1 +fi -- cgit 1.4.1-3-g733a5 From a8da3335e6e6f6d6ad8500205ded61a5351dc2b4 Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Wed, 12 May 2021 12:15:39 +0200 Subject: make verify-channel.sh compatible with macOS --- src/ci/scripts/verify-channel.sh | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'src/ci/scripts') diff --git a/src/ci/scripts/verify-channel.sh b/src/ci/scripts/verify-channel.sh index 7945512738e..d02dc362c63 100755 --- a/src/ci/scripts/verify-channel.sh +++ b/src/ci/scripts/verify-channel.sh @@ -8,21 +8,31 @@ IFS=$'\n\t' source "$(cd "$(dirname "$0")" && pwd)/../shared.sh" -declare -A CHANNEL_BRANCH -CHANNEL_BRANCH["nightly"]="master" -CHANNEL_BRANCH["beta"]="beta" -CHANNEL_BRANCH["stable"]="stable" - if isCiBranch auto || isCiBranch try; then echo "channel verification is only executed on PR builds" exit fi channel=$(cat "$(ciCheckoutPath)/src/ci/channel") +case "${channel}" in + nightly) + channel_branch="master" + ;; + beta) + channel_branch="beta" + ;; + stable) + channel_branch="stable" + ;; + *) + echo "error: unknown channel defined in src/ci/channel: ${channel}" + exit 1 +esac + branch="$(ciBaseBranch)" -if [[ "${branch}" != "${CHANNEL_BRANCH[$channel]}" ]]; then +if [[ "${branch}" != "${channel_branch}" ]]; then echo "error: PRs changing the \`${channel}\` channel should be sent to the \ -\`${CHANNEL_BRANCH[$channel]}\` branch!" +\`${channel_branch}\` branch!" exit 1 fi -- cgit 1.4.1-3-g733a5