diff --git a/.codecov.yml b/.codecov.yml index ebfe44b2..37232412 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -47,28 +47,28 @@ coverage: flags: dash-num: paths: [pkgs/num/] - carryforward: false + carryforward: true dash-script: paths: [pkgs/script/] - carryforward: false + carryforward: true dash-p2p-core: paths: [pkgs/p2p_core/] - carryforward: false + carryforward: true dash-params: paths: [pkgs/params/] - carryforward: false + carryforward: true dash-pkc: paths: [pkgs/pkc/] - carryforward: false + carryforward: true dash-pow: paths: [pkgs/pow/] - carryforward: false + carryforward: true dash-primitives: paths: [pkgs/primitives/] - carryforward: false + carryforward: true dash-types: paths: [pkgs/types/, pkgs/types/marker/] - carryforward: false + carryforward: true ignore: - "**/bench/**" - "**/corpus/**" diff --git a/.github/workflows/build_cross.yml b/.github/workflows/build_cross.yml index 13a53278..da0de847 100644 --- a/.github/workflows/build_cross.yml +++ b/.github/workflows/build_cross.yml @@ -85,7 +85,7 @@ jobs: path: | ~/.cargo/registry ~/.cargo/git - key: cargo-deps-${{ hashFiles('Cargo.lock', 'docs/samples/Cargo.lock') }} + key: cargo-deps-${{ hashFiles('Cargo.lock', 'docs/samples/Cargo.lock', 'fuzz/Cargo.lock') }} restore-keys: cargo-deps- - name: Manage build artifacts diff --git a/.github/workflows/build_msrv.yml b/.github/workflows/build_msrv.yml index 69765a6e..e937cd3e 100644 --- a/.github/workflows/build_msrv.yml +++ b/.github/workflows/build_msrv.yml @@ -1,98 +1,31 @@ name: MSRV (1.89) on: - push: - branches: [develop] - pull_request: - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true + workflow_call: + inputs: + package: + description: Cargo package name (e.g. dash-num) + required: true + type: string + package_dir: + description: Package directory relative to pkgs/ (e.g. num) + required: true + type: string + fuzz_package_dir: + description: Fuzz package directory relative to fuzz/ (e.g. pow) + required: false + type: string + default: "" + secrets: + CACHIX_AUTH_TOKEN: + required: false + CODECOV_TOKEN: + required: false permissions: contents: read jobs: - lint: - name: Lint - runs-on: ubuntu-24.04 - - defaults: - run: - shell: nix develop ./contrib/nix#ci --command bash -eo pipefail {0} - - steps: - - name: Checkout - uses: actions/checkout@v6 - with: - fetch-depth: 100 - - - name: Run pull request checks - if: github.event_name == 'pull_request' - shell: bash - run: | - source .github/ci.env - commits=${{ github.event.pull_request.commits }} - if [ "${commits}" -gt "${MAX_PR_COMMITS}" ]; then - echo "::error::PR has ${commits} commits (limit: ${MAX_PR_COMMITS})" - exit 1 - fi - - - name: Install Nix - uses: DeterminateSystems/nix-installer-action@v22 - with: - extra-conf: | - extra-substituters = https://dashpay-base-sdk.cachix.org - extra-trusted-public-keys = dashpay-base-sdk.cachix.org-1:TAoDyYL2e60lUEG8n10gvIZmujM5rJAhaG613fNfOWI= - - - name: Cache Nix - uses: cachix/cachix-action@v17 - with: - name: dashpay-base-sdk - authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" - skipAddingSubstituter: true - - - name: Restore cargo registry - uses: actions/cache/restore@v5 - with: - path: | - ~/.cargo/registry - ~/.cargo/git - key: cargo-deps-${{ hashFiles('Cargo.lock', 'docs/samples/Cargo.lock') }} - restore-keys: cargo-deps- - - - name: Manage build artifacts - uses: actions/cache@v5 - with: - path: target - key: cargo-build-lint-${{ runner.os }}-${{ runner.arch }}-${{ github.sha }} - restore-keys: | - cargo-build-lint-${{ runner.os }}-${{ runner.arch }}- - - - name: Manage CodeQL packs - uses: actions/cache@v5 - with: - path: ~/.codeql - key: codeql-packs-${{ hashFiles('maint/codeql/*/codeql-pack.lock.yml') }} - - - name: Run linters - run: just lint - - - name: Lint every feature combination - run: cargo hack --workspace --exclude-features default --feature-powerset clippy --all-targets -- -D warnings - - - name: Check PR title - if: github.event_name == 'pull_request' - env: - PR_TITLE: ${{ github.event.pull_request.title }} - run: python3 maint/lint/lint_commit.py -m "${PR_TITLE}" - - - name: Check PR commit messages - if: github.event_name == 'pull_request' - run: > - python3 maint/lint/lint_commit.py - -r "${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}" - build: name: Build and test runs-on: ubuntu-24.04-arm @@ -108,6 +41,7 @@ jobs: uses: actions/checkout@v6 with: fetch-depth: 1 + submodules: ${{ inputs.fuzz_package_dir != '' }} - name: Run pull request checks if: github.event_name == 'pull_request' @@ -140,7 +74,7 @@ jobs: path: | ~/.cargo/registry ~/.cargo/git - key: cargo-deps-${{ hashFiles('Cargo.lock', 'docs/samples/Cargo.lock') }} + key: cargo-deps-${{ hashFiles('Cargo.lock', 'docs/samples/Cargo.lock', 'fuzz/Cargo.lock') }} restore-keys: cargo-deps- - name: Manage build artifacts @@ -149,9 +83,10 @@ jobs: path: | target !target/nextest - key: cargo-build-msrv-${{ runner.os }}-${{ runner.arch }}-${{ github.sha }} + fuzz/target + key: cargo-build-msrv-${{ runner.os }}-${{ runner.arch }}-${{ inputs.package }}-${{ github.sha }} restore-keys: | - cargo-build-msrv-${{ runner.os }}-${{ runner.arch }}- + cargo-build-msrv-${{ runner.os }}-${{ runner.arch }}-${{ inputs.package }}- - name: Select the MSRV toolchain run: | @@ -162,17 +97,17 @@ jobs: } >> "$GITHUB_ENV" - name: Build every feature - run: '"$CARGO" hack --workspace --exclude-features default --each-feature build' + run: '"$CARGO" hack -p ${{ inputs.package }} --exclude-features default --each-feature build' - name: Test every feature run: | - "$CARGO" hack --workspace --exclude-features default --each-feature nextest run --config-file .cargo/nextest.toml --no-tests=warn - "$CARGO" hack --workspace --exclude-features default --each-feature test --doc + "$CARGO" hack -p ${{ inputs.package }} --exclude-features default --each-feature nextest run --config-file .cargo/nextest.toml --no-tests=warn + "$CARGO" hack -p ${{ inputs.package }} --exclude-features default --each-feature test --doc - - name: Test workspace (with coverage) + - name: Test package (with coverage) run: | "$CARGO" llvm-cov clean --workspace - "$CARGO" llvm-cov --no-report nextest --config-file .cargo/nextest.toml --workspace --features full + "$CARGO" llvm-cov --no-report nextest --config-file .cargo/nextest.toml --package ${{ inputs.package }} --features full "$CARGO" llvm-cov report --lcov --output-path lcov.info - name: Upload coverage to Codecov @@ -180,7 +115,7 @@ jobs: uses: codecov/codecov-action@v5 with: files: lcov.info - flags: dash-num,dash-p2p-core,dash-params,dash-pkc,dash-pow,dash-primitives,dash-script,dash-types + flags: ${{ inputs.package }} token: ${{ secrets.CODECOV_TOKEN }} - name: Upload test results to Codecov @@ -189,7 +124,12 @@ jobs: with: files: target/nextest/default/junit.xml report_type: test_results + flags: ${{ inputs.package }} token: ${{ secrets.CODECOV_TOKEN }} + - name: Replay fuzz corpora + if: inputs.fuzz_package_dir != '' + run: PATH="$TOOLCHAIN_MSRV/bin:$PATH" just fuzz::test + - name: Sanity check benchmarks - run: '"$CARGO" hack --workspace --exclude-features default --each-feature test --benches' + run: '"$CARGO" hack -p ${{ inputs.package }} --exclude-features default --each-feature test --benches' diff --git a/.github/workflows/build_stable.yml b/.github/workflows/build_stable.yml index 2a9db311..f66715c2 100644 --- a/.github/workflows/build_stable.yml +++ b/.github/workflows/build_stable.yml @@ -1,21 +1,98 @@ name: Build on stable on: - workflow_call: - inputs: - package: - description: Cargo package name (e.g. dash-num) - required: true - type: string - package_dir: - description: Package directory relative to pkgs/ (e.g. num) - required: true - type: string + push: + branches: [develop] + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true permissions: contents: read jobs: + lint: + name: Lint + runs-on: ubuntu-24.04 + + defaults: + run: + shell: nix develop ./contrib/nix#ci --command bash -eo pipefail {0} + + steps: + - name: Checkout + uses: actions/checkout@v6 + with: + fetch-depth: 100 + + - name: Run pull request checks + if: github.event_name == 'pull_request' + shell: bash + run: | + source .github/ci.env + commits=${{ github.event.pull_request.commits }} + if [ "${commits}" -gt "${MAX_PR_COMMITS}" ]; then + echo "::error::PR has ${commits} commits (limit: ${MAX_PR_COMMITS})" + exit 1 + fi + + - name: Install Nix + uses: DeterminateSystems/nix-installer-action@v22 + with: + extra-conf: | + extra-substituters = https://dashpay-base-sdk.cachix.org + extra-trusted-public-keys = dashpay-base-sdk.cachix.org-1:TAoDyYL2e60lUEG8n10gvIZmujM5rJAhaG613fNfOWI= + + - name: Cache Nix + uses: cachix/cachix-action@v17 + with: + name: dashpay-base-sdk + authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" + skipAddingSubstituter: true + + - name: Restore cargo registry + uses: actions/cache/restore@v5 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + key: cargo-deps-${{ hashFiles('Cargo.lock', 'docs/samples/Cargo.lock', 'fuzz/Cargo.lock') }} + restore-keys: cargo-deps- + + - name: Manage build artifacts + uses: actions/cache@v5 + with: + path: target + key: cargo-build-lint-${{ runner.os }}-${{ runner.arch }}-${{ github.sha }} + restore-keys: | + cargo-build-lint-${{ runner.os }}-${{ runner.arch }}- + + - name: Manage CodeQL packs + uses: actions/cache@v5 + with: + path: ~/.codeql + key: codeql-packs-${{ hashFiles('maint/codeql/*/codeql-pack.lock.yml') }} + + - name: Run linters + run: just lint + + - name: Lint every feature combination + run: cargo hack --workspace --exclude-features default --feature-powerset clippy --all-targets -- -D warnings + + - name: Check PR title + if: github.event_name == 'pull_request' + env: + PR_TITLE: ${{ github.event.pull_request.title }} + run: python3 maint/lint/lint_commit.py -m "${PR_TITLE}" + + - name: Check PR commit messages + if: github.event_name == 'pull_request' + run: > + python3 maint/lint/lint_commit.py + -r "${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}" + stable: strategy: fail-fast: false @@ -62,23 +139,23 @@ jobs: path: | ~/.cargo/registry ~/.cargo/git - key: cargo-deps-${{ hashFiles('Cargo.lock', 'docs/samples/Cargo.lock') }} + key: cargo-deps-${{ hashFiles('Cargo.lock', 'docs/samples/Cargo.lock', 'fuzz/Cargo.lock') }} restore-keys: cargo-deps- - name: Manage build artifacts uses: actions/cache@v5 with: path: target - key: cargo-build-stable-${{ runner.os }}-${{ runner.arch }}-${{ inputs.package }}-${{ github.sha }} + key: cargo-build-stable-${{ runner.os }}-${{ runner.arch }}-${{ github.sha }} restore-keys: | - cargo-build-stable-${{ runner.os }}-${{ runner.arch }}-${{ inputs.package }}- + cargo-build-stable-${{ runner.os }}-${{ runner.arch }}- - name: Build every feature - run: cargo hack -p ${{ inputs.package }} --exclude-features default --each-feature build + run: cargo hack --workspace --exclude-features default --each-feature build env: RUSTUP_TOOLCHAIN: stable - name: Test every feature - run: cargo hack -p ${{ inputs.package }} --exclude-features default --each-feature test + run: cargo hack --workspace --exclude-features default --each-feature test env: RUSTUP_TOOLCHAIN: stable diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 362b53b6..7fa9c5e8 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -62,7 +62,7 @@ jobs: path: | ~/.cargo/registry ~/.cargo/git - key: cargo-deps-${{ hashFiles('Cargo.lock', 'docs/samples/Cargo.lock') }} + key: cargo-deps-${{ hashFiles('Cargo.lock', 'docs/samples/Cargo.lock', 'fuzz/Cargo.lock') }} restore-keys: cargo-deps- - name: Build documentation diff --git a/.github/workflows/pkg_num.yml b/.github/workflows/pkg_num.yml index ebe7f94c..d118f02c 100644 --- a/.github/workflows/pkg_num.yml +++ b/.github/workflows/pkg_num.yml @@ -4,12 +4,13 @@ on: workflow_dispatch: push: paths: &paths - - pkgs/num/** + - .cargo/nextest.toml + - .github/workflows/build_msrv.yml + - .github/workflows/pkg_num.yml - Cargo.lock - Cargo.toml - - .github/workflows/pkg_num.yml - - .github/workflows/build_stable.yml - contrib/nix/** + - pkgs/num/** - pyproject.toml - rust-toolchain.toml - uv.lock @@ -21,8 +22,9 @@ concurrency: cancel-in-progress: true jobs: - stable: - uses: ./.github/workflows/build_stable.yml + msrv: + uses: ./.github/workflows/build_msrv.yml with: package: dash-num package_dir: num + secrets: inherit diff --git a/.github/workflows/pkg_p2p_core.yml b/.github/workflows/pkg_p2p_core.yml index 135b7f2b..3ca50cc9 100644 --- a/.github/workflows/pkg_p2p_core.yml +++ b/.github/workflows/pkg_p2p_core.yml @@ -4,17 +4,18 @@ on: workflow_dispatch: push: paths: &paths - - pkgs/p2p_core/** + - .cargo/nextest.toml + - .github/workflows/build_msrv.yml + - .github/workflows/pkg_p2p_core.yml + - Cargo.lock + - Cargo.toml + - contrib/nix/** - pkgs/num/** + - pkgs/p2p_core/** - pkgs/params/** - pkgs/primitives/** - pkgs/script/** - pkgs/types/** - - Cargo.lock - - Cargo.toml - - .github/workflows/pkg_p2p_core.yml - - .github/workflows/build_stable.yml - - contrib/nix/** - pyproject.toml - rust-toolchain.toml - uv.lock @@ -26,8 +27,9 @@ concurrency: cancel-in-progress: true jobs: - stable: - uses: ./.github/workflows/build_stable.yml + msrv: + uses: ./.github/workflows/build_msrv.yml with: package: dash-p2p-core package_dir: p2p_core + secrets: inherit diff --git a/.github/workflows/pkg_params.yml b/.github/workflows/pkg_params.yml index 8cf2c7bd..feb16b71 100644 --- a/.github/workflows/pkg_params.yml +++ b/.github/workflows/pkg_params.yml @@ -4,15 +4,16 @@ on: workflow_dispatch: push: paths: &paths - - pkgs/params/** - - pkgs/num/** - - pkgs/primitives/** - - pkgs/script/** + - .cargo/nextest.toml + - .github/workflows/build_msrv.yml + - .github/workflows/pkg_params.yml - Cargo.lock - Cargo.toml - - .github/workflows/pkg_params.yml - - .github/workflows/build_stable.yml - contrib/nix/** + - pkgs/num/** + - pkgs/params/** + - pkgs/primitives/** + - pkgs/script/** - pyproject.toml - rust-toolchain.toml - uv.lock @@ -24,8 +25,9 @@ concurrency: cancel-in-progress: true jobs: - stable: - uses: ./.github/workflows/build_stable.yml + msrv: + uses: ./.github/workflows/build_msrv.yml with: package: dash-params package_dir: params + secrets: inherit diff --git a/.github/workflows/pkg_pkc.yml b/.github/workflows/pkg_pkc.yml index 36da34f9..25b1a590 100644 --- a/.github/workflows/pkg_pkc.yml +++ b/.github/workflows/pkg_pkc.yml @@ -4,14 +4,15 @@ on: workflow_dispatch: push: paths: &paths - - pkgs/pkc/** - - pkgs/num/** - - pkgs/types/** + - .cargo/nextest.toml + - .github/workflows/build_msrv.yml + - .github/workflows/pkg_pkc.yml - Cargo.lock - Cargo.toml - - .github/workflows/pkg_pkc.yml - - .github/workflows/build_stable.yml - contrib/nix/** + - pkgs/num/** + - pkgs/pkc/** + - pkgs/types/** - pyproject.toml - rust-toolchain.toml - uv.lock @@ -23,8 +24,9 @@ concurrency: cancel-in-progress: true jobs: - stable: - uses: ./.github/workflows/build_stable.yml + msrv: + uses: ./.github/workflows/build_msrv.yml with: package: dash-pkc package_dir: pkc + secrets: inherit diff --git a/.github/workflows/pkg_pow.yml b/.github/workflows/pkg_pow.yml index f604bc88..bb4cf593 100644 --- a/.github/workflows/pkg_pow.yml +++ b/.github/workflows/pkg_pow.yml @@ -4,17 +4,21 @@ on: workflow_dispatch: push: paths: &paths - - pkgs/pow/** - - pkgs/num/** - - fuzz/** - - Cargo.lock - - Cargo.toml - .cargo/config.toml - - .gitmodules - - Justfile + - .cargo/nextest.toml + - .github/workflows/build_msrv.yml - .github/workflows/pkg_pow.yml - - .github/workflows/build_stable.yml + - .gitmodules + - Cargo.lock + - Cargo.toml - contrib/nix/** + - fuzz/Cargo.lock + - fuzz/Cargo.toml + - fuzz/mod.just + - fuzz/pow/** + - Justfile + - pkgs/num/** + - pkgs/pow/** - pyproject.toml - rust-toolchain.toml - uv.lock @@ -26,57 +30,10 @@ concurrency: cancel-in-progress: true jobs: - stable: - uses: ./.github/workflows/build_stable.yml + msrv: + uses: ./.github/workflows/build_msrv.yml with: package: dash-pow package_dir: pow - - fuzz: - strategy: - fail-fast: false - matrix: - os: [ubuntu-24.04, ubuntu-24.04-arm] - - name: ${{ matrix.os }} (fuzz corpora) - runs-on: ${{ matrix.os }} - permissions: - contents: read - - steps: - - name: Checkout - uses: actions/checkout@v6 - with: - fetch-depth: 1 - persist-credentials: false - submodules: true - - - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@stable - - - name: Install just - uses: taiki-e/install-action@v2 - with: - tool: just - - - name: Manage cargo registry - uses: actions/cache@v5 - with: - path: | - ~/.cargo/registry - ~/.cargo/git - key: cargo-deps-fuzz-${{ hashFiles('fuzz/Cargo.lock') }} - restore-keys: cargo-deps-fuzz- - - - name: Manage build artifacts - uses: actions/cache@v5 - with: - path: fuzz/target - key: cargo-build-fuzz-${{ runner.os }}-${{ runner.arch }}-${{ github.sha }} - restore-keys: | - cargo-build-fuzz-${{ runner.os }}-${{ runner.arch }}- - - - name: Replay fuzz corpora - run: just fuzz::test - env: - RUSTUP_TOOLCHAIN: stable + fuzz_package_dir: pow + secrets: inherit diff --git a/.github/workflows/pkg_primitives.yml b/.github/workflows/pkg_primitives.yml index cd6e44f4..474b9956 100644 --- a/.github/workflows/pkg_primitives.yml +++ b/.github/workflows/pkg_primitives.yml @@ -4,15 +4,16 @@ on: workflow_dispatch: push: paths: &paths - - pkgs/primitives/** - - pkgs/num/** - - pkgs/script/** - - pkgs/types/** + - .cargo/nextest.toml + - .github/workflows/build_msrv.yml + - .github/workflows/pkg_primitives.yml - Cargo.lock - Cargo.toml - - .github/workflows/pkg_primitives.yml - - .github/workflows/build_stable.yml - contrib/nix/** + - pkgs/num/** + - pkgs/primitives/** + - pkgs/script/** + - pkgs/types/** - pyproject.toml - rust-toolchain.toml - uv.lock @@ -24,8 +25,9 @@ concurrency: cancel-in-progress: true jobs: - stable: - uses: ./.github/workflows/build_stable.yml + msrv: + uses: ./.github/workflows/build_msrv.yml with: package: dash-primitives package_dir: primitives + secrets: inherit diff --git a/.github/workflows/pkg_script.yml b/.github/workflows/pkg_script.yml index 4a9fa584..94d05f11 100644 --- a/.github/workflows/pkg_script.yml +++ b/.github/workflows/pkg_script.yml @@ -4,13 +4,14 @@ on: workflow_dispatch: push: paths: &paths - - pkgs/script/** - - pkgs/types/** + - .cargo/nextest.toml + - .github/workflows/build_msrv.yml + - .github/workflows/pkg_script.yml - Cargo.lock - Cargo.toml - - .github/workflows/pkg_script.yml - - .github/workflows/build_stable.yml - contrib/nix/** + - pkgs/script/** + - pkgs/types/** - pyproject.toml - rust-toolchain.toml - uv.lock @@ -22,8 +23,9 @@ concurrency: cancel-in-progress: true jobs: - stable: - uses: ./.github/workflows/build_stable.yml + msrv: + uses: ./.github/workflows/build_msrv.yml with: package: dash-script package_dir: script + secrets: inherit diff --git a/.github/workflows/pkg_types.yml b/.github/workflows/pkg_types.yml index 7542a996..91837d5e 100644 --- a/.github/workflows/pkg_types.yml +++ b/.github/workflows/pkg_types.yml @@ -4,12 +4,13 @@ on: workflow_dispatch: push: paths: &paths - - pkgs/types/** + - .cargo/nextest.toml + - .github/workflows/build_msrv.yml + - .github/workflows/pkg_types.yml - Cargo.lock - Cargo.toml - - .github/workflows/pkg_types.yml - - .github/workflows/build_stable.yml - contrib/nix/** + - pkgs/types/** - pyproject.toml - rust-toolchain.toml - uv.lock @@ -21,8 +22,9 @@ concurrency: cancel-in-progress: true jobs: - stable: - uses: ./.github/workflows/build_stable.yml + msrv: + uses: ./.github/workflows/build_msrv.yml with: package: dash-types package_dir: types + secrets: inherit