From 6885e59e16a815558bacaefaa1131161735aabbe Mon Sep 17 00:00:00 2001 From: Jing Zhang Date: Tue, 17 Mar 2026 20:46:59 +0000 Subject: [PATCH 1/2] coverage Signed-off-by: Jing Zhang --- .github/workflows/coverage.yml | 33 +++++++++++++++++++++++++++++++++ Makefile | 7 ++++++- 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/coverage.yml diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 00000000..5a851716 --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,33 @@ +name: Coverage + +on: + pull_request: {} + +jobs: + coverage: + if: github.repository_owner == 'sonic-net' + name: Rust line coverage (>= 80%) + runs-on: ubuntu-latest + steps: + - name: Checkout (no submodules) + uses: actions/checkout@v4 + with: + submodules: false + fetch-depth: 0 + + - name: Install Rust (stable) + uses: dtolnay/rust-toolchain@stable + + - name: Cargo cache + uses: Swatinem/rust-cache@v2 + + - name: Install LLVM tools for coverage + run: rustup component add llvm-tools-preview + + - name: Install cargo-llvm-cov + run: | + cargo install cargo-llvm-cov --locked || true + cargo llvm-cov --version + + - name: Run unit tests with coverage (fail under 80% lines) + run: cargo llvm-cov --workspace --all-features --fail-under-lines 80 \ No newline at end of file diff --git a/Makefile b/Makefile index 52cca29a..3dd6ada9 100644 --- a/Makefile +++ b/Makefile @@ -56,7 +56,7 @@ test-release: clean-release: cargo clean --release -ci-all: | ci-format ci-build ci-doc ci-lint ci-test +ci-all: | ci-format ci-build ci-doc ci-lint ci-test ci-coverage ci-format: cargo fmt --check --all @@ -80,3 +80,8 @@ ci-test: cargo test --workspace --all-features cargo clean cargo test --release --workspace --all-features + +ci-coverage: + rustup component add llvm-tools-preview + cargo install cargo-llvm-cov --locked || true + cargo llvm-cov --workspace --all-features --fail-under-lines 80 From 427179bcac3a9c5e92ae4d5b9950daeb8a5f8ee1 Mon Sep 17 00:00:00 2001 From: Jing Zhang Date: Tue, 17 Mar 2026 20:55:31 +0000 Subject: [PATCH 2/2] azp Signed-off-by: Jing Zhang --- .github/workflows/coverage.yml | 33 --------------------------------- azure-pipelines.yml | 4 ++++ 2 files changed, 4 insertions(+), 33 deletions(-) delete mode 100644 .github/workflows/coverage.yml diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml deleted file mode 100644 index 5a851716..00000000 --- a/.github/workflows/coverage.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Coverage - -on: - pull_request: {} - -jobs: - coverage: - if: github.repository_owner == 'sonic-net' - name: Rust line coverage (>= 80%) - runs-on: ubuntu-latest - steps: - - name: Checkout (no submodules) - uses: actions/checkout@v4 - with: - submodules: false - fetch-depth: 0 - - - name: Install Rust (stable) - uses: dtolnay/rust-toolchain@stable - - - name: Cargo cache - uses: Swatinem/rust-cache@v2 - - - name: Install LLVM tools for coverage - run: rustup component add llvm-tools-preview - - - name: Install cargo-llvm-cov - run: | - cargo install cargo-llvm-cov --locked || true - cargo llvm-cov --version - - - name: Run unit tests with coverage (fail under 80% lines) - run: cargo llvm-cov --workspace --all-features --fail-under-lines 80 \ No newline at end of file diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 0b7aec51..593e410b 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -109,6 +109,10 @@ stages: make ci-test displayName: 'Test' + - script: | + make ci-coverage + displayName: 'Coverage (fail under 80% lines)' + - publish: $(System.DefaultWorkingDirectory)/ artifact: sonic-dash-ha displayName: 'Archive release binaries'