name: ci
on:
pull_request:
branches: [main]
push:
branches: [main]
workflow_call:
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
defaults:
run:
shell: bash
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262
- name: Install Rust
uses: dtolnay/rust-toolchain@e2a55d2ffb04f378e9626c28d38b36d230d1e12f with:
toolchain: stable
- name: Cache cargo
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ubuntu-test-${{ hashFiles('Cargo.lock') }}
restore-keys: |
ubuntu-test-
- name: Run the tests
run: cargo test --locked
- name: Build the documentation
run: cargo doc --locked --no-deps
env:
RUSTDOCFLAGS: -Dwarnings
fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262
- name: Install Rust
uses: dtolnay/rust-toolchain@e2a55d2ffb04f378e9626c28d38b36d230d1e12f with:
toolchain: stable
components: rustfmt
- name: Check formatting
run: cargo fmt --all -- --check
clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262
- name: Install Rust
uses: dtolnay/rust-toolchain@e2a55d2ffb04f378e9626c28d38b36d230d1e12f with:
toolchain: stable
components: clippy
- name: Cache cargo
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ubuntu-clippy-${{ hashFiles('Cargo.lock') }}
restore-keys: |
ubuntu-clippy-
- name: Run Clippy
run: cargo clippy --locked --all-targets -- -D warnings
vectors:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262
- name: Install Rust
uses: dtolnay/rust-toolchain@e2a55d2ffb04f378e9626c28d38b36d230d1e12f with:
toolchain: stable
- name: Cache cargo
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ubuntu-vectors-${{ hashFiles('Cargo.lock') }}
restore-keys: |
ubuntu-vectors-
- name: The eight chain-event envelope vectors
run: |
cargo test --locked --test chain_events -- --exact \
pinned_tip_round_trip \
pinned_fork_round_trip \
pinned_reorg_round_trip \
pinned_invalidated_round_trip \
pinned_frozen_round_trip \
pinned_tip_age_round_trip \
pinned_split_round_trip \
pinned_split_resolved_round_trip | tee chain_events.out
grep -q '^test result: ok. 8 passed; 0 failed; 0 ignored' chain_events.out
- name: The ARC status vector
run: |
cargo test --locked --test verdicts -- --exact \
arc_p0_2_twenty_bodies_are_only_hints | tee verdicts.out
grep -q '^test result: ok. 1 passed; 0 failed; 0 ignored' verdicts.out
wasm32:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262
- name: Install Rust
uses: dtolnay/rust-toolchain@e2a55d2ffb04f378e9626c28d38b36d230d1e12f with:
toolchain: stable
targets: wasm32-unknown-unknown
- name: Cache cargo
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ubuntu-wasm32-${{ hashFiles('Cargo.lock') }}
restore-keys: |
ubuntu-wasm32-
- name: Build for wasm32-unknown-unknown
run: cargo build --locked --target wasm32-unknown-unknown --features wasm
msrv:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262
- name: Install Rust
uses: dtolnay/rust-toolchain@e2a55d2ffb04f378e9626c28d38b36d230d1e12f with:
toolchain: "1.88"
- name: Cache cargo
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ubuntu-msrv-${{ hashFiles('Cargo.lock') }}
restore-keys: |
ubuntu-msrv-
- name: The declared rust-version is the toolchain
run: |
declared=$(cargo metadata --locked --no-deps --format-version 1 | jq -r '.packages[0].rust_version')
if [ "$declared" != "1.88" ]; then
echo "::error::rust-version $declared differs from the msrv job's toolchain 1.88"
exit 1
fi
- name: Check at the MSRV
run: cargo check --locked --all-targets
machete:
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262
- name: Install Rust
uses: dtolnay/rust-toolchain@e2a55d2ffb04f378e9626c28d38b36d230d1e12f with:
toolchain: stable
- name: Install cargo-machete
run: cargo install cargo-machete --version 0.9.2 --locked --root "$RUNNER_TEMP/tools"
- name: Find unused dependencies
run: '"$RUNNER_TEMP/tools/bin/cargo-machete" --with-metadata'
secrets:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 with:
fetch-depth: 0
- name: Install gitleaks 8.28.0
run: |
curl -sSfL -o "$RUNNER_TEMP/gitleaks.tar.gz" \
https://github.com/gitleaks/gitleaks/archive/refs/tags/v8.28.0.tar.gz
echo "c681af8aeacacf9d14f7ad97d534cf087f6d2d6fbd50dd02020b0f929b7a1c41 $RUNNER_TEMP/gitleaks.tar.gz" | sha256sum -c -
tar -xzf "$RUNNER_TEMP/gitleaks.tar.gz" -C "$RUNNER_TEMP"
cd "$RUNNER_TEMP/gitleaks-8.28.0"
go build -o "$RUNNER_TEMP/tools/gitleaks" .
- name: Scan the history
run: '"$RUNNER_TEMP/tools/gitleaks" git --redact --no-banner --exit-code 1 .'
actionlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262
- name: Install actionlint 1.7.12
run: |
curl -sSfL -o "$RUNNER_TEMP/actionlint.tar.gz" \
https://github.com/rhysd/actionlint/archive/refs/tags/v1.7.12.tar.gz
echo "454800bd4f854592bcfe79b161f71d56e35940eb7016e48a26dd356adc9d400a $RUNNER_TEMP/actionlint.tar.gz" | sha256sum -c -
tar -xzf "$RUNNER_TEMP/actionlint.tar.gz" -C "$RUNNER_TEMP"
cd "$RUNNER_TEMP/actionlint-1.7.12"
go build -o "$RUNNER_TEMP/tools/actionlint" ./cmd/actionlint
- name: Lint the workflows
run: '"$RUNNER_TEMP/tools/actionlint" -color'