Skip to content

Commit

Permalink
update ci with codecov
Browse files Browse the repository at this point in the history
  • Loading branch information
mothsART committed Aug 23, 2024
1 parent 711eb7f commit b735a80
Showing 1 changed file with 16 additions and 93 deletions.
109 changes: 16 additions & 93 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,106 +39,29 @@ jobs:
command: test
args: --verbose ${{ matrix.features }}

test-coverage:
name: Test coverage (gcc-${{ matrix.gcc }}, clang-${{ matrix.clang }})
runs-on: ubuntu-latest
strategy:
matrix:
include:
- gcc: 10
clang: 11
- gcc: 11
clang: 12
- gcc: 11
clang: 13
env:
CXX: clang++-${{ matrix.clang }}
CLANG_CXX: clang++-${{ matrix.clang }}
GCC_CXX: g++-${{ matrix.gcc }}
GCOV: gcov-${{ matrix.gcc }}
continue-on-error: true
steps:
- name: Prepare C toolchains
run: |
# Add LLVM keys
curl -o- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
# Add extra APT repos
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo add-apt-repository 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-11 main'
sudo add-apt-repository 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-12 main'
sudo add-apt-repository 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-13 main'
# Install toolchains
sudo apt-get update
sudo apt-get install -y clang-${{ matrix.clang }} g++-${{ matrix.gcc }}
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Rust
run: |
rustup toolchain add nightly --component llvm-tools-preview
rustup override set nightly
- name: Configure cache
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: test-${{ runner.os }}-cargo-gcc-${{ matrix.gcc }}-clang-${{ matrix.clang }}-${{ hashFiles('**/Cargo.lock') }}
- name: Build
env:
RUSTFLAGS: -Cinstrument-coverage
run: cargo build
- name: Test
env:
LLVM_PROFILE_FILE: grcov-%p-%m.profraw
RUSTFLAGS: -Cinstrument-coverage
run: cargo test
- name: Generate coverage
run: |
./target/debug/grcov $(find . -name "grcov-*.profraw" -print) \
--branch \
--ignore-not-existing \
--binary-path ./target/debug/ \
-s . \
-t lcov \
--ignore "/*" \
-o lcov.info
coverage:
name: Coverage
runs-on: ubuntu-latest

steps:
- name: Checkout sources
uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Install rust
uses: actions-rs/toolchain@v1
- name: Install Rust (nightly)
uses: actions-rust-lang/setup-rust-toolchain@v1.9.0
with:
toolchain: stable
profile: minimal
override: true

- name: Cache
uses: Swatinem/rust-cache@v1
toolchain: nightly
components: llvm-tools

- name: Install cargo-tarpaulin
uses: actions-rs/cargo@v1
- name: Install just, cargo-llvm-cov, cargo-nextest
uses: taiki-e/[email protected]
with:
command: install
args: cargo-tarpaulin
tool: just,cargo-llvm-cov,cargo-nextest

- name: Run cargo tarpaulin
uses: actions-rs/cargo@v1
with:
command: tarpaulin
args: -- --test-threads 1
- name: Generate code coverage
run: just test-coverage-codecov

- name: Publish to Coveralls
uses: coverallsapp/github-action@master
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4.5.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
files: codecov.json
fail_ci_if_error: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

0 comments on commit b735a80

Please sign in to comment.