Skip to content

Commit

Permalink
ci: Split coverage calculation (pola-rs#15780)
Browse files Browse the repository at this point in the history
  • Loading branch information
stinodego authored Apr 19, 2024
1 parent d11da5e commit 0c37ead
Showing 1 changed file with 74 additions and 29 deletions.
103 changes: 74 additions & 29 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,36 +20,22 @@ concurrency:

defaults:
run:
working-directory: py-polars
shell: bash

env:
RUSTFLAGS: '-C instrument-coverage --cfg=coverage --cfg=coverage_nightly --cfg=trybuild_no_target'
RUST_BACKTRACE: 1
LLVM_PROFILE_FILE: '/Users/runner/work/polars/polars/target/polars-%p-%3m.profraw'
CARGO_LLVM_COV: 1
CARGO_LLVM_COV_SHOW_ENV: 1
CARGO_LLVM_COV_TARGET_DIR: '/Users/runner/work/polars/polars/target'

jobs:
coverage:
name: Code Coverage
coverage-rust:
runs-on: macos-latest
env:
RUSTFLAGS: '-C instrument-coverage --cfg=coverage --cfg=coverage_nightly --cfg=trybuild_no_target'
RUST_BACKTRACE: 1
LLVM_PROFILE_FILE: '/Users/runner/work/polars/polars/target/polars-%p-%3m.profraw'
CARGO_LLVM_COV: 1
CARGO_LLVM_COV_SHOW_ENV: 1
CARGO_LLVM_COV_TARGET_DIR: '/Users/runner/work/polars/polars/target'

steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Create virtual environment
run: |
python -m venv .venv
echo "$GITHUB_WORKSPACE/py-polars/.venv/bin" >> $GITHUB_PATH
- name: Install dependencies
run: pip install -r requirements-dev.txt

- name: Set up Rust
run: rustup component add llvm-tools-preview

Expand Down Expand Up @@ -79,28 +65,87 @@ jobs:
-p polars-time
-p polars-utils
- name: Run Rust integration tests
- name: Run integration tests
run: cargo test --all-features -p polars --test it

- name: Report coverage
run: cargo llvm-cov report --lcov --output-path coverage-rust.lcov

- name: Upload coverage report
uses: actions/upload-artifact@v4
with:
name: coverage-rust
path: coverage-rust.lcov

coverage-python:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Create virtual environment
run: |
python -m venv .venv
echo "$GITHUB_WORKSPACE/.venv/bin" >> $GITHUB_PATH
- name: Install dependencies
run: pip install -r py-polars/requirements-dev.txt

- name: Set up Rust
run: rustup component add llvm-tools-preview

- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov

- name: Cache Rust
uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.ref_name == 'main' }}

- name: Prepare coverage
run: cargo llvm-cov clean --workspace

- name: Install Polars
run: maturin develop
run: maturin develop -m py-polars/Cargo.toml

- name: Run Python tests
working-directory: py-polars
run: pytest --cov -n auto --dist loadgroup -m "not benchmark and not docs" --cov-report xml:main.xml
continue-on-error: true

- name: Run Python tests - async reader
working-directory: py-polars
env:
POLARS_FORCE_ASYNC: 1
run: pytest --cov -m "not benchmark and not docs" tests/unit/io/ --cov-report xml:async.xml
continue-on-error: true

- name: Report coverage
run: cargo llvm-cov report --lcov --output-path coverage.lcov
- name: Report Rust coverage
run: cargo llvm-cov report --lcov --output-path coverage-python.lcov

- name: Upload coverage reports
uses: actions/upload-artifact@v4
with:
name: coverage-python
path: |
coverage-python.lcov
py-polars/main.xml
py-polars/async.xml
upload-coverage:
needs: [coverage-rust, coverage-python]
runs-on: ubuntu-latest
steps:
- name: Download coverage files
uses: actions/download-artifact@v4
with:
merge-multiple: true

- name: Upload coverage information
uses: codecov/codecov-action@v4
with:
files: py-polars/coverage.lcov,py-polars/main.xml,py-polars/async.xml
name: macos
files: coverage-rust.lcov,coverage-python.lcov,main.xml,async.xml
token: ${{ secrets.CODECOV_TOKEN }}

0 comments on commit 0c37ead

Please sign in to comment.