CI #2729
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
merge_group: | |
pull_request: | |
# smoelius: Every Thursday at 3:00 UTC (Wednesday at 22:00 EST), run `cargo test -- --ignored`. | |
schedule: | |
- cron: "0 3 * * 4" | |
workflow_dispatch: | |
concurrency: | |
group: ci-${{ github.ref }} | |
cancel-in-progress: true | |
env: | |
CARGO_TERM_COLOR: always | |
GROUP_RUNNER: target.'cfg(all())'.runner='group-runner' | |
jobs: | |
check-up-to-dateness: | |
outputs: | |
is-up-to-date: ${{ steps.main.outputs.is-up-to-date }} | |
runs-on: ubuntu-latest | |
steps: | |
- id: main | |
uses: trailofbits/check-up-to-dateness@v1 | |
test: | |
needs: [check-up-to-dateness] | |
if: needs.check-up-to-dateness.outputs.is-up-to-date != 'true' | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
package: [third-party, other] | |
serde_format: [bincode, postcard] | |
toolchain: [stable, nightly] | |
sha1_filenames: [false, true] | |
steps: | |
- uses: actions/checkout@v5 | |
- name: Dylint versions | |
run: cargo search dylint | grep '^dylint' | sort | tee dylint_versions.txt | |
# smoelius: The `~/.cargo/` entries are from: | |
# * https://github.com/actions/cache/blob/main/examples.md#rust---cargo. | |
# * https://doc.rust-lang.org/cargo/guide/cargo-home.html#caching-the-cargo-home-in-ci | |
# The rest were added by me. | |
- uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
~/.dylint_drivers/ | |
~/.local/share/afl.rs/ | |
~/.rustup/toolchains/ | |
target/dylint/ | |
key: ${{ matrix.toolchain }}-dylint-${{ hashFiles('dylint_versions.txt') }} | |
# smoelius: The Substrate tests require the `rust-src` component and the wasm32 target. | |
- name: Set toolchain | |
run: | | |
rustup default ${{ matrix.toolchain }} | |
rustup component add rust-src | |
rustup target add wasm32-unknown-unknown | |
# smoelius: The Substrate tests require `protoc`. | |
- name: Install protoc | |
run: sudo apt-get install protobuf-compiler | |
# smoelius: Some of the `install` tests run older versions of cargo-afl that still use the | |
# gold linker. However, the gold linker does not work with the nightly toolchain. See: | |
# https://github.com/rust-fuzz/afl.rs/pull/597 | |
- name: Remove gold linker | |
run: | | |
sudo rm -f /usr/bin/ld.gold | |
sudo ln -s /usr/bin/ld /usr/bin/ld.gold | |
- name: Install cargo-afl | |
run: cargo install cargo-afl || true | |
- name: Run afl-system-config | |
run: cargo afl system-config | |
- uses: taiki-e/install-action@v2 | |
with: | |
tool: cargo-sort, cargo-udeps | |
# smoelius: I expect this list to grow. | |
- name: Install tools | |
run: | | |
rustup +nightly component add clippy rustfmt | |
cargo install cargo-dylint dylint-link || true | |
cargo install cargo-license || true | |
cargo install cargo-supply-chain || true | |
cargo install cargo-unmaintained || true | |
cargo install group-runner || true | |
go install github.com/rhysd/actionlint/cmd/actionlint@latest | |
npm install -g prettier | |
- name: Free up space | |
run: | | |
# https://github.com/actions/runner-images/issues/2606#issuecomment-772683150 | |
sudo rm -rf /usr/local/lib/android | |
sudo rm -rf /usr/share/dotnet | |
sudo rm -rf /usr/share/swift | |
# du -sh /usr/*/* 2>/dev/null | sort -h || true | |
- name: Setup | |
run: | | |
if [[ ${{ matrix.package }} = 'third-party' ]]; then | |
MAYBE_THIRD_PARTY='--package third-party' | |
if [[ ${{ github.event_name }} = 'schedule' ]] || | |
git diff --name-only ${{ github.event.pull_request.base.sha }} | grep -w 'patches\|third_party' >/dev/null | |
then | |
MAYBE_THIRD_PARTY="$MAYBE_THIRD_PARTY --features=test-third-party-full" | |
fi | |
else | |
MAYBE_THIRD_PARTY='--workspace --exclude third-party --features=test-install' | |
fi | |
SERDE_FORMAT='test-fuzz/serde_${{ matrix.serde_format }}' | |
MAYBE_SHUFFLE= | |
if [[ ${{ matrix.toolchain }} = nightly ]]; then | |
MAYBE_SHUFFLE='-Z unstable-options --shuffle --test-threads=1' | |
fi | |
BUILD_CMD="cargo build $MAYBE_THIRD_PARTY --features $SERDE_FORMAT --all-targets" | |
TEST_CMD="cargo test $MAYBE_THIRD_PARTY --features $SERDE_FORMAT --config $GROUP_RUNNER -- --nocapture $MAYBE_SHUFFLE" | |
echo "BUILD_CMD=$BUILD_CMD" >> "$GITHUB_ENV" | |
echo "TEST_CMD=$TEST_CMD" >> "$GITHUB_ENV" | |
if ${{ matrix.sha1_filenames }}; then | |
echo 'AFL_SHA1_FILENAMES=1' >> "$GITHUB_ENV" | |
fi | |
- name: Build | |
run: $BUILD_CMD | |
- name: Test | |
run: | | |
$TEST_CMD | |
env: | |
AFL_NO_AFFINITY: 1 | |
RUST_BACKTRACE: 1 | |
RUST_LOG: warn | |
- name: Check for non-SHA1 filenames | |
if: ${{ matrix.sha1_filenames }} | |
run: | | |
if find target -name 'id:*' | grep .; then | |
exit 1 | |
fi | |
all-checks: | |
needs: | |
- test | |
runs-on: ubuntu-latest | |
# smoelius: From "Defining prerequisite jobs" | |
# (https://docs.github.com/en/actions/using-jobs/using-jobs-in-a-workflow#defining-prerequisite-jobs): | |
# > If you would like a job to run even if a job it is dependent on did not succeed, use the | |
# > `always()` conditional expression in `jobs.<job_id>.if`. | |
if: ${{ always() }} | |
steps: | |
- name: Check results | |
if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }} | |
run: exit 1 |