Skip to content

Workflow update

Workflow update #12

Workflow file for this run

name: Rust
on:
push:
branches:
- main
tags:
- "**"
pull_request:
branches:
- "**"
concurrency:
# SHA is added to the end if on `main` to let all main workflows run
group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}-${{ (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/') || startsWith(github.ref, 'refs/heads/long_lived/')) && github.sha || '' }}
cancel-in-progress: true
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
env:
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
steps:
- uses: actions/checkout@v4
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Run sccache-cache
uses: mozilla-actions/[email protected]
- name: Rustfmt
run: cargo fmt --all -- --files-with-diff --check
- name: Clippy
run: cargo clippy --workspace --all-targets --all-features
- name: Audit
run: cargo audit --ignore RUSTSEC-2023-0071
- name: Install cargo-machete
run: cargo install cargo-machete --locked
- name: Unused dependencies
run: cargo machete
- name: Display sccache stats
run: sccache --show-stats
test:
name: Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
env:
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
steps:
- uses: actions/checkout@v4
# The test files are read verbatim, making it problematic if git is
# allowed to insert \r when checking out files.
- name: Disable git autocrlf
run: git config --global core.autocrlf false
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
- name: Run sccache-cache
uses: mozilla-actions/[email protected]
- name: Install cargo-tarpaulin
run: cargo install cargo-tarpaulin --locked
- name: Tests
run: cargo tarpaulin --workspace --all-features --release --out lcov
- name: Upload to Coveralls
uses: coverallsapp/github-action@v2
if: matrix.os == 'ubuntu-latest'
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
with:
path-to-lcov: "./lcov.info"
- name: Display sccache stats
run: sccache --show-stats
publish:
name: Publish
needs: [lint, test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
- name: Build
run: cargo build --release
- name: Upload crate artifacts
uses: actions/upload-artifact@v4
with:
name: crate
path: ./target/package/*-*.crate
- name: Install wasm-pack
run: cargo install wasm-pack --locked
- name: Build and pack wasm
run: |
cd wasm
wasm-pack build
wasm-pack pack
- name: Upload NPM artifacts
uses: actions/upload-artifact@v4
with:
name: npm-pkg
path: ./wasm/pkg/*-*.tgz
- name: Install cargo-workspaces
run: cargo install cargo-workspaces --locked
- name: Publish to crates.io if tagged
if: startsWith(github.event.ref, 'refs/tags')
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.cargo_registry_token }}
run: cargo ws publish --publish-as-is
- name: Publish to npmjs.com if tagged
if: startsWith(github.event.ref, 'refs/tags')
uses: JS-DevTools/npm-publish@v3
with:
token: ${{ secrets.node_auth_token }}
package: wasm/pkg/package.json
benchmark:
name: Benchmark
runs-on: benchmark
env:
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
steps:
- uses: actions/checkout@v4
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
- name: Run sccache-cache
uses: mozilla-actions/[email protected]
- name: Run benchmarks
run: cargo bench --workspace --exclude chia_rs
- name: Display sccache stats
run: sccache --show-stats
fuzz:
name: Fuzz
runs-on: ubuntu-latest
env:
CARGO_PROFILE_RELEASE_LTO: false
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- name: Run sccache-cache
uses: mozilla-actions/[email protected]
- name: Install cargo-fuzz
run: cargo +nightly install cargo-fuzz
- name: Fuzz chia-consensus
run: |
cd crates/chia-consensus
cargo fuzz list | xargs -I "%" sh -c "cargo +nightly fuzz run % -- -max_total_time=20 || exit 255"
- name: Fuzz chia-bls
env:
# We disable leak reports here because blspy appears to be allocating
# memory that's not freed. It might be a false positive since python is
# not unloaded before exiting.
LSAN_OPTIONS: detect_leaks=0
run: |
cd crates/chia-bls
python -m pip install blspy
cargo fuzz list | xargs -I "%" sh -c "cargo +nightly fuzz run % -- -max_total_time=10 || exit 255"
- name: Fuzz clvm-utils
run: |
cd crates/clvm-utils
cargo fuzz list | xargs -I "%" sh -c "cargo +nightly fuzz run % -- -max_total_time=20 || exit 255"
- name: Fuzz chia-protocol
run: |
cd crates/chia-protocol
cargo +nightly fuzz build
cargo fuzz list | xargs -I "%" sh -c "cargo +nightly fuzz run % -- -max_total_time=20 || exit 255"
- name: Fuzz chia-puzzles
run: |
cd crates/chia-puzzles
cargo +nightly fuzz build
cargo fuzz list | xargs -I "%" sh -c "cargo +nightly fuzz run % -- -max_total_time=20 || exit 255"
- name: Display sccache stats
run: sccache --show-stats