Skip to content

Commit

Permalink
fix: merge steps for testbased coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
kristof-mattei committed Feb 15, 2022
1 parent b3b0cb6 commit a7b74e1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 55 deletions.
75 changes: 20 additions & 55 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,9 @@ jobs:
cargo --version
- name: Cargo build
uses: actions-rs/cargo@844f36862e911db73fe0815f00a4a2602c279505
with:
command: build
args: --verbose
- name: Build
run: |
cargo build --all-targets --workspace --verbose
cargo-fmt:
name: Cargo fmt
Expand Down Expand Up @@ -188,6 +186,7 @@ jobs:
runs-on: ubuntu-latest
needs:
- changes
- cargo-build
if: |
(needs.changes.outputs.code == 'true')
steps:
Expand Down Expand Up @@ -220,7 +219,22 @@ jobs:
run: |
cargo install --locked cargo-nextest;
- name: Install grcov
run: |
cargo install --locked grcov;
- name: Build with instrumentation support
env:
RUSTC_BOOSTRAP: 1
RUSTFLAGS: "-Zinstrument-coverage"
run: |
cargo build --all-targets --workspace --verbose
- name: Run nextest
env:
RUSTC_BOOSTRAP: 1
RUSTFLAGS: "-Zinstrument-coverage"
LLVM_PROFILE_FILE: "profiling/profile-%p-%m.profraw"
run: |
cargo nextest run --profile ci --no-fail-fast --all-targets --workspace
continue-on-error: true
Expand All @@ -232,57 +246,9 @@ jobs:
github_token: ${{ secrets.GITHUB_TOKEN }}
files: reports/results.xml

cargo-coverage:
name: Cargo coverage
runs-on: ubuntu-latest
needs:
- changes
- cargo-build
if: |
(needs.changes.outputs.code == 'true')
steps:
- name: Checkout
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579

- name: Cache dependencies
uses: actions/cache@937d24475381cd9c75ae6db12cb4e79714b926ed
env:
CACHE_NAME: cargo-cache-dependencies
with:
path: |
~/.cargo
./target
key: ${{ runner.os }}-build-${{ env.CACHE_NAME }}-${{ hashFiles('Cargo.lock') }}-test
restore-keys: |
${{ runner.os }}-build-${{ env.CACHE_NAME }}-${{ hashFiles('Cargo.lock') }}-
${{ runner.os }}-build-${{ env.CACHE_NAME }}-
- name: Set up toolchain
shell: bash
run: |
rm ${HOME}/.cargo/bin/rustfmt
rm ${HOME}/.cargo/bin/cargo-fmt
rustup update
cargo --version
- name: Install grcov
run: |
cargo install --locked grcov;
- name: Build with coverage enabled
env:
RUSTC_BOOTSTRAP: 1
CARGO_INCREMENTAL: 0
RUSTFLAGS: "-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"
RUSTDOCFLAGS: "-Cpanic=abort"
run: |
cargo build --all-targets --workspace
- name: Run grcov
run: |
grcov . --source-dir . --binary-path ./target/debug/ --output-type lcov --branch --ignore-not-existing --llvm --output-path ./reports/lcov.info
continue-on-error: true
grcov $(find profiling -name "profile-*.profraw" -print) --source-dir . --binary-path ./target/debug/ --output-type lcov --branch --ignore-not-existing --llvm --output-path ./reports/lcov.info
- name: Upload to CodeCov
uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b
Expand Down Expand Up @@ -404,7 +370,6 @@ jobs:
- cargo-fmt
- cargo-test-and-report
- cargo-clippy-and-report
- cargo-coverage
- docker-build
if: ${{ github.repository == 'kristof-mattei/rust-end-to-end-application' && github.event_name == 'pull_request' }}
steps:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@

node_modules/
reports/
profiling/
NEXTVERSION
Empty file added profiling/.gitkeep
Empty file.

0 comments on commit a7b74e1

Please sign in to comment.