From 65327c491b53a26c2cc0b38e18f27bcae503bd57 Mon Sep 17 00:00:00 2001 From: Rigidity Date: Mon, 15 Jul 2024 17:58:10 -0400 Subject: [PATCH] Initial update --- .github/workflows/audit-check.yml | 13 --- .github/workflows/benchmark.yml | 18 --- .github/workflows/build-crate-and-npm.yml | 71 ------------ .github/workflows/build-test.yml | 72 +----------- .github/workflows/prettier.yml | 2 - .github/workflows/rust.yml | 135 ++++++++++++++++++++++ package-lock.json | 3 +- 7 files changed, 138 insertions(+), 176 deletions(-) delete mode 100644 .github/workflows/audit-check.yml delete mode 100644 .github/workflows/build-crate-and-npm.yml create mode 100644 .github/workflows/rust.yml diff --git a/.github/workflows/audit-check.yml b/.github/workflows/audit-check.yml deleted file mode 100644 index 332799198..000000000 --- a/.github/workflows/audit-check.yml +++ /dev/null @@ -1,13 +0,0 @@ -name: Security audit -on: - pull_request: - branches: - - "**" - -jobs: - security_audit: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: cargo audit - run: cargo audit --ignore RUSTSEC-2023-0071 diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index cf1ad22fd..ba129ed3d 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -116,21 +116,3 @@ jobs: cd tests ./generate-programs.py ./run-programs.py - - benchmarks: - name: rust benchmarks - runs-on: benchmark - strategy: - fail-fast: false - - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 1 - - - name: Set up rust - uses: dtolnay/rust-toolchain@stable - - - name: cargo bench - run: | - cargo bench --workspace --exclude chia_rs diff --git a/.github/workflows/build-crate-and-npm.yml b/.github/workflows/build-crate-and-npm.yml deleted file mode 100644 index 3b9d79d2f..000000000 --- a/.github/workflows/build-crate-and-npm.yml +++ /dev/null @@ -1,71 +0,0 @@ -name: Build crate and npm package - -on: - push: - branches: - - main - tags: - - "**" - pull_request: - branches: - - "**" - -jobs: - build_crate: - name: Crate & NPM - runs-on: ubuntu-latest - strategy: - fail-fast: false - - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Set up rusts - uses: dtolnay/rust-toolchain@stable - with: - components: rustfmt, clippy - - - name: fmt - run: cargo fmt -- --files-with-diff --check - - name: clippy - run: cargo clippy - - name: tests - run: cargo test && cargo test --release - - 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: wasm-pack build and pack - run: cd wasm && wasm-pack build && wasm-pack pack - - - name: Upload npm pkg artifacts - uses: actions/upload-artifact@v4 - with: - name: npm-pkg - path: ./wasm/pkg/*-*.tgz - - - name: publish to crates.io if tagged - if: startsWith(github.event.ref, 'refs/tags') - env: - CARGO_REGISTRY_TOKEN: ${{ secrets.cargo_registry_token }} - run: | - cargo install cargo-workspaces --locked - cargo ws publish --publish-as-is - - # this has not been tested, so probably needs to be debugged next time a tag is created - - 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 diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index e01868518..5a2bfd47b 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -259,75 +259,6 @@ jobs: name: packages-sdist-${{ matrix.os.name }}-${{ matrix.python.major-dot-minor }}-${{ matrix.arch.name }} path: ./target/wheels/ - fmt: - runs-on: ubuntu-latest - name: cargo fmt - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 1 - - - name: Install rust - uses: dtolnay/rust-toolchain@stable - with: - components: rustfmt, clippy - - - name: fmt - run: | - cargo fmt --all -- --files-with-diff --check - cd wheel - cargo fmt -- --files-with-diff --check - - clippy: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable - with: - components: clippy - - - name: workspace - run: | - cargo clippy --workspace --all-features --all-targets - - fuzz_targets: - runs-on: ubuntu-latest - env: - CARGO_PROFILE_RELEASE_LTO: false - steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@nightly - - name: cargo-fuzz - run: cargo +nightly install cargo-fuzz - - name: cargo 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: cargo 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: cargo 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: cargo 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: cargo 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" - unit_tests: runs-on: ${{ matrix.os }} strategy: @@ -342,8 +273,7 @@ jobs: git config --global core.autocrlf false - uses: actions/checkout@v4 - with: - fetch-depth: 1 + - uses: dtolnay/rust-toolchain@stable - name: Prepare for coverage if: matrix.os == 'ubuntu-latest' diff --git a/.github/workflows/prettier.yml b/.github/workflows/prettier.yml index 29387b657..d568759e4 100644 --- a/.github/workflows/prettier.yml +++ b/.github/workflows/prettier.yml @@ -14,8 +14,6 @@ jobs: prettier: name: Prettier runs-on: ubuntu-latest - strategy: - fail-fast: false steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml new file mode 100644 index 000000000..9a7055116 --- /dev/null +++ b/.github/workflows/rust.yml @@ -0,0 +1,135 @@ +name: Rust + +on: + push: + branches: + - main + tags: + - "**" + pull_request: + branches: + - "**" + +jobs: + build_crate: + name: Tests + runs-on: ubuntu-latest + 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/sccache-action@v0.0.5 + + - 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: Tests + run: cargo test --workspace --all-features --release + + - 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 + + benchmarks: + name: Benchmarks + runs-on: benchmark + steps: + - uses: actions/checkout@v4 + + - name: Set up Rust + uses: dtolnay/rust-toolchain@stable + + - name: Run benchmarks + run: cargo bench --workspace + + fuzz_targets: + runs-on: ubuntu-latest + env: + CARGO_PROFILE_RELEASE_LTO: false + steps: + - uses: actions/checkout@v4 + + - uses: dtolnay/rust-toolchain@nightly + + - 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" diff --git a/package-lock.json b/package-lock.json index 4490e78c7..370e32ee8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,7 +4,7 @@ "requires": true, "packages": { "": { - "dependencies": { + "devDependencies": { "prettier": "^3.3.2" } }, @@ -12,6 +12,7 @@ "version": "3.3.3", "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.3.tgz", "integrity": "sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==", + "dev": true, "license": "MIT", "bin": { "prettier": "bin/prettier.cjs"