Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update coverage to use cargo llvm-cov #109

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 40 additions & 73 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,21 @@ on:
pull_request: {}

jobs:
test-linux:
name: test rust-${{ matrix.rust-version }} on linux
test-rust:
name: test rust-${{ matrix.rust-version }} on ${{ matrix.runs-on }}
strategy:
fail-fast: false
matrix:
rust-version: [stable, nightly]
runs-on: [ubuntu-latest, macos-latest]
rust-version: [stable]
include:
- runs-on: ubuntu-latest
rust-version: nightly

runs-on: ubuntu-latest
runs-on: ${{ matrix.runs-on }}

env:
RUNS_ON: ubuntu-latest
RUNS_ON: ${{ matrix.runs-on }}
RUST_VERSION: ${{ matrix.rust-version }}

steps:
Expand All @@ -33,24 +37,23 @@ jobs:
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust-version }}
components: llvm-tools-preview

- id: cache-rust
uses: Swatinem/rust-cache@v2
with:
prefix-key: "v1-rust"

- run: cargo install rustfilt coverage-prepare cargo-careful
if: steps.cache-rust.outputs.cache-hit != 'true'

- run: rustup component add llvm-tools-preview
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov

- run: cargo test -F python
- run: |
source <(cargo llvm-cov show-env --export-prefix)
cargo test -F python
env:
RUST_BACKTRACE: 1
RUSTFLAGS: '-C instrument-coverage'

- run: coverage-prepare --ignore-filename-regex '/tests/' lcov $(find ../../target/debug/deps -regex '.*/main[^.]*')
working-directory: crates/jiter
- run: |
source <(cargo llvm-cov show-env --export-prefix)
cargo llvm-cov report --codecov --output-path=coverage.json

- run: cargo test --doc

Expand All @@ -59,52 +62,7 @@ jobs:

- uses: codecov/codecov-action@v4
with:
env_vars: RUNS_ON,RUST_VERSION
token: ${{ secrets.CODECOV_TOKEN }}

test-macos:
name: test on ${{ matrix.runs-on }}
strategy:
fail-fast: false
matrix:
runs-on: [macos-latest, macos-latest]

runs-on: ${{ matrix.runs-on }}

env:
RUNS_ON: ${{ matrix.runs-on }}
RUST_VERSION: stable

steps:
- uses: actions/checkout@v3

- name: set up python
uses: actions/setup-python@v4
with:
python-version: '3.12'

- uses: dtolnay/rust-toolchain@stable

- id: cache-rust
uses: Swatinem/rust-cache@v2

- run: cargo install rustfilt coverage-prepare
if: steps.cache-rust.outputs.cache-hit != 'true'

- run: rustup component add llvm-tools-preview

- run: cargo test -F python
env:
RUST_BACKTRACE: 1
RUSTFLAGS: '-C instrument-coverage'

- run: coverage-prepare --ignore-filename-regex '/tests/' lcov $(find ../../target/debug/deps -regex '.*/main[^.]*')
working-directory: crates/jiter

- run: cargo test --doc

- uses: codecov/codecov-action@v4
with:
file: coverage.json
env_vars: RUNS_ON,RUST_VERSION
token: ${{ secrets.CODECOV_TOKEN }}

Expand All @@ -125,33 +83,42 @@ jobs:
python-version: '3.12'

- uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview

- id: cache-rust
uses: Swatinem/rust-cache@v2

- run: cargo install rustfilt coverage-prepare
if: steps.cache-rust.outputs.cache-hit != 'true'
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov

- run: rustup component add llvm-tools-preview
- run: |
source <(cargo llvm-cov show-env --export-prefix)
make python-install

- run: make python-install

- run: pip install -e crates/jiter-python
env:
RUSTFLAGS: '-C instrument-coverage'
- run: |
source <(cargo llvm-cov show-env --export-prefix)
pip install -e crates/jiter-python

- run: pytest crates/jiter-python/tests
- run: |
source <(cargo llvm-cov show-env --export-prefix)
pytest crates/jiter-python/tests
env:
RUST_BACKTRACE: 1

- run: python crates/jiter-python/bench.py
- run: |
source <(cargo llvm-cov show-env --export-prefix)
python crates/jiter-python/bench.py
env:
FAST: 1

- run: coverage-prepare lcov $(python -c 'import jiter.jiter;print(jiter.jiter.__file__)')
- run: |
source <(cargo llvm-cov show-env --export-prefix)
cargo llvm-cov report --codecov --output-path=coverage.json

- uses: codecov/codecov-action@v4
with:
file: coverage.json
token: ${{ secrets.CODECOV_TOKEN }}

bench:
Expand Down Expand Up @@ -550,7 +517,7 @@ jobs:
# https://github.com/marketplace/actions/alls-green#why used for branch protection checks
check:
if: always()
needs: [test-linux, test-macos, test-python, bench, fuzz, fuzz-skip, lint]
needs: [test-rust, test-python, bench, fuzz, fuzz-skip, lint]
runs-on: ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
Expand Down
Loading