Skip to content

Commit 81e3e03

Browse files
committed
ci: Upgrade workflows for 2025
Based off ones in the slog-rs/slog main repo.
1 parent 5a7e66c commit 81e3e03

File tree

3 files changed

+81
-36
lines changed

3 files changed

+81
-36
lines changed

.github/workflows/clippy.yml

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
# This is the clippy workflow, seperate from the main 'Rust' workflow
2-
#
3-
# This will fail if clippy fails (if we encounter any of its "correctness" lints)
4-
#
5-
# Clippy warnings won't fail the build. They may or may not turn into Github warnings.
61
on: [push, pull_request]
72
name: Clippy
83

@@ -18,19 +13,31 @@ jobs:
1813
clippy:
1914
# Only run on PRs if the source branch is on someone else's repo
2015
if: ${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }}
16+
2117
runs-on: ubuntu-latest
2218
strategy:
19+
fail-fast: false
2320
matrix:
2421
rust:
22+
# in hardcoded versions, warnings will fail the build
23+
- 1.90
24+
# in auto-updated versions, warnings will not fail the build
2525
- stable
26+
- nightly
27+
2628
steps:
27-
- uses: actions/checkout@v2
28-
- uses: actions-rs/toolchain@v1
29+
- uses: actions/checkout@v4
30+
- uses: dtolnay/rust-toolchain@master
2931
with:
30-
profile: minimal
3132
toolchain: ${{ matrix.rust }}
32-
override: true
33-
components: clippy
34-
- shell: bash
33+
components: clippy
34+
- uses: Swatinem/rust-cache@v2
35+
if: ${{ matrix.rust != 'nightly' }}
36+
- name: Clippy
3537
run: |
36-
cargo clippy
38+
cargo clippy --all --all-targets --verbose --all-features -- -D warnings
39+
# When using hardcoded/pinned versions, warnings are forbidden.
40+
#
41+
# On automatically updated versions of rust (both stable & nightly) we allow clippy to fail.
42+
# This is because automatic updates can introduce new lints or change existing lints.
43+
continue-on-error: ${{ !contains(matrix.rust, '1.') }}

.github/workflows/rustfmt.yml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,10 @@ jobs:
1414
# Only run on PRs if the source branch is on someone else's repo
1515
if: ${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }}
1616
runs-on: ubuntu-latest
17-
strategy:
18-
matrix:
19-
rust:
20-
- stable
2117
steps:
22-
- uses: actions/checkout@v2
23-
- uses: actions-rs/toolchain@v1
18+
- uses: actions/checkout@v4
19+
- uses: dtolnay/rust-toolchain@stable
2420
with:
25-
profile: minimal
26-
toolchain: ${{ matrix.rust }}
27-
override: true
2821
components: rustfmt
2922
- shell: bash
3023
run: |

.github/workflows/test.yml

Lines changed: 60 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# We use `actions-rs` for most of our actions
22
#
3-
# This file is for the main tests. clippy & rustfmt are seperate workflows
4-
#
5-
# It is mostly copied from slog-rs/slog
3+
# This file is for the main tests. clippy & rustfmt are separate workflows
64
on: [push, pull_request]
75
name: Cargo Test
86

@@ -28,24 +26,71 @@ jobs:
2826
strategy:
2927
fail-fast: false # Even if one job fails we still want to see the other ones
3028
matrix:
31-
# 1.53 is MSRV. Keep in sync with Cargo.toml
32-
rust: [1.53, stable, nightly]
33-
# NOTE: Features to test must be specified manually. They are applied to all versions seperately.
29+
rust:
30+
# Minimum Supported Rust Version
31+
#
32+
# This is hardcoded and needs to be in sync with Cargo.toml and the README
33+
- 1.53
34+
35+
# Intermediate Releases (between MSRV and latest stable)
36+
# Be careful not to add these needlessly; they hold up CI
37+
# <nothing currently>
38+
39+
# The most recent version of stable rust (automatically updated)
40+
- stable
41+
- nightly
42+
# NOTE: Features to test must be specified manually. They are applied to all versions separately.
3443
#
35-
# This has the advantage of being more flexibile and thorough
36-
# This has the disadvantage of being more vebrose
44+
# This has the advantage of being more flexible and thorough
45+
# This has the disadvantage of being more verbose
3746
#
38-
# Specific feature combos can be overriden per-version with 'include' and 'exclude'
39-
features: ["", "nested-values", "dynamic-keys", "nested-values dynamic-keys"]
47+
# Specific feature combos can be overridden per-version with 'include' and 'ecclude'
48+
features:
49+
- ""
50+
- "nested-values"
51+
- "dynamic-keys"
52+
- "nested-values dynamic-keys"
4053

4154
steps:
42-
- uses: actions/checkout@v2
43-
- uses: actions-rs/toolchain@v1
55+
- uses: actions/checkout@v4
56+
- uses: dtolnay/rust-toolchain@master
4457
with:
4558
toolchain: ${{ matrix.rust }}
46-
override: true
47-
# NOTE: We only run `cargo test`. No need for a seperate `cargo check`
59+
- uses: Swatinem/rust-cache@v2
60+
if: ${{ matrix.rust != 'nightly' }} # ineffective due to version key
61+
- name: Check
62+
run: |
63+
cargo check --all-targets --verbose --no-default-features --features "${{ matrix.features }}"
64+
# A failing `cargo check` always fails the build
65+
continue-on-error: false
4866
- name: Test
67+
# NOTE: Running --all-targets does not include doc tests
4968
run: |
50-
cargo test --verbose --features "${{ matrix.features }}"
69+
cargo test --all --verbose --no-default-features --features "${{ matrix.features }}"
5170
71+
# We require tests to succeed on all the feature combinations.
72+
#
73+
# However, we can grant special exceptions for the Minimum Supported Rust Version
74+
# if there is a really good reason (like a dependency that requires a newer version).
75+
continue-on-error: false
76+
- name: rustdoc
77+
# Restrict to working on nightly/stable (old versions might have undefined types)
78+
if: ${{ matrix.rust == 'nightly' || matrix.rust == 'stable' }}
79+
env:
80+
RUSTDOCFLAGS: -Dwarnings
81+
run: |
82+
cargo doc --no-deps --all --verbose --no-default-features --features "${{ matrix.features }}"
83+
# Runs the same build that docs.rs does. See https://github.com/dtolnay/cargo-docs-rs
84+
docsrs:
85+
# Only run on PRs if the source branch is on someone else's repo
86+
if: ${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }}
87+
88+
name: docs.rs
89+
runs-on: ubuntu-latest
90+
env:
91+
RUSTDOCFLAGS: -Dwarnings
92+
steps:
93+
- uses: actions/checkout@v5
94+
- uses: dtolnay/rust-toolchain@nightly
95+
- uses: dtolnay/install@cargo-docs-rs
96+
- run: cargo docs-rs

0 commit comments

Comments
 (0)