Skip to content

Commit

Permalink
Code coverage for Rust/Python (#3278)
Browse files Browse the repository at this point in the history
  • Loading branch information
cjermain committed May 3, 2022
1 parent ee76815 commit 519096f
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 1 deletion.
41 changes: 41 additions & 0 deletions .github/workflows/coverage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Coverage

on:
push:
branches:
- master
pull_request:

jobs:
coverage:
name: Coverage for ${{ matrix.os }}
strategy:
matrix:
os: ["ubuntu"]
runs-on: ${{ matrix.os }}-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: "3.10"
cache: "pip"
cache-dependency-path: "py-polars/build.requirements.txt"
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2022-04-01
override: true
profile: minimal
components: llvm-tools-preview
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- uses: Swatinem/rust-cache@v1
with:
key: coverage-cargo-${{ matrix.os }}
continue-on-error: true
- name: Run coverage
run: make coverage
- uses: codecov/codecov-action@v3
with:
files: coverage.lcov,coverage.xml
name: ${{ matrix.os }}
fail_ci_if_error: true
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ node_modules/
.coverage
venv/
*.iml
coverage.lcov
coverage.xml
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,17 @@ changelog-rust:

fmt_toml:
dprint fmt

coverage:
@bash -c "\
rustup override set nightly-2022-04-01; \
source <(cargo llvm-cov show-env --export-prefix); \
export CARGO_TARGET_DIR=\$$CARGO_LLVM_COV_TARGET_DIR; \
export CARGO_INCREMENTAL=1; \
cargo llvm-cov clean --workspace; \
$(MAKE) -C py-polars venv; \
source py-polars/venv/bin/activate; \
$(MAKE) -C polars test; \
$(MAKE) -C py-polars test-with-cov; \
cargo llvm-cov --no-run --lcov --output-path coverage.lcov; \
"
6 changes: 5 additions & 1 deletion py-polars/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ test: venv
$(PYTHON) -m pytest tests

test-with-cov: venv
@cd tests && ../$(PYTHON) -m pytest --cov=polars --cov-fail-under=90 --import-mode=importlib
@cd tests && ../$(PYTHON) -m pytest \
--cov=polars \
--cov-report xml \
--cov-fail-under=90 \
--import-mode=importlib

doctest:
cd tests && ../$(PYTHON) run_doc_examples.py
Expand Down

0 comments on commit 519096f

Please sign in to comment.