Skip to content

Commit 6418790

Browse files
authored
Add coverage workflows for baseline and pull request coverage comparison (#307)
Fixes #305
1 parent f2e3ec7 commit 6418790

File tree

2 files changed

+491
-0
lines changed

2 files changed

+491
-0
lines changed
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
name: Coverage Baseline
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
coverage:
13+
name: Coverage Baseline
14+
runs-on: ${{ matrix.os }}
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
include:
19+
- os: ubuntu-latest
20+
target: x86_64-unknown-linux-musl
21+
- os: windows-latest
22+
target: x86_64-pc-windows-msvc
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
27+
- name: Set Python to PATH
28+
uses: actions/setup-python@v5
29+
with:
30+
python-version: "3.12"
31+
32+
- name: Add Conda to PATH (Windows)
33+
if: startsWith(matrix.os, 'windows')
34+
run: |
35+
$path = $env:PATH + ";" + $env:CONDA + "\condabin"
36+
echo "PATH=$path" >> $env:GITHUB_ENV
37+
38+
- name: Add Conda to PATH (Linux)
39+
if: startsWith(matrix.os, 'ubuntu')
40+
run: echo "PATH=$PATH:$CONDA/condabin" >> $GITHUB_ENV
41+
shell: bash
42+
43+
- name: Check Conda version
44+
run: conda info --all
45+
46+
- name: Create Conda Environments
47+
run: |
48+
conda create -n test-env1 python=3.12 -y
49+
conda create -n test-env-no-python -y
50+
conda create -p ./prefix-envs/.conda1 python=3.12 -y
51+
conda create -p ./prefix-envs/.conda-nopy -y
52+
53+
- name: Install pipenv
54+
run: pip install pipenv
55+
56+
- name: Check pipenv version
57+
run: pipenv --version
58+
59+
- name: Create a Pipenv Environment
60+
run: pipenv install
61+
62+
- name: Install virtualenvwrapper (Linux)
63+
if: startsWith(matrix.os, 'ubuntu')
64+
run: |
65+
pip install virtualenvwrapper
66+
echo "WORKON_HOME=$HOME/.virtualenvs" >> $GITHUB_ENV
67+
mkdir -p $HOME/.virtualenvs
68+
source virtualenvwrapper.sh
69+
mkvirtualenv venv_wrapper_env1
70+
shell: bash
71+
72+
- name: Install virtualenvwrapper-win (Windows)
73+
if: startsWith(matrix.os, 'windows')
74+
run: |
75+
pip install virtualenvwrapper-win
76+
echo "WORKON_HOME=$HOME/.virtualenvs" >> $GITHUB_ENV
77+
shell: bash
78+
79+
- name: Install pyenv (Windows)
80+
if: startsWith(matrix.os, 'windows')
81+
run: |
82+
choco install pyenv-win -y
83+
echo "PATH=$PATH;$HOME/.pyenv/pyenv-win/bin;$HOME/.pyenv/pyenv-win/shims" >> $GITHUB_ENV
84+
echo "PYENV_ROOT=$HOME/.pyenv" >> $GITHUB_ENV
85+
shell: bash
86+
87+
- name: Install pyenv and pyenv-virtualenv (Linux)
88+
if: startsWith(matrix.os, 'ubuntu')
89+
run: |
90+
curl https://pyenv.run | bash
91+
echo "PYENV_ROOT=$HOME/.pyenv" >> $GITHUB_ENV
92+
echo "PATH=$HOME/.pyenv/bin:$PATH" >> $GITHUB_ENV
93+
shell: bash
94+
95+
- name: Check Pyenv version
96+
run: pyenv --version
97+
shell: bash
98+
99+
- name: Install Pyenv Python(s) (Linux)
100+
if: startsWith(matrix.os, 'ubuntu')
101+
run: |
102+
pyenv install --list
103+
pyenv install 3.13:latest 3.12:latest 3.9:latest
104+
shell: bash
105+
106+
- name: Install Pyenv Python(s) (Windows)
107+
if: startsWith(matrix.os, 'windows')
108+
run: |
109+
pyenv install --list
110+
pyenv install 3.10.5 3.8.10
111+
shell: bash
112+
113+
- name: Create pyenv-virtualenv envs (Linux)
114+
if: startsWith(matrix.os, 'ubuntu')
115+
run: |
116+
eval "$(pyenv virtualenv-init -)"
117+
pyenv virtualenv 3.12 pyenv-virtualenv-env1
118+
shell: bash
119+
120+
- name: Create .venv
121+
run: python -m venv .venv
122+
shell: bash
123+
124+
- name: Create .venv2
125+
run: python -m venv .venv2
126+
shell: bash
127+
128+
- name: Install Pixi
129+
uses: prefix-dev/setup-pixi@v0.8.1
130+
with:
131+
run-install: false
132+
133+
- name: Create Pixi environments
134+
run: |
135+
pixi init
136+
pixi add python
137+
pixi add --feature dev python
138+
pixi project environment add --feature dev dev
139+
pixi install --environment dev
140+
shell: bash
141+
142+
- name: Rust Tool Chain setup
143+
uses: dtolnay/rust-toolchain@stable
144+
with:
145+
toolchain: stable
146+
targets: ${{ matrix.target }}
147+
148+
- name: Install cargo-llvm-cov
149+
uses: taiki-e/install-action@cargo-llvm-cov
150+
151+
- name: Cargo Fetch
152+
run: cargo fetch
153+
shell: bash
154+
155+
- name: Run Tests with Coverage
156+
run: cargo llvm-cov --features ci --lcov --output-path lcov.info -- --nocapture --test-threads=1
157+
env:
158+
RUST_BACKTRACE: 1
159+
RUST_LOG: trace
160+
shell: bash
161+
162+
- name: Upload Coverage Artifact
163+
uses: actions/upload-artifact@v4
164+
with:
165+
name: coverage-baseline-${{ matrix.os }}
166+
path: lcov.info
167+
retention-days: 90

0 commit comments

Comments
 (0)