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

Updated code coverage #36

Merged
merged 1 commit into from
Jul 14, 2024
Merged
Changes from all commits
Commits
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
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
Loading