ci(python): Fix Python test coverage upload #2086
Workflow file for this run
This file contains 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: Code coverage | |
on: | |
pull_request: | |
paths: | |
- '**.rs' | |
- '**.py' | |
- .github/workflows/codecov.yml | |
push: | |
branches: | |
- main | |
paths: | |
- '**.rs' | |
- '**.py' | |
- .github/workflows/codecov.yml | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
defaults: | |
run: | |
shell: bash | |
env: | |
RUSTFLAGS: '-C instrument-coverage --cfg=coverage --cfg=coverage_nightly --cfg=trybuild_no_target' | |
RUST_BACKTRACE: 1 | |
LLVM_PROFILE_FILE: ${{ github.workspace }}/target/polars-%p-%3m.profraw | |
CARGO_LLVM_COV: 1 | |
CARGO_LLVM_COV_SHOW_ENV: 1 | |
CARGO_LLVM_COV_TARGET_DIR: ${{ github.workspace }}/target | |
jobs: | |
coverage-rust: | |
runs-on: macos-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- 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: Run tests | |
run: > | |
cargo test --all-features | |
-p polars-arrow | |
-p polars-compute | |
-p polars-core | |
-p polars-io | |
-p polars-lazy | |
-p polars-ops | |
-p polars-plan | |
-p polars-row | |
-p polars-sql | |
-p polars-time | |
-p polars-utils | |
- 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 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
- name: Create virtual environment | |
run: | | |
curl -LsSf https://astral.sh/uv/install.sh | sh | |
uv venv .venv | |
echo "$GITHUB_WORKSPACE/.venv/bin" >> $GITHUB_PATH | |
echo "VIRTUAL_ENV=$GITHUB_WORKSPACE/.venv" >> $GITHUB_ENV | |
- name: Install dependencies | |
run: uv 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 -m py-polars/Cargo.toml | |
- name: Run Python tests | |
working-directory: py-polars | |
run: pytest --cov -n auto --dist loadgroup -m "not release and 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 release and not benchmark and not docs" tests/unit/io/ --cov-report xml:async.xml | |
continue-on-error: true | |
- 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: coverage-rust.lcov,coverage-python.lcov,py-polars/main.xml,py-polars/async.xml | |
token: ${{ secrets.CODECOV_TOKEN }} | |
fail_ci_if_error: true |