Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tb/coverage next #2044

Closed
wants to merge 34 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .config/nextest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ retries = 2
slow-timeout = "2m"
default-filter = 'package(tests)'
retries = 2

[profile.coverage]
default-filter = 'not (test(slow_) | test(service::test::test_) | test(uint_bytes) | test(diff-test-hotshot) | test(test_catchup) | package(contract-bindings) | package(gen-vk-contract) | package(hotshot-contract-adapter) | package(hotshot-state-prover) | package(tests))'
47 changes: 15 additions & 32 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,24 @@ on:
branches:
- main
- release-*
pull_request:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:

CARGO_TERM_COLOR: always
NEXTEST_PROFILE: coverage
COVERAGE_RUSTFLAGS: >
-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort
-Zpanic_abort_tests -Cdebuginfo=2 --cfg async_executor_impl="async-std" --cfg async_channel_impl="async-std" --cfg
--cfg async_executor_impl="async-std" --cfg async_channel_impl="async-std" --cfg
hotshot_example
COVERAGE_RUSTDOCFLAGS: >
-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort
-Zpanic_abort_tests
CARGO_TEST_CMD: >
cargo +nightly test --locked --all-features --no-fail-fast --release --workspace --exclude contract-bindings
--exclude gen-vk-contract --exclude hotshot-contract-adapter --exclude diff-test-hotshot

jobs:
code-coverage:
runs-on: ubuntu-latest
runs-on: buildjet-16vcpu-ubuntu-2204
steps:
- name: Checkout Repository
uses: actions/checkout@v4
Expand All @@ -37,37 +34,23 @@ jobs:
with:
version: nightly

- uses: dtolnay/rust-toolchain@nightly
- uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview

- name: Enable Rust Caching
uses: Swatinem/rust-cache@v2

# Separate build step for easier identification of failures and timings.
- name: Build tests for coverage
run: |
$CARGO_TEST_CMD --no-run
env:
# Do not exceed the memory limit of the public github runner during cargo build.
CARGO_BUILD_JOBS: "2"
CARGO_INCREMENTAL: "0"
RUSTFLAGS: ${{ env.COVERAGE_RUSTFLAGS }}
RUSTDOCFLAGS: ${{ env.COVERAGE_RUSTDOCFLAGS }}
- uses: taiki-e/install-action@cargo-llvm-cov
- uses: taiki-e/install-action@nextest

- name: Run tests with coverage
run: |
$CARGO_TEST_CMD -- --skip service::test::test_
- name: Collect coverage data
run: cargo llvm-cov nextest --all-features --no-fail-fast --lcov --output-path lcov.info
env:
CARGO_INCREMENTAL: "0"
RUSTFLAGS: ${{ env.COVERAGE_RUSTFLAGS }}
RUSTDOCFLAGS: ${{ env.COVERAGE_RUSTDOCFLAGS }}

- uses: alekitto/[email protected]
with:
config: .github/grcov.yml
id: coverage
timeout-minutes: 90

- name: Coveralls upload
uses: coverallsapp/github-action@master
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ${{ steps.coverage.outputs.report }}
4 changes: 2 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,9 @@
];
CARGO_INCREMENTAL = "0";
shellHook = ''
RUSTFLAGS="$RUSTFLAGS -Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests -Cdebuginfo=2"
RUSTFLAGS="$RUSTFLAGS -Zprofile -Ccodegen-units=1 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests -Cdebuginfo=2 -Cllvm-args=--inline-threshold=0"
'';
RUSTDOCFLAGS = "-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests";
RUSTDOCFLAGS = "-Zprofile -Ccodegen-units=1 -Cllvm-args=--inline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests";
});

devShells.rustShell =
Expand Down
5 changes: 1 addition & 4 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,7 @@ gas-benchmarks:
# the lcov output is pushed to coveralls.
code-coverage:
@echo "Running code coverage"
nix develop .#coverage -c cargo test --all-features --no-fail-fast --release --workspace -- --skip service::test::test_
grcov . -s . --binary-path $CARGO_TARGET_DIR/debug/ -t html --branch --ignore-not-existing -o $CARGO_TARGET_DIR/coverage/ \
--ignore 'contract-bindings/*' --ignore 'contracts/*'
@echo "HTML report available at: $CARGO_TARGET_DIR/coverage/index.html"
cargo llvm-cov nextest --all-features --profile coverage --no-fail-fast --open

# Download Aztec's SRS for production
download-srs:
Expand Down
Loading