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
64on : [push, pull_request]
75name : 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