Skip to content

Add post-release workflow #38

Add post-release workflow

Add post-release workflow #38

Workflow file for this run

name: PR Validation
on:
pull_request:
branches:
- main
env:
CARGO_TERM_COLOR: always
jobs:
build-and-test:
runs-on: ${{ matrix.platform.os }}
strategy:
fail-fast: false
matrix:
platform:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
command: cargo
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
command: cross
- os: windows-latest
target: x86_64-pc-windows-msvc
command: cargo
steps:
- 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:
path: |
~/.cargo/registry
~/.cargo/git
~/.cargo/bin
key: ${{ matrix.platform.target }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ matrix.platform.target }}-cargo
- name: Install cross
if: matrix.platform.command == 'cross'
run: |
if ! command -v cross &>/dev/null; then
cargo install cross
fi
- 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: 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:
- name: Checkout code
uses: actions/checkout@v4
- name: Install nightly
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: nightly
components: rustfmt
- name: Format
run: cargo +nightly fmt --check
clippy:
needs: build-and-test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Clippy lint
run: cargo clippy -- -D warnings