diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 73b4f247..e39b453b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -61,6 +61,39 @@ jobs: run: cargo +${{ matrix.rust-version }} test + coverage: + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + with: + submodules: true + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y \ + libbpf-dev \ + protobuf-compiler + + - uses: actions/cache@v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-${{ runner.arch }}-cargo-coverage-${{ hashFiles('**/Cargo.lock') }} + + - name: Generate coverage + run: make coverage + + - name: Upload to Codecov + uses: codecov/codecov-action@v5 + with: + files: codecov.json + token: ${{ secrets.CODECOV_TOKEN }} + format-check: runs-on: ubuntu-24.04 env: diff --git a/.gitignore b/.gitignore index dc478a1e..29fe02fc 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,7 @@ internalapi/ results.xml logs/ THIRD_PARTY_LICENSES.html +codecov.json # clangd and compilation database .cache/ diff --git a/CHANGELOG.md b/CHANGELOG.md index 86bcf5fe..76be7c95 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ possible include a PR number for easier tracking. ## Next +* feat: add code coverage with cargo-llvm-cov and Codecov upload (#745) + ## 0.3.0 * ROX-34663: Migrate from ubi-minimal to ubi-micro (#653) diff --git a/Makefile b/Makefile index 55f58098..85fdd936 100644 --- a/Makefile +++ b/Makefile @@ -32,9 +32,13 @@ integration-tests: performance-tests: make -C performance-tests +coverage: + cargo llvm-cov --workspace --codecov --output-path codecov.json + clean: make -C tests clean rm -f THIRD_PARTY_LICENSES.html + rm -f codecov.json format-check: cargo fmt --check @@ -44,4 +48,4 @@ format: cargo fmt make -C fact-ebpf format -.PHONY: tag mock-server integration-tests image image-name licenses clean +.PHONY: tag mock-server integration-tests image image-name licenses coverage clean