-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #12200 - weihanglo:which-channel-backport-rust-1.71.0, …
…r=<try> chore: detect the channel a PR wants to merge into ### What does this PR try to resolve? This detects which channel a pull request wants to merge into. It is hard because bors runs in a different repo. Bors knows nothing about branches or tag in this repo. It only see one base commit and a merge commit AFAIK. Basically the assumption and idea are 1. bors create a merge commit, so `HEAD~` should find the base branch. 2. Cargo maintains `rust-1.y.0` branch for each Rust minor version releases. Therefore, we can use the symbolic name of `origin/rust-1.x.0` to determine if it aims for stable, beta, or nightly channel. 3. After we know which channel it is targeted at, we can skip jobs that are likely to be broken. ### How should we test and review this PR? This is like #12181 but targeted on 1.71.0. r? ehuss
- Loading branch information
Showing
3 changed files
with
159 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
[ | ||
{ | ||
"name": "Linux x86_64 stable", | ||
"os": "ubuntu-latest", | ||
"rust": "stable", | ||
"other": "i686-unknown-linux-gnu" | ||
}, | ||
{ | ||
"name": "Linux x86_64 beta", | ||
"os": "ubuntu-latest", | ||
"rust": "beta", | ||
"other": "i686-unknown-linux-gnu" | ||
}, | ||
{ | ||
"name": "Linux x86_64 nightly", | ||
"os": "ubuntu-latest", | ||
"rust": "nightly", | ||
"other": "i686-unknown-linux-gnu" | ||
}, | ||
{ | ||
"name": "macOS x86_64 stable", | ||
"os": "macos-latest", | ||
"rust": "stable", | ||
"other": "x86_64-apple-ios" | ||
}, | ||
{ | ||
"name": "macOS x86_64 nightly", | ||
"os": "macos-latest", | ||
"rust": "nightly", | ||
"other": "x86_64-apple-ios" | ||
}, | ||
{ | ||
"name": "Windows x86_64 MSVC stable", | ||
"os": "windows-latest", | ||
"rust": "stable-msvc", | ||
"other": "i686-pc-windows-msvc" | ||
}, | ||
{ | ||
"name": "Windows x86_64 gnu nightly", | ||
"os": "windows-latest", | ||
"rust": "nightly-gnu", | ||
"other": "i686-pc-windows-gnu" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/bin/bash | ||
# This script outputs the channel where a CI workflow wants to merge into. | ||
# | ||
# Inputs: | ||
# BASE_SHA The commit SHA of the branch where the PR wants to merge into. | ||
# | ||
# GitHub Action Outputs: | ||
# CHANNEL Target channel where the PR wants to merge into. | ||
|
||
set -euo pipefail | ||
|
||
# When `BASE_SHA` is missing, we assume it is from bors merge commit, | ||
# so hope `HEAD~` to find the previous commit on master branch. | ||
base_sha=$(git rev-parse "${BASE_SHA:-HEAD~1}") | ||
|
||
# Get symbolic names for the base_sha. | ||
# Assumption: Cargo branches are always in the format of `rust-1.*.0`, | ||
# otherwise `git name-rev` will return "undefined". | ||
ref=$(git name-rev --name-only --refs='origin/rust-1.*.0' $base_sha) | ||
|
||
# Get the latest `rust-1.*.0` branch from remote origin. | ||
# Assumption: The latest branch is always beta branch. | ||
beta=$( | ||
git branch --remotes --list 'origin/rust-1.*.0' \ | ||
| sort --version-sort \ | ||
| tail -n1 \ | ||
| tr -d "[:space:]" | ||
) | ||
|
||
master=$(git rev-parse origin/master) | ||
|
||
# Backport pull requests always target at a `rust-1.*.0` branch. | ||
if [[ "$ref" = "undefined" ]] || [[ "$base_sha" = "$master" ]] | ||
then | ||
# Should be nightly but for convenience in CI let's call it master. | ||
channel="master" | ||
elif [[ "$ref" = "$beta" ]] | ||
then | ||
channel="beta" | ||
else | ||
channel="stable" | ||
fi | ||
|
||
echo "Base sha: $base_sha" | ||
echo "Git Ref: $ref" | ||
echo "master: $master" | ||
echo "beta: $beta" | ||
echo "Channel: $channel" | ||
|
||
echo "CHANNEL=$channel" >> "$GITHUB_OUTPUT" |