Merge pull request #33 from lexara-prime-ai/dev #58
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Code Coverage | |
on: | |
push: | |
branches: [master] | |
pull_request: | |
branches: [master] | |
jobs: | |
code-coverage: | |
runs-on: ubuntu-latest | |
steps: | |
- 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 |