diff options
| author | bors <bors@rust-lang.org> | 2021-05-15 05:20:49 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-05-15 05:20:49 +0000 |
| commit | 428636f954204abb8a561a0bd08dc340fc0985c0 (patch) | |
| tree | d679746e5d66a484f90e9159f14b291fb17e5361 /src/ci/scripts | |
| parent | 1025db84a68b948139b5adcd55da31bce32da8f3 (diff) | |
| parent | a8da3335e6e6f6d6ad8500205ded61a5351dc2b4 (diff) | |
| download | rust-428636f954204abb8a561a0bd08dc340fc0985c0.tar.gz rust-428636f954204abb8a561a0bd08dc340fc0985c0.zip | |
Auto merge of #84997 - pietroalbini:ci-verify-channel, r=Mark-Simulacrum
Error out if a PR is sent to the wrong channel It happened multiple times that a PR meant to go on beta ends up being opened (and occasionally merged) to master. This PR does two things: * Moves the definition of the channel in `src/ci/channel` so it's easier for tools to read it. I was not sure whether to move it to `src/channel` (like `src/version`): ended up with `src/ci` as it's currently only used for CI, but I'm open to moving it to `src`. We'll need to update the release process after this. * Adds a check on **non-bors** builds that errors out if the base branch is not the expected one for the currently defined channel. This will not cause problems for promotion PRs, as those PRs are meant to also update the channel name. r? `@Mark-Simulacrum`
Diffstat (limited to 'src/ci/scripts')
| -rwxr-xr-x | src/ci/scripts/verify-channel.sh | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/ci/scripts/verify-channel.sh b/src/ci/scripts/verify-channel.sh new file mode 100755 index 00000000000..d02dc362c63 --- /dev/null +++ b/src/ci/scripts/verify-channel.sh @@ -0,0 +1,38 @@ +#!/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" + +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}" ]]; then + echo "error: PRs changing the \`${channel}\` channel should be sent to the \ +\`${channel_branch}\` branch!" + + exit 1 +fi |
