@@ -16,6 +16,7 @@ permissions: read-all
1616
1717env :
1818 CARGO_TERM_COLOR : always
19+ RUST_BACKTRACE : 1
1920 RUSTFLAGS : -Dwarnings
2021 RUSTDOCFLAGS : -Dwarnings
2122 # `ZC_NIGHTLY_XXX` are flags that we add to `XXX` only on the nightly
@@ -507,6 +508,73 @@ jobs:
507508 # `roll-pinned-toolchain-versions.yml`.
508509 kani-version : 0.55.0
509510
511+ unsafe_fields :
512+ runs-on : ubuntu-latest
513+ needs : generate_cache
514+ strategy :
515+ # By default, this is set to `true`, which means that a single CI job
516+ # failure will cause all outstanding jobs to be canceled. This slows down
517+ # development because it means that errors need to be encountered and
518+ # fixed one at a time.
519+ fail-fast : false
520+ matrix :
521+ toolchain : [
522+ " msrv" ,
523+ " stable" ,
524+ " nightly" ,
525+ ]
526+ steps :
527+ - uses : actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
528+ - name : Configure environment variables
529+ run : |
530+ set -eo pipefail
531+ ZC_TOOLCHAIN="$(./cargo.sh --version ${{ matrix.toolchain }})"
532+ echo "ZC_TOOLCHAIN=$ZC_TOOLCHAIN" >> $GITHUB_ENV
533+ - name : Install stable Rust for use in 'cargo.sh'
534+ uses : dtolnay/rust-toolchain@00b49be78f40fba4e87296b2ead62868750bdd83 # stable
535+ with :
536+ toolchain : stable
537+ - name : Install Rust with nightly toolchain (${{ env.ZC_TOOLCHAIN }}) and target aarch64_be-unknown-linux-gnu
538+ uses : dtolnay/rust-toolchain@00b49be78f40fba4e87296b2ead62868750bdd83 # stable
539+ with :
540+ toolchain : ${{ env.ZC_TOOLCHAIN }}
541+ components : clippy, rust-src
542+ - name : Check
543+ run : ./cargo.sh +${{ matrix.toolchain }} check --package unsafe-fields --verbose
544+ - name : Check tests
545+ run : ./cargo.sh +${{ matrix.toolchain }} check --tests --package unsafe-fields --verbose
546+ - name : Build
547+ run : ./cargo.sh +${{ matrix.toolchain }} build --package unsafe-fields --verbose
548+ - name : Run tests
549+ run : ./cargo.sh +${{ matrix.toolchain }} test --package unsafe-fields --verbose
550+ - name : Clippy
551+ run : ./cargo.sh +${{ matrix.toolchain }} clippy --package unsafe-fields --verbose
552+ # See comment in next step for why we only run on nightly.
553+ if : matrix.toolchain == 'nightly'
554+ - name : Clippy tests
555+ run : ./cargo.sh +${{ matrix.toolchain }} clippy --package unsafe-fields --tests --verbose
556+ # Clippy improves the accuracy of lints over time, and fixes bugs. Only
557+ # running Clippy on nightly allows us to avoid having to write code
558+ # which is compatible with older versions of Clippy, which sometimes
559+ # requires hacks to work around limitations that are fixed in more
560+ # recent versions.
561+ if : matrix.toolchain == 'nightly'
562+ - name : Cargo doc
563+ # We pass --document-private-items and --document-hidden items to ensure
564+ # that documentation always builds even for these items. This makes
565+ # future changes to make those items public/non-hidden more painless.
566+ # Note that --document-hidden-items is unstable; if a future release
567+ # breaks or removes it, we can just update CI to no longer pass that
568+ # flag.
569+ run : |
570+ # Include arguments passed during docs.rs deployments to make sure those
571+ # work properly.
572+ set -eo pipefail
573+ METADATA_DOCS_RS_RUSTDOC_ARGS="$(cargo metadata --format-version 1 | \
574+ jq -r ".packages[] | select(.name == \"unsafe-fields\").metadata.docs.rs.\"rustdoc-args\"[]" | tr '\n' ' ')"
575+ export RUSTDOCFLAGS="${{ matrix.toolchain == 'nightly' && '-Z unstable-options --document-hidden-items $METADATA_DOCS_RS_RUSTDOC_ARGS'|| '' }} $RUSTDOCFLAGS"
576+ ./cargo.sh +${{ matrix.toolchain }} doc --document-private-items --package unsafe-fields
577+
510578 # NEON intrinsics are currently broken on big-endian platforms. [1] This test ensures
511579 # that we don't accidentally attempt to compile these intrinsics on such platforms. We
512580 # can't use this as part of the build matrix because rustup doesn't support the
@@ -670,7 +738,7 @@ jobs:
670738 # https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/troubleshooting-required-status-checks#handling-skipped-but-required-checks
671739 if : failure()
672740 runs-on : ubuntu-latest
673- needs : [build_test, kani,check_be_aarch64 , check_fmt, check_readme, check_versions, generate_cache, check-all-toolchains-tested, check-job-dependencies, run-git-hooks]
741+ needs : [build_test, kani,check_be_aarch64, check_fmt, check_readme, check_versions, generate_cache, check-all-toolchains-tested, check-job-dependencies, run-git-hooks, unsafe_fields ]
674742 steps :
675743 - name : Mark the job as failed
676744 run : exit 1
0 commit comments