Skip to content

Commit

Permalink
CI: Break out lint as a job, and pass RUSTFLAGS=-Dwarnings.
Browse files Browse the repository at this point in the history
This will cause the CI job to actually fail on rustc or clippy warnings,
rather than passing and thus requiring us to manually check the output.
  • Loading branch information
kpreid committed Jul 25, 2024
1 parent 4cb3c83 commit 418afee
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 10 deletions.
86 changes: 76 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,17 +173,13 @@ jobs:
- run: df -h .

# Run clippy and docs to get warnings.
- name: Lint
run: cargo xtask --scope=only-normal lint --timings

# Save timing reports so we can download and view them
# (for understanding build performance in CI)
- name: Save cargo --timings output
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: cargo-timings ${{ matrix.os }} ${{ matrix.toolchain }} ${{ matrix.depversions }}
name: cargo-timings build ${{ matrix.os }} ${{ matrix.toolchain }} ${{ matrix.depversions }}
path: |
target/cargo-timings/cargo-timing-*.html
Expand Down Expand Up @@ -228,9 +224,83 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Run `xtask lint`.
#
# This job is separate from the main "build" job so that:
# * Lint results are delivered quickly by running them in parallel with other jobs.
# * We build with `-Dwarnings` so the failures aren't silent, but don't want this to
# cause *re*building in the main build job and its cache.
lint:
strategy:
fail-fast: false
matrix:
toolchain: ["stable", "nightly", "beta"]

runs-on: ubuntu-latest
continue-on-error: false

env:
RUSTFLAGS: '-Dwarnings'

steps:
- uses: actions/checkout@v4

- name: Set Rust toolchain
# The rust-toolchain.toml file specifies the targets and components we need,
# but we may want to override the toolchain.
if: ${{ matrix.toolchain != 'stable' }}
run: |
sed -i.origstable "s/stable/${{ matrix.toolchain }}/" rust-toolchain.toml
rustup show # triggers installation of selected toolchain
- name: Install native libraries
if: ${{ runner.os == 'Linux' }}
run: |
sudo apt update
sudo apt-get -y install libxrandr-dev xorg-dev libx11-xcb-dev libwayland-dev libasound2-dev libudev-dev
- run: df -h .

- uses: Swatinem/[email protected]
with:
# We cannot reuse the cache from the `build` job, because `RUSTFLAGS=-Dwarnings`
# would invalidate all cached artifacts anyway.
prefix-key: "v1-rust-${{ matrix.toolchain }}"
shared-key: "lint"
# Job's likely to fail and yet have useful cache material.
cache-on-failure: true

- name: Install tools
run: |
cargo install --locked [email protected]
- run: df -h .

# break this out as a separate non-silenced build step
- name: Compile xtask
run: cargo build --package xtask

# Kludge: Avoid dependency on `cargo-about` by making the generated license info file look fresh.
- name: Skip license generation
run: touch all-is-cubes-wasm/static/third-party-licenses.html

- name: Lint
run: cargo xtask --scope=only-normal lint --timings

- run: df -h .

- name: Save cargo --timings output
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: cargo-timings lint ${{ matrix.toolchain }}
path: |
target/cargo-timings/cargo-timing-*.html
# Run `xtask test-more` to look for broken `features`.
features:
# Don't spend time on this if the normal builds failed.
# Also, we reuse the cache from it.
needs: build
runs-on: ubuntu-latest
continue-on-error: false
Expand All @@ -249,17 +319,13 @@ jobs:
run: |
sudo apt update
sudo apt-get -y install libxrandr-dev xorg-dev libx11-xcb-dev libwayland-dev libasound2-dev libudev-dev
# libxrandr-dev xorg-dev libx11-xcb-dev libwayland-dev: needed for windowing
# Note that `libwayland-dev` provides the library called `wayland-client`
# libasound2-dev: needed for audio via `kira`
# libudev-dev: needed for gamepad input via `gilrs`
# Load cache before doing any Rust builds
- uses: Swatinem/[email protected]
with:
# Reuse the cache from the normal `build` job instead of creating an independent one,
# to reduce redundant work and save disk space — but don't *write* to that cache, so
# we don't bloat it.
# we don't bloat it or conflict.
prefix-key: "v1-rust-ubuntu-stable-locked"
shared-key: "build"
save-if: false
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/unstable-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# * no deployment
# * no testing of multiple feature configurations
# * no concept of a "primary" matrix configuration
# * no separate lint job

name: Unstable Rust Features

Expand Down

0 comments on commit 418afee

Please sign in to comment.