CI workflow (serde-rs/serde)
The CI workflow from serde-rs/serde, explained and optimized by Latchkey.
CI health: B - good
Point runs-on at Latchkey and get run de-duplication, SHA-pinned actions, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the CI workflow from the serde-rs/serde repository, a real project running GitHub Actions. It is shown here with attribution under its Apache-2.0 license.
Below, Latchkey shows a faster, safer version produced by its optimization engine.
The workflow
name: CI
on:
push:
pull_request:
workflow_dispatch:
schedule: [cron: "40 1 * * *"]
permissions:
contents: read
env:
RUSTFLAGS: -Dwarnings
jobs:
test:
name: Test suite
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@nightly
- run: cd test_suite && cargo test --features unstable
- uses: actions/upload-artifact@v7
if: always()
with:
name: Cargo.lock
path: Cargo.lock
continue-on-error: true
windows:
name: Test suite (windows)
runs-on: windows-latest
timeout-minutes: 45
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@nightly
- run: cd test_suite && cargo test --features unstable -- --skip ui --exact
stable:
name: Rust ${{matrix.rust}}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
rust: [stable, beta]
timeout-minutes: 45
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{matrix.rust}}
- run: cd serde && cargo build --features rc
- run: cd serde && cargo build --no-default-features
- run: cd test_suite/no_std && cargo build
nightly:
name: Rust nightly${{matrix.os == 'windows' && ' (windows)' || ''}}
runs-on: ${{matrix.os}}-latest
strategy:
fail-fast: false
matrix:
os: [ubuntu, windows]
timeout-minutes: 45
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@nightly
- run: cd serde && cargo build
- run: cd serde && cargo build --no-default-features
- run: cd serde && cargo build --no-default-features --features alloc
- run: cd serde && cargo build --no-default-features --features rc,alloc
- run: cd serde && cargo build --no-default-features --features unstable
- run: cd serde_core && cargo test --features rc,unstable
- run: cd test_suite/no_std && cargo build
if: matrix.os != 'windows'
- run: cd serde_derive && cargo check --tests
env:
RUSTFLAGS: --cfg exhaustive ${{env.RUSTFLAGS}}
if: matrix.os != 'windows'
build:
name: Rust ${{matrix.rust}}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
rust: [1.56.0, 1.60.0]
timeout-minutes: 45
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{matrix.rust}}
- run: sed -i '/"test_suite"/d' Cargo.toml
- run: cd serde && cargo build --features rc
- run: cd serde && cargo build --no-default-features
- run: cd serde && cargo build --no-default-features --features alloc
- run: cd serde && cargo build
derive:
name: Rust 1.71.0
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@1.71.0
- run: |
sed -i 's/proc-macro2 = { workspace = true/proc-macro2 = { version = "1"/' serde_derive*/Cargo.toml
sed -i 's/quote = { workspace = true/quote = { version = "1"/' serde_derive*/Cargo.toml
sed -i 's/syn = { workspace = true/syn = { version = "2"/' serde_derive*/Cargo.toml
- run: cd serde && cargo check --no-default-features
- run: cd serde && cargo check
- run: cd serde_derive && cargo check
minimal:
name: Minimal versions
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@nightly
- run: cargo generate-lockfile -Z minimal-versions
- run: cargo check --locked --workspace
doc:
name: Documentation
runs-on: ubuntu-latest
timeout-minutes: 45
env:
RUSTDOCFLAGS: -Dwarnings
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@nightly
- uses: dtolnay/install@cargo-docs-rs
- run: cargo docs-rs -p serde
- run: cargo docs-rs -p serde_core
- run: cargo docs-rs -p serde_derive
- run: cargo docs-rs -p serde_derive_internals
clippy:
name: Clippy
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
timeout-minutes: 45
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@clippy
- run: cd serde && cargo clippy --features rc,unstable -- -Dclippy::all -Dclippy::pedantic
- run: cd serde_core && cargo clippy --features rc,unstable -- -Dclippy::all -Dclippy::pedantic
- run: cd serde_derive && cargo clippy -- -Dclippy::all -Dclippy::pedantic
- run: cd serde_derive_internals && cargo clippy -- -Dclippy::all -Dclippy::pedantic
- run: cd test_suite && cargo clippy --tests --features unstable -- -Dclippy::all -Dclippy::pedantic
- run: cd test_suite/no_std && cargo clippy -- -Dclippy::all -Dclippy::pedantic
miri:
name: Miri
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@miri
- run: cargo miri setup
- run: cd serde_core && cargo miri test --features rc,unstable
env:
MIRIFLAGS: -Zmiri-strict-provenance
- run: cd test_suite && cargo miri test --features unstable
env:
MIRIFLAGS: -Zmiri-strict-provenance
outdated:
name: Outdated
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
timeout-minutes: 45
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
- uses: dtolnay/install@cargo-outdated
- run: cargo outdated --workspace --exit-code 1
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: CI on: push: pull_request: workflow_dispatch: schedule: [cron: "40 1 * * *"] permissions: contents: read env: RUSTFLAGS: -Dwarnings concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: test: name: Test suite runs-on: latchkey-small timeout-minutes: 45 steps: - uses: actions/checkout@v7 - uses: dtolnay/rust-toolchain@nightly - run: cd test_suite && cargo test --features unstable - uses: actions/upload-artifact@v7 if: always() with: name: Cargo.lock path: Cargo.lock continue-on-error: true windows: name: Test suite (windows) runs-on: windows-latest timeout-minutes: 45 steps: - uses: actions/checkout@v7 - uses: dtolnay/rust-toolchain@nightly - run: cd test_suite && cargo test --features unstable -- --skip ui --exact stable: name: Rust ${{matrix.rust}} runs-on: latchkey-small strategy: fail-fast: false matrix: rust: [stable, beta] timeout-minutes: 45 steps: - uses: actions/checkout@v7 - uses: dtolnay/rust-toolchain@master with: toolchain: ${{matrix.rust}} - run: cd serde && cargo build --features rc - run: cd serde && cargo build --no-default-features - run: cd test_suite/no_std && cargo build nightly: name: Rust nightly${{matrix.os == 'windows' && ' (windows)' || ''}} runs-on: ${{matrix.os}}-latest strategy: fail-fast: false matrix: os: [ubuntu, windows] timeout-minutes: 45 steps: - uses: actions/checkout@v7 - uses: dtolnay/rust-toolchain@nightly - run: cd serde && cargo build - run: cd serde && cargo build --no-default-features - run: cd serde && cargo build --no-default-features --features alloc - run: cd serde && cargo build --no-default-features --features rc,alloc - run: cd serde && cargo build --no-default-features --features unstable - run: cd serde_core && cargo test --features rc,unstable - run: cd test_suite/no_std && cargo build if: matrix.os != 'windows' - run: cd serde_derive && cargo check --tests env: RUSTFLAGS: --cfg exhaustive ${{env.RUSTFLAGS}} if: matrix.os != 'windows' build: name: Rust ${{matrix.rust}} runs-on: latchkey-small strategy: fail-fast: false matrix: rust: [1.56.0, 1.60.0] timeout-minutes: 45 steps: - uses: actions/checkout@v7 - uses: dtolnay/rust-toolchain@master with: toolchain: ${{matrix.rust}} - run: sed -i '/"test_suite"/d' Cargo.toml - run: cd serde && cargo build --features rc - run: cd serde && cargo build --no-default-features - run: cd serde && cargo build --no-default-features --features alloc - run: cd serde && cargo build derive: name: Rust 1.71.0 runs-on: latchkey-small timeout-minutes: 45 steps: - uses: actions/checkout@v7 - uses: dtolnay/rust-toolchain@1.71.0 - run: | sed -i 's/proc-macro2 = { workspace = true/proc-macro2 = { version = "1"/' serde_derive*/Cargo.toml sed -i 's/quote = { workspace = true/quote = { version = "1"/' serde_derive*/Cargo.toml sed -i 's/syn = { workspace = true/syn = { version = "2"/' serde_derive*/Cargo.toml - run: cd serde && cargo check --no-default-features - run: cd serde && cargo check - run: cd serde_derive && cargo check minimal: name: Minimal versions runs-on: latchkey-small timeout-minutes: 45 steps: - uses: actions/checkout@v7 - uses: dtolnay/rust-toolchain@nightly - run: cargo generate-lockfile -Z minimal-versions - run: cargo check --locked --workspace doc: name: Documentation runs-on: latchkey-small timeout-minutes: 45 env: RUSTDOCFLAGS: -Dwarnings steps: - uses: actions/checkout@v7 - uses: dtolnay/rust-toolchain@nightly - uses: dtolnay/install@cargo-docs-rs - run: cargo docs-rs -p serde - run: cargo docs-rs -p serde_core - run: cargo docs-rs -p serde_derive - run: cargo docs-rs -p serde_derive_internals clippy: name: Clippy runs-on: latchkey-small if: github.event_name != 'pull_request' timeout-minutes: 45 steps: - uses: actions/checkout@v7 - uses: dtolnay/rust-toolchain@clippy - run: cd serde && cargo clippy --features rc,unstable -- -Dclippy::all -Dclippy::pedantic - run: cd serde_core && cargo clippy --features rc,unstable -- -Dclippy::all -Dclippy::pedantic - run: cd serde_derive && cargo clippy -- -Dclippy::all -Dclippy::pedantic - run: cd serde_derive_internals && cargo clippy -- -Dclippy::all -Dclippy::pedantic - run: cd test_suite && cargo clippy --tests --features unstable -- -Dclippy::all -Dclippy::pedantic - run: cd test_suite/no_std && cargo clippy -- -Dclippy::all -Dclippy::pedantic miri: name: Miri runs-on: latchkey-small timeout-minutes: 45 steps: - uses: actions/checkout@v7 - uses: dtolnay/rust-toolchain@miri - run: cargo miri setup - run: cd serde_core && cargo miri test --features rc,unstable env: MIRIFLAGS: -Zmiri-strict-provenance - run: cd test_suite && cargo miri test --features unstable env: MIRIFLAGS: -Zmiri-strict-provenance outdated: name: Outdated runs-on: latchkey-small if: github.event_name != 'pull_request' timeout-minutes: 45 steps: - uses: actions/checkout@v7 - uses: dtolnay/rust-toolchain@stable - uses: dtolnay/install@cargo-outdated - run: cargo outdated --workspace --exit-code 1
What changed
- Run on Latchkey managed runners with one line (
runs-on), which apply the fixes below automatically and self-heal transient failures. This example useslatchkey-small; pick the runner size that fits the job. - Cancel superseded runs when a branch or PR gets a newer push.
2 third-party actions are referenced by a movable tag. Pin them to the commit SHA (Latchkey resolves and applies this automatically) so a repointed tag cannot change what runs.
What Latchkey heals here
This workflow has steps that commonly fail on transient issues (network, registries, flaky browsers). On Latchkey managed runners they are detected, retried, and self-healed instead of failing your build:
- Dependency installs
This workflow runs 11 jobs (14 with the matrix expanded) per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.