From 794c9cd8915174c0cedb87f557ae573a5a9d9b69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Garillot?= Date: Wed, 30 Mar 2022 21:30:37 -0400 Subject: [PATCH] chore: add code coverage --- .github/workflows/codecov.yml | 49 +++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .github/workflows/codecov.yml diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml new file mode 100644 index 0000000000000..831cd9970ca7e --- /dev/null +++ b/.github/workflows/codecov.yml @@ -0,0 +1,49 @@ +name: Codecov +on: + push: + branches: + - main + pull_request: + branches: + - main + types: [opened, reopened, synchronize] + +jobs: + codecov-grcov: + name: Generate code coverage + runs-on: ubuntu-latest + strategy: + fail-fast: true + steps: + - name: install toolchain according to rust-toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: nightly + profile: default + override: true + components: llvm-tools-preview + - name: Checkout sources + uses: actions/checkout@v2 + - uses: Swatinem/rust-cache@v1 + - name: Install grcov, and cache the binary + uses: baptiste0928/cargo-install@v1 + with: + crate: grcov + - name: Build + uses: actions-rs/cargo@v1 + with: + command: build + env: + RUSTFLAGS: '-Cinstrument-coverage' + RUSTDOCFLAGS: '-Cinstrument-coverage' + - name: Run tests + env: + RUSTFLAGS: '-Cinstrument-coverage' + RUSTDOCFLAGS: '-Cinstrument-coverage' + LLVM_PROFILE_FILE: 'codecov-instrumentation-%p-%m.profraw' + run: | + cargo test + - name: Run grcov + run: grcov . --binary-path target/debug/ -s . -t lcov --branch --ignore-not-existing --ignore '../**' --ignore '/*' -o coverage.lcov + - name: Upload to codecov.io + uses: codecov/codecov-action@v1 \ No newline at end of file