From 04f802e89e803f77d8c7816b2f6050d83d750fa1 Mon Sep 17 00:00:00 2001 From: Jakub Date: Thu, 5 Sep 2024 11:14:52 +0200 Subject: [PATCH 1/2] CI: Implement branch coverage using llcov --- .github/workflows/codecov.yml | 51 +++++++++++------------------------ Makefile | 2 +- 2 files changed, 17 insertions(+), 36 deletions(-) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index da8bb577..e87c2306 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -1,42 +1,23 @@ -on: - push: - branches: - - main - name: Code coverage check -jobs: +on: [pull_request, push] +jobs: coverage: - name: Code Coverage - # https://github.com/actions/virtual-environments - runs-on: ubuntu-20.04 - strategy: - matrix: - rust-version: [1.78.0] + runs-on: ubuntu-latest + env: + CARGO_TERM_COLOR: always steps: - - name: Checkout sources - uses: actions/checkout@v3 - - name: Install stable toolchain - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: ${{ matrix.rust-version }} - target: wasm32-unknown-unknown - override: true - - name: Install tarpaulin - uses: actions-rs/cargo@v1 - with: - command: install - args: cargo-tarpaulin --version 0.30.0 - - run: make build - - name: Run code coverage check with tarpaulin - uses: actions-rs/cargo@v1 - with: - command: tarpaulin - args: --all-features --workspace --timeout 120 --out Xml --exclude soroban-token-contract + - uses: actions/checkout@v4 + - name: Install Rust + run: rustup update stable + - name: Install cargo-llvm-cov + uses: taiki-e/install-action@cargo-llvm-cov + - name: Generate code coverage + run: cargo llvm-cov --all-features --workspace --codecov --output-path codecov.json - name: Upload coverage to Codecov - uses: codecov/codecov-action@v1 + uses: codecov/codecov-action@v3 with: - token: ${{ secrets.CODECOV_TOKEN }} - file: ./cobertura.xml + token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos + files: lcov.info + fail_ci_if_error: true diff --git a/Makefile b/Makefile index 0c1802c8..32f316f3 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -SUBDIRS := contracts/collections contracts/deployer +SUBDIRS := contracts/deployer contracts/collections BUILD_FLAGS ?= default: build From 43c5b6d0bce12f3255aff957f1449633099be0ee Mon Sep 17 00:00:00 2001 From: Jakub Date: Thu, 5 Sep 2024 11:22:16 +0200 Subject: [PATCH 2/2] CI: Add explicite collections contract build to the coverage job --- .github/workflows/codecov.yml | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index e87c2306..c3ce177a 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -9,15 +9,32 @@ jobs: CARGO_TERM_COLOR: always steps: - uses: actions/checkout@v4 + - name: Install Rust run: rustup update stable + + - name: Install stable toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable # Specify the Rust toolchain version + target: wasm32-unknown-unknown + override: true + - name: Install cargo-llvm-cov uses: taiki-e/install-action@cargo-llvm-cov + + # Explicitly build the collections contract first + - name: Build Collections Contract + run: make build + - name: Generate code coverage run: cargo llvm-cov --all-features --workspace --codecov --output-path codecov.json + - name: Upload coverage to Codecov uses: codecov/codecov-action@v3 with: token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos - files: lcov.info + files: codecov.json # Changed from lcov.info to codecov.json based on the Generate code coverage step fail_ci_if_error: true +