Skip to content

Add code coverage.

Add code coverage. #4

Workflow file for this run

name: CI
on:
push:
branches: ["main"]
paths-ignore: ["*.md", "LICENSE-*"]
pull_request:
branches: ["main"]
paths-ignore: ["*.md", "LICENSE-*"]
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
check:
name: Continuous Integration
runs-on: ubuntu-latest
env:
NSS_DIR: ${{ github.workspace }}/nss
strategy:
fail-fast: false
matrix:
hpke:
- rust-hpke
rust:
- 1.75.0
- stable
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
components: rustfmt, clippy, llvm-tools-preview
- name: Install Build Prerequisites for NSS
if: matrix.hpke == 'nss'
run: |
DEBIAN_FRONTEND=noninteractive sudo apt-get install -y \
build-essential \
ca-certificates \
clang \
coreutils \
curl \
git \
gyp \
libclang-dev \
libssl-dev \
lld \
llvm \
make \
mercurial \
ninja-build \
pkg-config \
ssh \
zlib1g-dev \
--no-install-recommends
echo RUSTFLAGS="-C link-arg=-fuse-ld=lld" >> "$GITHUB_ENV"
- name: Fetch NSS and NSPR
if: matrix.hpke == 'nss'
run: |
hg clone https://hg.mozilla.org/projects/nspr "$NSS_DIR"/../nspr
git clone --depth 1 https://github.com/nss-dev/nss "$NSS_DIR"
echo "LD_LIBRARY_PATH=${{ github.workspace }}/dist/Debug/lib" >> "$GITHUB_ENV"
- name: Build
run: |
cargo +${{ matrix.rust }} build --tests --no-default-features --features ${{ matrix.hpke }},client,server
- name: Run Tests
run: |
cargo +${{ matrix.rust }} test --no-default-features --features ${{ matrix.hpke }},client,server
- name: Check formatting
if: ${{ success() || failure() }}
run: |
cargo +${{ matrix.rust }} fmt --all -- --check --config imports_granularity=Crate
- name: Clippy
if: ${{ success() || failure() }}
run: |
cargo clippy --tests --no-default-features --features ${{ matrix.hpke }},client,server
- name: Install cargo-llvm-cov
if: ${{ success() || failure() }}
run: |
cargo install cargo-llvm-cov
- name: Generate coverage report
if: ${{ success() || failure() }}
run: |
cargo llvm-cov --workspace --cobertura --output-path target/cobertura.xml -- --test --test-threads=1
- name: Upload coverage artifact
if: ${{ success() || failure() }}
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: target/cobertura.xml