diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 0066ee012d9..6b740bde336 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -33,6 +33,7 @@ env: CACHE_TIMEOUT_MINUTES: 5 AWS_ACCESS_KEY_ID: "${{ secrets.AWS_ACCESS_KEY_ID }}" AWS_SECRET_ACCESS_KEY: "${{ secrets.AWS_SECRET_ACCESS_KEY }}" + RUSTC_WRAPPER: "sccache" CC: clang CXX: clang++ # To minimize compile times: https://nnethercote.github.io/perf-book/build-configuration.html#minimizing-compile-times @@ -41,17 +42,34 @@ env: FIL_PROOFS_PARAMETER_CACHE: /var/tmp/filecoin-proof-parameters RUST_LOG: error FOREST_ACTOR_BUNDLE_PATH: /var/tmp/forest_actor_bundle.car.zst + # https://github.com/BurntSushi/quickcheck/blob/692527d1d9fc9043a70b7d2bf436902e2d0f595b/src/tester.rs#L20 + QUICKCHECK_GENERATOR_SIZE: 20 + QUICKCHECK_TESTS: 20 + QUICKCHECK_MAX_TESTS: 1000 jobs: codecov: name: Coverage - if: github.event.pull_request.draft == false && github.actor != 'dependabot[bot]' + if: github.event.pull_request.draft == false runs-on: warp-ubuntu-2404-arm64-8x timeout-minutes: 30 steps: + - name: Configure SCCache variables + run: | + # External PRs do not have access to 'vars' or 'secrets'. + if [[ "${{secrets.AWS_ACCESS_KEY_ID}}" != "" ]]; then + echo "SCCACHE_ENDPOINT=${{ vars.SCCACHE_ENDPOINT}}" >> $GITHUB_ENV + echo "SCCACHE_BUCKET=${{ vars.SCCACHE_BUCKET}}" >> $GITHUB_ENV + echo "SCCACHE_REGION=${{ vars.SCCACHE_REGION}}" >> $GITHUB_ENV + fi + - name: Setup sccache + uses: mozilla-actions/sccache-action@v0.0.9 + timeout-minutes: ${{ fromJSON(env.CACHE_TIMEOUT_MINUTES) }} + continue-on-error: true - uses: actions/checkout@v6 - uses: jdx/mise-action@v4 - uses: taiki-e/install-action@cargo-llvm-cov + - uses: taiki-e/install-action@nextest - uses: actions/cache@v5 id: cache-proof-params with: @@ -65,10 +83,20 @@ jobs: - name: Fetch proof params and RPC test snapshots run: | # Use the same profile to re-use some compilation artifacts and speed up the entire job. - cargo llvm-cov run --no-report --bin forest-dev --no-default-features -- fetch-test-snapshots --actor-bundle $FOREST_ACTOR_BUNDLE_PATH + cargo llvm-cov run --profile codecov --no-report --bin forest-dev --no-default-features -- fetch-test-snapshots --actor-bundle $FOREST_ACTOR_BUNDLE_PATH ls -ahl $FIL_PROOFS_PARAMETER_CACHE - name: Generate code coverage run: mise codecov + env: + FOREST_TEST_SKIP_PROOF_PARAM_CHECK: 1 + - name: Upload Test Results to CodeCov + uses: codecov/codecov-action@v6 + if: ${{ !cancelled() }} + with: + token: ${{ secrets.CODECOV_TOKEN }} + report_type: "test_results" + files: target/nextest/default/junit.xml + fail_ci_if_error: false # Save lcov.info as an artifact for debugging purposes - uses: actions/upload-artifact@v7 with: diff --git a/.github/workflows/forest.yml b/.github/workflows/forest.yml index 8090d0fa0fe..9215e2e0104 100644 --- a/.github/workflows/forest.yml +++ b/.github/workflows/forest.yml @@ -63,8 +63,10 @@ jobs: with: go-version-file: "go.work" cache-dependency-path: "**/go.sum" - - name: Cargo Check - run: cargo check + - uses: jdx/mise-action@v4 + - run: cargo check + # nextest doesn't run doctests https://github.com/nextest-rs/nextest/issues/16 + - run: mise test:docs build-ubuntu: name: Build Ubuntu runs-on: ubuntu-24.04 diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml deleted file mode 100644 index 4f13930c0df..00000000000 --- a/.github/workflows/unit-tests.yml +++ /dev/null @@ -1,101 +0,0 @@ -name: Unit tests -permissions: - contents: read - -# Cancel workflow if there is a new change to the branch. -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} - -on: - workflow_dispatch: - merge_group: - pull_request: - branches: - - main - # This needs to be declared explicitly so that the job is actually - # run when moved out of draft. - types: [opened, synchronize, reopened, ready_for_review] - paths-ignore: - - "docs/**" - - ".github/workflows/docs-*.yml" - - "**/*.md" - push: - branches: - - main - paths-ignore: - - "docs/**" - - ".github/workflows/docs-*.yml" - - "**/*.md" - -env: - CI: 1 - CACHE_TIMEOUT_MINUTES: 5 - AWS_ACCESS_KEY_ID: "${{ secrets.AWS_ACCESS_KEY_ID }}" - AWS_SECRET_ACCESS_KEY: "${{ secrets.AWS_SECRET_ACCESS_KEY }}" - RUSTC_WRAPPER: "sccache" - CC: "sccache clang" - CXX: "sccache clang++" - # To minimize compile times: https://nnethercote.github.io/perf-book/build-configuration.html#minimizing-compile-times - RUSTFLAGS: "-C linker=clang -C link-arg=-fuse-ld=lld" - FIL_PROOFS_PARAMETER_CACHE: /var/tmp/filecoin-proof-parameters - RUST_LOG: error - FOREST_ACTOR_BUNDLE_PATH: /var/tmp/forest_actor_bundle.car.zst - -jobs: - tests-release: - runs-on: ubuntu-24.04-arm - timeout-minutes: 45 - # Run the job only if the PR is not a draft. - # This is done to limit the runner cost. - if: github.event.pull_request.draft == false - steps: - - name: Configure SCCache variables - run: | - # External PRs do not have access to 'vars' or 'secrets'. - if [[ "${{secrets.AWS_ACCESS_KEY_ID}}" != "" ]]; then - echo "SCCACHE_ENDPOINT=${{ vars.SCCACHE_ENDPOINT}}" >> $GITHUB_ENV - echo "SCCACHE_BUCKET=${{ vars.SCCACHE_BUCKET}}" >> $GITHUB_ENV - echo "SCCACHE_REGION=${{ vars.SCCACHE_REGION}}" >> $GITHUB_ENV - fi - - name: Checkout Sources - uses: actions/checkout@v6 - - name: Setup sccache - uses: mozilla-actions/sccache-action@v0.0.9 - timeout-minutes: ${{ fromJSON(env.CACHE_TIMEOUT_MINUTES) }} - continue-on-error: true - - uses: actions/setup-go@v6 - with: - go-version-file: "go.work" - cache-dependency-path: "**/go.sum" - - name: install nextest - uses: taiki-e/install-action@nextest - - uses: actions/cache@v5 - id: cache-proof-params - with: - path: ${{ env.FIL_PROOFS_PARAMETER_CACHE }} - key: proof-params-keys - - uses: actions/cache@v5 - id: cache-actor-bundle - with: - path: ${{ env.FOREST_ACTOR_BUNDLE_PATH }} - key: actor-bundle - - name: Fetch proof params and RPC test snapshots - run: | - cargo run --bin forest-dev --no-default-features --profile quick-test -- fetch-test-snapshots --actor-bundle $FOREST_ACTOR_BUNDLE_PATH - ls -ahl $FIL_PROOFS_PARAMETER_CACHE - - uses: jdx/mise-action@v4 - - run: | - mise test - env: - FOREST_TEST_SKIP_PROOF_PARAM_CHECK: 1 - # https://docs.github.com/en/actions/reference/runners/github-hosted-runners#standard-github-hosted-runners-for-public-repositories - CARGO_BUILD_JOBS: 3 - - name: Upload Test Results to CodeCov - uses: codecov/codecov-action@v6 - if: ${{ !cancelled() }} - with: - token: ${{ secrets.CODECOV_TOKEN }} - report_type: "test_results" - files: target/nextest/default/junit.xml - fail_ci_if_error: false diff --git a/Cargo.toml b/Cargo.toml index a8aab8d268d..b4edf30eabc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -289,6 +289,16 @@ debug = false # Speed up debug tests and codecov tests opt-level = 1 +[profile.codecov] +inherits = "dev" +opt-level = 1 + +[profile.codecov.package."*"] +# Avoid generating any debug information for dependencies +debug = false +# Speed up debug tests and codecov tests +opt-level = 1 + # Profile for interactive debugging sessions, e.g., with LLDB. # Doesn't work with Go FFI - disable it with `FOREST_F3_SIDECAR_FFI_BUILD_OPT_OUT=1`. [profile.debugging] diff --git a/mise.toml b/mise.toml index 669d89f21f4..06cae62236a 100644 --- a/mise.toml +++ b/mise.toml @@ -160,13 +160,8 @@ rm -rf node_modules # nextest doesn't run doctests https://github.com/nextest-rs/nextest/issues/16 # We need to run them separately. description = "Run doctests." -usage = ''' -arg "" help="Build profile (quick-test, dev, etc.)" default="quick-test" { - choices "quick" "quick-test" "release" "dev" -} -''' run = ''' -cargo test --doc --profile ${usage_profile?} --no-default-features --features "test doctest-private cargo-test" --no-fail-fast +cargo test --doc --no-default-features --features "test doctest-private cargo-test" --no-fail-fast ''' [tasks."test:nextest"] @@ -194,7 +189,7 @@ cargo test --lib --profile ${usage_profile?} --no-default-features --features "t ''' [tasks.test] -description = "Run all tests." +description = "Run nextest and cargo-test groups (doctests run via `test:docs`)." usage = ''' arg "" help="Build profile (quick-test, dev, etc.)" default="quick-test" { choices "quick" "quick-test" "release" "dev" @@ -203,13 +198,32 @@ arg "" help="Build profile (quick-test, dev, etc.)" default="quick-test run = ''' mise task run test:nextest ${usage_profile?} mise task run test:cargo ${usage_profile?} -mise task run test:docs ${usage_profile?} +''' + +[tasks."codecov:nextest"] +description = "Run codecov with nextest" +run = ''' +cargo llvm-cov --no-report nextest --cargo-profile codecov --workspace --no-default-features --features "test" --no-fail-fast +''' + +[tasks."codecov:cargo"] +description = "Run codecov with cargo-test" +run = ''' +cargo llvm-cov --no-report test -p forest-filecoin --profile codecov --lib --no-default-features --features "test cargo-test" --no-fail-fast -- "cargo_test_" +''' + +[tasks."codecov:report"] +description = "Generate merged codecov report" +run = ''' +cargo llvm-cov report --profile codecov --codecov --output-path lcov.info ''' [tasks.codecov] description = "Generate codecov report" run = ''' -cargo llvm-cov -p forest-filecoin --codecov --no-default-features --features "test cargo-test" --output-path lcov.info +mise task run codecov:nextest +mise task run codecov:cargo +mise task run codecov:report ''' [tasks."format-spellcheck-dictionary"]