Skip to content

Commit

Permalink
Auto merge of #12204 - rust-lang:revert-12181-which-channel-backport,…
Browse files Browse the repository at this point in the history
… r=epage

Revert "chore: detect the channel a PR wants to merge into"

Reverts #12181

GitHub Action expression `success()` will look into the chain of dependent jobs. On master CI passed but on a backport it still failed <#12200 (comment)>

This isn't worth pursuing at this moment either. To fix it, it's unavoidable to write something like below for bors job

```yaml
    if: "always()
      && !(contains(needs.*.result, 'cancelled')
        || contains(needs.*.result, 'skipped')
        || contains(needs.*.result, 'failure')
      )
      && github.event_name == 'push'
      && github.ref == 'refs/heads/auto-cargo'
    "
```

I don't think that's good in long-term.

r? ehuss
  • Loading branch information
bors committed May 30, 2023
2 parents f7b95e3 + ffbf0ec commit 814aa46
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 165 deletions.
104 changes: 33 additions & 71 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,6 @@ env:
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse

jobs:
# Determine which channel will be merged into.
channel:
runs-on: ubuntu-latest
outputs:
CHANNEL: ${{ steps.channel.outputs.CHANNEL }}
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # fetch all branches
- id: channel
run: ci/which-channel.sh

# Check Code style quickly by running `rustfmt` over all code
rustfmt:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -77,42 +63,8 @@ jobs:
- run: rustup update stable && rustup default stable
- run: ci/validate-version-bump.sh

# Generate strategy matrix for different platforms and channels
# (see ci/matrix.json)
matrix:
runs-on: ubuntu-latest
needs:
- channel
outputs:
matrix: ${{ steps.matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v3
- name: Generate strategy matrix
id: matrix
run: |
CHANNEL=${{ needs.channel.outputs.CHANNEL }}
# This reads ci/matrix.json and then filters the environment we want to
# build on, based on the channel this PR want to merge into.
#
# * For stable, we build only on stable toolchain.
# * For beta, we build on stable and beta.
# * For nightly, we build on stable, beta, and nightly.
MATRIX=$(
jq --arg C "$CHANNEL" 'map (. |
if ($C == "beta") then select(.rust | startswith("nightly") | not)
elif ($C == "stable") then select(.rust | startswith("stable"))
else . end)' ci/matrix.json
)
echo "$MATRIX"
# Outputs as Job's outputs for other jobs to reuse.
echo "MATRIX={\"include\":$(echo $MATRIX)}" >> "$GITHUB_OUTPUT"
test:
runs-on: ${{ matrix.os }}
needs:
- matrix
env:
CARGO_PROFILE_DEV_DEBUG: 1
CARGO_PROFILE_TEST_DEBUG: 1
Expand All @@ -121,7 +73,36 @@ jobs:
# Deny warnings on CI to avoid warnings getting into the codebase.
RUSTFLAGS: -D warnings
strategy:
matrix: ${{ fromJSON(needs.matrix.outputs.MATRIX) }}
matrix:
include:
- 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 # runs out of space while trying to link the test suite
os: windows-latest
rust: nightly-gnu
other: i686-pc-windows-gnu
name: Tests ${{ matrix.name }}
steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -199,9 +180,6 @@ jobs:

build_std:
runs-on: ubuntu-latest
needs:
- channel
if: needs.channel.outputs.CHANNEL == 'master'
steps:
- uses: actions/checkout@v3
- run: rustup update nightly && rustup default nightly
Expand All @@ -212,8 +190,6 @@ jobs:
CARGO_RUN_BUILD_STD_TESTS: 1
docs:
runs-on: ubuntu-latest
needs:
- channel
steps:
- uses: actions/checkout@v3
- run: rustup update nightly && rustup default nightly
Expand All @@ -235,36 +211,22 @@ jobs:
- run: cd src/doc && mdbook build --dest-dir ../../target/doc
- name: Run linkchecker.sh
run: |
BRANCH=${{ needs.channel.outputs.CHANNEL }}
cd target
curl -sSLO "https://raw.githubusercontent.com/rust-lang/rust/$BRANCH/src/tools/linkchecker/linkcheck.sh"
curl -sSLO https://raw.githubusercontent.com/rust-lang/rust/master/src/tools/linkchecker/linkcheck.sh
sh linkcheck.sh --all --path ../src/doc cargo
# Jobs that may be skipped if they aren't going to merge into master (nightly).
#
# This is needed because GitHub Actions treats success() as false if a job is
# skipped, and the bors success/failure jobs below need to ignore skipped jobs.
z-nightly-jobs:
needs:
- channel
- build_std
if: "(needs.channel.outputs.CHANNEL != 'master' && !failure()) || success()"
runs-on: ubuntu-latest
steps:
- run: exit 0

success:
permissions:
contents: none
name: bors build finished
needs:
- build_std
- docs
- lockfile
- resolver
- rustfmt
- test
- test_gitoxide
- z-nightly-jobs
runs-on: ubuntu-latest
if: "success() && github.event_name == 'push' && github.ref == 'refs/heads/auto-cargo'"
steps:
Expand All @@ -274,13 +236,13 @@ jobs:
contents: none
name: bors build finished
needs:
- build_std
- docs
- lockfile
- resolver
- rustfmt
- test
- test_gitoxide
- z-nightly-jobs
runs-on: ubuntu-latest
if: "!success() && github.event_name == 'push' && github.ref == 'refs/heads/auto-cargo'"
steps:
Expand Down
44 changes: 0 additions & 44 deletions ci/matrix.json

This file was deleted.

50 changes: 0 additions & 50 deletions ci/which-channel.sh

This file was deleted.

0 comments on commit 814aa46

Please sign in to comment.