Skip to content

Commit

Permalink
Add CI/CD validation against Beta and Nightly Rust
Browse files Browse the repository at this point in the history
  • Loading branch information
matej-almasi authored and Matej Almasi committed Dec 9, 2024
1 parent 52a83dc commit d0a49cf
Showing 1 changed file with 86 additions and 4 deletions.
90 changes: 86 additions & 4 deletions .github/workflows/pr-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Rust
uses: actions-rust-lang/setup-rust-toolchain@v1

- name: Cache Cargo and cross
uses: actions/cache@v4
with:
Expand All @@ -50,13 +53,90 @@ jobs:
cargo install cross
fi
- name: Build
run: ${{ matrix.platform.command }} build --target ${{ matrix.platform.target }}
- name: Build stable
id: build
run: ${{ matrix.platform.command }} build --target ${{ matrix.platform.target }};

- name: Test stable
id: test
run: ${{ matrix.platform.command }} test --target ${{ matrix.platform.target }};

- name: Set up Rust beta
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: beta

- name: Test
run: ${{ matrix.platform.command }} test --target ${{ matrix.platform.target }}
- name: Build beta
id: build-beta
run: ${{ matrix.platform.command }} +beta build --target ${{ matrix.platform.target }};
continue-on-error: true

- name: Test beta
id: test-beta
if: ${{ steps.build-beta.outcome == 'success' }}
run: ${{ matrix.platform.command }} +beta test --target ${{ matrix.platform.target }};
continue-on-error: true

- name: Set up Rust nightly
if: ${{ steps.build-beta.outcome == 'success' }}
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: nightly

- name: Build nightly
id: build-nightly
if: ${{ steps.build-beta.outcome == 'success' }}
run: ${{ matrix.platform.command }} +nightly build --target ${{ matrix.platform.target }};
continue-on-error: true

- name: Test nightly
id: test-nightly
if: ${{ steps.build-nightly.outcome == 'success' }}
run: ${{ matrix.platform.command }} +nightly test --target ${{ matrix.platform.target }};
continue-on-error: true

- name: Issue warnings for beta/ nightly fails
if: >
${{ steps.build-beta.outcome == 'failure' ||
steps.test-beta.outcome == 'failure' ||
steps.build-nightly.outcome == 'failure' ||
steps.test-nightly.outcome == 'failure'}}
uses: actions/github-script@v7
with:
script: |
let body = "";
const beta_build_fail = ${{ steps.build-beta.outcome == 'failure' }};
const nightly_build_fail = ${{ steps.build-nightly.outcome == 'failure' }};
if (beta_build_fail || nightly_build_fail) {
const failed_toolchain = beta_build_fail ? "beta" : "nightly"
body = body.concat(`🚨 🛠️ Build Failures on **${failed_toolchain}** Rust with **${{ matrix.platform.target }}** target.\n`)
}
const beta_test_fail = ${{ steps.test-beta.outcome == 'failure' }};
const nightly_test_fail = ${{ steps.test-nightly.outcome == 'failure' }};
if (beta_test_fail || nightly_test_fail) {
let failed_toolchain = beta_build_fail ? "beta" : ""
if (nightly_test_fail) {
failed_toolchain = failed_toolchain.concat(" and nightly")
}
body = body.concat(`🚨 ❌ Test Failures on **${failed_toolchain}** Rust with **${{ matrix.platform.target }}** target.`)
}
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
body: body
});
format:
needs: build-and-test

runs-on: ubuntu-latest

steps:
Expand All @@ -73,6 +153,8 @@ jobs:
run: cargo +nightly fmt --check

clippy:
needs: build-and-test

runs-on: ubuntu-latest

steps:
Expand Down

0 comments on commit d0a49cf

Please sign in to comment.