Skip to content

Commit

Permalink
Updated code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
irfanghat committed Jul 14, 2024
1 parent e14f599 commit 96141e6
Showing 1 changed file with 27 additions and 45 deletions.
72 changes: 27 additions & 45 deletions .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,48 +14,30 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
components: llvm-tools-preview

- name: Install grcov
run: cargo install grcov
working-directory: ./rust

- name: Install x86_64-unknown-linux-gnu target
run: rustup target add x86_64-unknown-linux-gnu
working-directory: ./rust

- name: Set up coverage configuration
run: |
mkdir -p .cargo
echo "[build]" > .cargo/config.toml
echo 'rustflags = ["-Zinstrument-coverage","-Ccodegen-units=1","-Cinline-threshold=0","-Clink-dead-code","-Coverflow-checks=off","-Zno-profiler-runtime"]' >> .cargo/config.toml
echo "[unstable]" >> .cargo/config.toml
echo 'build-std = ["std"]' >> .cargo/config.toml
working-directory: ./rust

- name: Run tests with coverage
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: "-Zinstrument-coverage"
LLVM_PROFILE_FILE: "coverage-%p-%m.profraw"
run: cargo test --target x86_64-unknown-linux-gnu
working-directory: ./rust

- name: Generate coverage report
run: |
grcov . -s . -t html --llvm --branch --ignore-not-existing -o ./coverage
mkdir -p coverage-report
cp -r ./coverage/* coverage-report/
working-directory: ./rust

- name: Upload coverage report
uses: actions/upload-artifact@v2
with:
name: coverage-report
path: coverage-report
- name: Install toolchain
id: toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: x86_64-unknown-linux-musl
override: true
components: llvm-tools-preview

- name: Download grcov
run: |
mkdir -p "${HOME}/.local/bin"
curl -sL https://github.com/mozilla/grcov/releases/download/v0.8.10/grcov-x86_64-unknown-linux-gnu.tar.bz2 | tar jxf - -C "${HOME}/.local/bin"
echo "$HOME/.local/bin" >> $GITHUB_PATH
working-directory: ./rust


- name: Run xtask coverage
uses: actions-rs/cargo@v1
with:
command: xtask
args: coverage

- name: Upload to codecov.io
uses: codecov/codecov-action@v3
with:
files: coverage/*.lcov

0 comments on commit 96141e6

Please sign in to comment.