Skip to content

Commit

Permalink
ci: various cleanups
Browse files Browse the repository at this point in the history
This patch does some various cleanups to our rust ci pipeline. In
particular it runs linting (clippy, rustfmt) as well as tests using the
compiler toolchain specified inside of the `rust-toolchain` file instead
of overriding it with either `stable` or `nightly` either of which could
cause CI to break when a new toolchain is released to the stable or
nightly channels.

It also moves canarying of a new compiler toolchain from the workflow
that runs on every PR to a 'nightly' Github Action workflow. It also
prefers using the 'beta' channel instead of 'nightly' channel in order
to reduce noise.
  • Loading branch information
bmwill committed Mar 31, 2022
1 parent 2314465 commit 76015a1
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 82 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Rust
name: nightly

on:
schedule:
- cron: '0 0 * * *' # every day at midnight
- cron: '0 0 * * *' # every day at midnight

env:
CARGO_TERM_COLOR: always
Expand All @@ -27,26 +27,36 @@ env:
RUST_BACKTRACE: short

jobs:

test:
name: Test Rust ${{matrix.toolchain}} on ${{matrix.os}}
runs-on: ${{matrix.os}}-latest
strategy:
fail-fast: false
matrix:
toolchain: [stable, nightly]
os: [ubuntu]
beta:
name: Run test on the beta channel
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install rust
- name: Install beta toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{matrix.toolchain}}
profile: minimal
toolchain: beta
components: clippy
override: true
- uses: Swatinem/rust-cache@v1
- name: Test
- name: cargo clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-targets -- -D clippy::all -D warnings -D clippy::disallowed_methods
- name: cargo test
uses: actions-rs/cargo@v1
with:
command: test
args: --all-features --release --profile=release
args: --all-features

release:
name: build release binaries
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- name: cargo build
uses: actions-rs/cargo@v1
with:
command: build
args: --all-targets --all-features --release --profile=release
86 changes: 21 additions & 65 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,102 +43,60 @@ jobs:
isRust:
- '!(explorer|doc|.github)/**'
- '.github/workflows/rust.yml'
release-check:
name: Rust release-mode compilation nightly on ubuntu
needs: diff
if: needs.diff.outputs.isRust == 'true'
license-check:
name: license-check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install rust
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
profile: minimal
override: true
- uses: Swatinem/rust-cache@v1
- name: Check
uses: actions-rs/cargo@v1
with:
command: check
args: --all --tests -Z unstable-options --profile=release
- run: scripts/license_check.sh

test:
name: Test Rust ${{matrix.toolchain}} on ${{matrix.os}}
needs: diff
runs-on: ${{matrix.os}}-latest
if: needs.diff.outputs.isRust == 'true'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
toolchain: [stable, nightly]
os: [ubuntu]
steps:
- uses: actions/checkout@v2
if: needs.diff.outputs.isRust == 'true'
- name: Install rust
if: needs.diff.outputs.isRust == 'true'
uses: actions-rs/toolchain@v1
with:
toolchain: ${{matrix.toolchain}}
profile: minimal
override: true
- uses: actions-rs/toolchain@v1
- uses: Swatinem/rust-cache@v1
if: needs.diff.outputs.isRust == 'true'
- name: Test
if: needs.diff.outputs.isRust == 'true'
- name: cargo test
uses: actions-rs/cargo@v1
with:
command: test
args: --all-features

clippy:
name: Clippy
needs: diff
if: needs.diff.outputs.isRust == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install minimal nightly with clippy
uses: actions-rs/toolchain@v1
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
components: clippy
override: true
- uses: Swatinem/rust-cache@v1
- name: Clippy
- name: cargo clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all --tests -- -D clippy::all -D warnings -D clippy::disallowed_methods
args: --all-targets -- -D clippy::all -D warnings -D clippy::disallowed_methods

rustfmt:
name: rustfmt
needs: diff
if: needs.diff.outputs.isRust == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install minimal nightly with rustfmt
uses: actions-rs/toolchain@v1
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
components: rustfmt
override: true
- uses: Swatinem/rust-cache@v1
- name: rustfmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check

license-check:
name: license-check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: scripts/license_check.sh
args: --all --check

cargo-deny:
name: cargo-deny (advisories, licenses, bans, ...)
Expand All @@ -150,22 +108,20 @@ jobs:
- uses: EmbarkStudios/cargo-deny-action@v1

cargo-udeps:
name: cargo-udeps
needs: diff
if: needs.diff.outputs.isRust == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install minimal nightly
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
- uses: actions-rs/toolchain@v1
- uses: Swatinem/rust-cache@v1
- name: Install cargo-udeps, and cache the binary
uses: baptiste0928/cargo-install@v1
with:
crate: cargo-udeps
locked: true
# Normally running cargo-udeps requires use of a nightly compiler
# In order to have a more stable and less noisy experience, lets instead
# opt to use the stable toolchain specified via the 'rust-toolchain' file
# and instead enable nightly features via 'RUSTC_BOOTSTRAP'
- name: run cargo-udeps
run: cargo +nightly udeps
run: RUSTC_BOOTSTRAP=1 cargo udeps

0 comments on commit 76015a1

Please sign in to comment.