Repository navigation
Activate codecov tests #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Run the Rust tests 🦀 | |
| on: | |
| push: | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| build: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest] | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Get data | |
| uses: ./.github/actions/cache-data | |
| - name: Switch to nightly Rust | |
| run: | | |
| rustup default nightly | |
| rustup component add llvm-tools-preview | |
| - name: Set RUSTDOCFLAGS | |
| run: | | |
| echo "RUSTDOCFLAGS=-Cinstrument-coverage -Z unstable-options --persist-doctests $(pwd)/target/debug/doctestbins" >> "$GITHUB_ENV" | |
| - name: Run tests 🦀 | |
| env: | |
| RUSTFLAGS: '-Cinstrument-coverage -Clink-dead-code' | |
| run: | | |
| cargo test --workspace --exclude mchep_pyapi --no-fail-fast 2> >(tee stderr 1>&2) | |
| if [ "${{ matrix.os }}" != "macos-latest" ]; then | |
| sed -i 's/\x1B\[[0-9;]\{1,\}[A-Za-z]//g' stderr | |
| fi | |
| - name: Generate code coverage | |
| if: matrix.os == 'ubuntu-latest' | |
| run: | | |
| find . -name '*.profraw' -exec $(rustc --print target-libdir)/../bin/llvm-profdata merge -sparse -o mchep.profdata {} + | |
| ( sed -nE 's/[[:space:]]+Running( unittests|) [^[:space:]]+ \(([^)]+)\)/\2/p' stderr && echo target/debug/doctestbins/*/rust_out | tr ' ' "\n" ) | \ | |
| xargs printf ' --object %s' | \ | |
| xargs $(rustc --print target-libdir)/../bin/llvm-cov export \ | |
| --ignore-filename-regex=index.crates.io \ | |
| --ignore-filename-regex=rustc \ | |
| --ignore-filename-regex=mchep/tests \ | |
| --ignore-filename-regex=mchep_capi \ | |
| --instr-profile=mchep.profdata \ | |
| --skip-functions \ | |
| --object target/debug/mchep \ | |
| --format lcov > lcov.info | |
| grep SF lcov.info | sort -u | sed 's/SF://' | |
| - name: Upload to codecov.io | |
| if: matrix.os == 'ubuntu-latest' | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| flags: rust |