Update Managed Files #997
Workflow file for this run
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: Rust bindings | |
| on: | |
| push: | |
| branches: | |
| - main | |
| release: | |
| types: [published] | |
| pull_request: | |
| branches: | |
| - "**" | |
| concurrency: | |
| group: ${{ github.event_name == 'pull_request' && format('{0}-{1}', github.workflow_ref, github.event.pull_request.number) || github.run_id }} | |
| cancel-in-progress: true | |
| permissions: | |
| id-token: write | |
| contents: read | |
| jobs: | |
| fuzz_targets: | |
| name: Run fuzzers (${{ matrix.target }}) | |
| runs-on: ubuntu-latest | |
| env: | |
| CARGO_PROFILE_RELEASE_LTO: false | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| target: | |
| - create_discriminant | |
| - prove | |
| - verify | |
| - verify_n_wesolowski | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: dtolnay/rust-toolchain@nightly | |
| - name: Cache cargo registry + build artifacts | |
| uses: actions/cache@v5 | |
| with: | |
| path: | | |
| ~/.cargo/bin | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| target | |
| rust_bindings/fuzz/corpus | |
| key: ${{ runner.os }}-rust-fuzz-${{ hashFiles('Cargo.lock') }} | |
| - name: Install cargo-fuzz | |
| run: | | |
| if ! command -v cargo-fuzz >/dev/null 2>&1; then | |
| cargo +nightly install cargo-fuzz --locked | |
| fi | |
| - name: Cargo fuzz (${{ matrix.target }}) | |
| run: | | |
| cd rust_bindings | |
| cargo +nightly fuzz run ${{ matrix.target }} -- -max_total_time=600 | |
| lint: | |
| name: Lint | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Set up Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: rustfmt, clippy | |
| - name: Rustfmt | |
| run: cargo fmt -- --files-with-diff --check | |
| - name: Clippy | |
| run: cargo clippy | |
| test: | |
| name: Test (${{ matrix.os.name }} ${{ matrix.arch.name }}) | |
| runs-on: ${{ matrix.os.runs-on[matrix.arch.matrix] }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: | |
| - name: macOS | |
| matrix: macos | |
| runs-on: | |
| arm: [macos-15] | |
| intel: [macos-15-intel] | |
| cibw-archs-macos: | |
| arm: arm64 | |
| intel: x86_64 | |
| - name: Ubuntu | |
| matrix: ubuntu | |
| runs-on: | |
| arm: [Linux, ARM64] | |
| intel: [ubuntu-latest] | |
| - name: Windows | |
| matrix: windows | |
| runs-on: | |
| intel: [windows-latest] | |
| arch: | |
| - name: ARM | |
| matrix: arm | |
| - name: Intel | |
| matrix: intel | |
| exclude: | |
| - os: | |
| name: Windows | |
| matrix: windows | |
| runs-on: | |
| intel: [windows-latest] | |
| arch: | |
| name: ARM | |
| matrix: arm | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Setup library path on MacOS | |
| if: matrix.os.name == 'macOS' | |
| run: echo "LIBRARY_PATH=$(brew --prefix)/lib:$LIBRARY_PATH" >> $GITHUB_ENV | |
| - name: Install CMake on MacOS | |
| if: matrix.os.name == 'macOS' | |
| run: | | |
| brew ls --versions cmake >/dev/null 2>&1 || brew install cmake | |
| CMAKE_BIN="$(brew --prefix cmake)/bin" | |
| if [ -d "$CMAKE_BIN" ]; then | |
| echo "$CMAKE_BIN" >> "$GITHUB_PATH" | |
| export PATH="$CMAKE_BIN:$PATH" | |
| fi | |
| if ! command -v cmake >/dev/null 2>&1; then | |
| BREW_BIN="$(brew --prefix)/bin" | |
| echo "$BREW_BIN" >> "$GITHUB_PATH" | |
| export PATH="$BREW_BIN:$PATH" | |
| fi | |
| command -v cmake | |
| cmake --version | |
| - name: Install MPIR on Windows | |
| if: matrix.os.name == 'Windows' | |
| run: | | |
| git clone https://github.com/Chia-Network/mpir_gc_x64.git | |
| "$(Get-Location)/mpir_gc_x64" | Out-File -Append -FilePath $env:GITHUB_PATH | |
| - name: Install libclang-dev on Linux | |
| if: matrix.os.name == 'Ubuntu' | |
| run: | | |
| # Avoid transient 404s from stale apt indices / mirror lag. | |
| sudo apt-get update -y -o Acquire::Retries=3 | |
| sudo apt-get install libclang-dev -y | |
| - name: Set up Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Tests | |
| run: cargo test && cargo test --release | |
| build_crate: | |
| name: Build crate | |
| needs: [lint, test] | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Set up Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Build | |
| run: cargo build --release | |
| - name: Prepare for publish | |
| run: | | |
| cd rust_bindings | |
| cp -r ../src cpp | |
| git clone https://github.com/Chia-Network/mpir_gc_x64.git | |
| - name: Publish to crates.io (dry run) | |
| # We use `--allow-dirty` because the `cpp` folder is copied into the working directory. | |
| # This is necessary because the `cpp` folder is not part of the crate otherwise. | |
| run: cargo publish --dry-run -p chiavdf --allow-dirty | |
| - name: Upload crate artifacts | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: crate | |
| path: ./target/package/*-*.crate | |
| - name: Set Env | |
| uses: Chia-Network/actions/setjobenv@main | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - uses: rust-lang/crates-io-auth-action@v1 | |
| if: env.RELEASE == 'true' | |
| id: auth | |
| - name: Publish to crates.io | |
| if: env.RELEASE == 'true' | |
| env: | |
| CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }} | |
| # See comment above for why `--allow-dirty` is used. | |
| run: | | |
| cp -r src rust_bindings/cpp | |
| cargo publish -p chiavdf --allow-dirty |