From 521d17786180a30f47d390ea6a7ca60712f8242f Mon Sep 17 00:00:00 2001 From: Predrag Gruevski Date: Sat, 22 Feb 2025 18:08:40 +0000 Subject: [PATCH 1/7] Require test crates to pass `cargo check`. --- .github/workflows/ci.yml | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 58838964..7d293901 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,6 +28,7 @@ jobs: needs: - lint - rust-tests + - cargo-check-test-crates - cross-version-caching - cross-feature-caching - run-on-rust-libp2p @@ -161,6 +162,34 @@ jobs: RUSTDOCFLAGS: -D warnings run: cargo doc --manifest-path semver/Cargo.toml --workspace --no-deps --document-private-items + cargo-check-test-crates: + name: Ensure test crates pass "cargo check" + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + persist-credentials: false + + - name: Install rust + id: toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + toolchain: stable + rustflags: "" + cache: false + + - uses: Swatinem/rust-cache@v2 + with: + workspaces: 'semver' + + - name: '"cargo check" each test crate' + env: + # Don't complain about dead code or unused items. + RUSTFLAGS: -A dead_code -A unused + run: | + find test_crates/ -name 'Cargo.toml' | xargs -n 1 cargo check --manifest-path + rust-tests: name: Run tests runs-on: ubuntu-latest @@ -205,7 +234,7 @@ jobs: run: | cd semver ./scripts/regenerate_test_rustdocs.sh +${{ matrix.toolchain }} - + - name: Fake rustdoc mtime on cache hit if: steps.cache-test-rustdocs.outputs.cache-hit == 'true' run: | From 59c60851f48028eb90c8010657bf30bd858fe979 Mon Sep 17 00:00:00 2001 From: Predrag Gruevski Date: Sat, 22 Feb 2025 18:12:05 +0000 Subject: [PATCH 2/7] Use null-delimited data between `find` and `xargs` for robustness. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7d293901..216fc618 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -188,7 +188,7 @@ jobs: # Don't complain about dead code or unused items. RUSTFLAGS: -A dead_code -A unused run: | - find test_crates/ -name 'Cargo.toml' | xargs -n 1 cargo check --manifest-path + find test_crates/ -name 'Cargo.toml' -print0 | xargs --null -n 1 cargo check --manifest-path rust-tests: name: Run tests From 0736151fd121a37177c6582a053b11f0b296325c Mon Sep 17 00:00:00 2001 From: Predrag Gruevski Date: Sat, 22 Feb 2025 18:20:49 +0000 Subject: [PATCH 3/7] Suppress lints that are expected or are not currently actionable. --- .github/workflows/ci.yml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 216fc618..31ef92de 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -175,7 +175,7 @@ jobs: id: toolchain uses: actions-rust-lang/setup-rust-toolchain@v1 with: - toolchain: stable + toolchain: nightly # Because we sometimes test unstable features. rustflags: "" cache: false @@ -185,8 +185,16 @@ jobs: - name: '"cargo check" each test crate' env: - # Don't complain about dead code or unused items. - RUSTFLAGS: -A dead_code -A unused + # Don't complain about dead code, deprecated items, or unused items. + # Those are common in almost every test crate. + # + # Also don't complain about test crates that rely on: + # - non-pub trait bounds (`private_bounds`) + # - `repr(C, i16)` and similar code (`conflicting_repr_hints`) + # + # TODO: Clean up warnings around `non_snake_case` and `non_upper_case_globals`. + # In the meantime, we suppress them as well since they clog the logs. + RUSTFLAGS: -A dead_code -A deprecated -A unused -A private_bounds -A conflicting_repr_hints -A non_snake_case -A non_upper_case_globals run: | find test_crates/ -name 'Cargo.toml' -print0 | xargs --null -n 1 cargo check --manifest-path From d6f211b3a62d1e9951d75948ee1d7be9c8f29aa9 Mon Sep 17 00:00:00 2001 From: Predrag Gruevski Date: Sat, 22 Feb 2025 18:31:39 +0000 Subject: [PATCH 4/7] Exclude test crates that intentionally do not pass `cargo check`. --- .github/workflows/ci.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 31ef92de..25d0b75f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -195,8 +195,15 @@ jobs: # TODO: Clean up warnings around `non_snake_case` and `non_upper_case_globals`. # In the meantime, we suppress them as well since they clog the logs. RUSTFLAGS: -A dead_code -A deprecated -A unused -A private_bounds -A conflicting_repr_hints -A non_snake_case -A non_upper_case_globals + # Exclude test crates that intentionally do not pass `cargo check` + # in order to serve their test purpose. run: | - find test_crates/ -name 'Cargo.toml' -print0 | xargs --null -n 1 cargo check --manifest-path + find test_crates/ \ + -path 'test_crates/manifest_tests/workspace_baseline_compile_error/*' -prune -o \ + -path 'test_crates/manifest_tests/workspace_baseline_conditional_compile_error/*' -prune -o \ + -path 'test_crates/feature_flags_validation/*' -prune -o \ + -type f -name 'Cargo.toml' -print | \ + xargs -n 1 --exec cargo check --manifest-path {} rust-tests: name: Run tests From 187cee524145f716bc4c3c02c933802a796501ed Mon Sep 17 00:00:00 2001 From: Predrag Gruevski Date: Sat, 22 Feb 2025 19:00:29 +0000 Subject: [PATCH 5/7] Use `-print0` in `find` again. --- .github/workflows/ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 25d0b75f..c0735211 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -202,8 +202,9 @@ jobs: -path 'test_crates/manifest_tests/workspace_baseline_compile_error/*' -prune -o \ -path 'test_crates/manifest_tests/workspace_baseline_conditional_compile_error/*' -prune -o \ -path 'test_crates/feature_flags_validation/*' -prune -o \ - -type f -name 'Cargo.toml' -print | \ - xargs -n 1 --exec cargo check --manifest-path {} + -type f -name 'Cargo.toml' \ + -print0 | \ + xargs -0 -n 1 --exec cargo check --manifest-path {} rust-tests: name: Run tests From 6a5a1ed86b32bcba38443761f316897c56e6a030 Mon Sep 17 00:00:00 2001 From: Predrag Gruevski Date: Sat, 22 Feb 2025 19:01:36 +0000 Subject: [PATCH 6/7] Remove `--exec` since we don't need it anymore. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c0735211..7a7e468f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -204,7 +204,7 @@ jobs: -path 'test_crates/feature_flags_validation/*' -prune -o \ -type f -name 'Cargo.toml' \ -print0 | \ - xargs -0 -n 1 --exec cargo check --manifest-path {} + xargs -0 -n 1 cargo check --manifest-path rust-tests: name: Run tests From 38bcc08c3cc68620a56904684ec5c4f0ead81ac8 Mon Sep 17 00:00:00 2001 From: Predrag Gruevski Date: Sat, 22 Feb 2025 19:15:57 +0000 Subject: [PATCH 7/7] Allow one more crate with expected breakage. --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7a7e468f..a19e650f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -202,6 +202,7 @@ jobs: -path 'test_crates/manifest_tests/workspace_baseline_compile_error/*' -prune -o \ -path 'test_crates/manifest_tests/workspace_baseline_conditional_compile_error/*' -prune -o \ -path 'test_crates/feature_flags_validation/*' -prune -o \ + -path 'test_crates/broken_rustdoc/*' -prune -o \ -type f -name 'Cargo.toml' \ -print0 | \ xargs -0 -n 1 cargo check --manifest-path