Skip to content

Commit d31a028

Browse files
committed
feat(ci): Initial attempt at adding test coverage to project
1 parent 018f581 commit d31a028

2 files changed

Lines changed: 74 additions & 4 deletions

File tree

.github/workflows/CI.yml

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,15 @@ jobs:
5555
with:
5656
version: "1.11"
5757

58+
- name: Cache python dependencies
59+
uses: actions/cache@v4
60+
with:
61+
path: |
62+
.venv
63+
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }}
64+
restore-keys: |
65+
${{ runner.os }}-pip-
66+
5867
- name: Run and Compare Benchmarks
5968
run: |
6069
# Install python dependencies
@@ -81,14 +90,14 @@ jobs:
8190
git stash pop
8291
- name: Commit benchmark results
8392
if: startsWith(github.ref, 'refs/tags/')
84-
uses: stefanzweifel/git-auto-commit-action@v4
93+
uses: stefanzweifel/git-auto-commit-action@v5
8594
with:
8695
commit_message: "docs(benchmarks): update benchmark results"
8796
file_pattern: BENCHMARKS.md
8897

8998
- name: Post benchmark results to PR
9099
if: github.event_name == 'pull_request'
91-
uses: actions/github-script@v6
100+
uses: actions/github-script@v7
92101
with:
93102
github-token: ${{ secrets.GITHUB_TOKEN }}
94103
script: |
@@ -142,7 +151,7 @@ jobs:
142151
run: cargo install cross
143152

144153
- name: Set up cargo cache
145-
uses: actions/cache@v3
154+
uses: actions/cache@v4
146155
with:
147156
path: |
148157
~/.cargo/bin/
@@ -158,6 +167,15 @@ jobs:
158167
with:
159168
python-version: "3.13"
160169

170+
- name: Cache python dependencies
171+
uses: actions/cache@v4
172+
with:
173+
path: |
174+
.venv
175+
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }}
176+
restore-keys: |
177+
${{ runner.os }}-pip-
178+
161179
- name: Check formatting
162180
run: cargo fmt --all -- --check
163181

@@ -256,6 +274,15 @@ jobs:
256274
path: dist
257275
merge-multiple: true
258276

277+
- name: Cache python dependencies
278+
uses: actions/cache@v4
279+
with:
280+
path: |
281+
.venv
282+
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('**/pyproject.toml') }}
283+
restore-keys: |
284+
${{ runner.os }}-pip-${{ matrix.python-version }}-
285+
259286
- name: Install wheel and test dependencies
260287
shell: bash
261288
run: |
@@ -358,6 +385,15 @@ jobs:
358385
with:
359386
python-version: "3.13"
360387

388+
- name: Cache python dependencies
389+
uses: actions/cache@v4
390+
with:
391+
path: |
392+
.venv
393+
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }}
394+
restore-keys: |
395+
${{ runner.os }}-pip-
396+
361397
- name: Run Python example
362398
shell: bash
363399
run: |
@@ -427,7 +463,7 @@ jobs:
427463
echo "EOF" >> $GITHUB_OUTPUT
428464
429465
- name: Create Release
430-
uses: softprops/action-gh-release@v1
466+
uses: softprops/action-gh-release@v2
431467
with:
432468
tag_name: ${{ env.latest_tag }}
433469
name: "Release ${{ env.latest_tag }}"

.github/workflows/coverage.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Code Coverage
2+
on: [push, pull_request]
3+
jobs:
4+
coverage:
5+
runs-on: ubuntu-latest
6+
steps:
7+
- name: Checkout repository
8+
uses: actions/checkout@v4
9+
10+
- name: Install rust
11+
uses: dtolnay/rust-toolchain@stable
12+
13+
- name: Cache dependencies
14+
uses: actions/cache@v3
15+
with:
16+
path: |
17+
~/.cargo/bin/
18+
~/.cargo/registry/index/
19+
~/.cargo/registry/cache/
20+
~/.cargo/git/db/
21+
target/
22+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
23+
24+
- name: Install cargo-tarpaulin
25+
run: cargo install cargo-tarpaulin --version 0.26.0
26+
27+
- name: Run tests and generate coverage report
28+
run: cargo tarpaulin --all-features --workspace --out Xml --output-dir ./coverage --ignore-tests
29+
30+
- name: Upload coverage to Codecov
31+
uses: codecov/codecov-action@v3
32+
with:
33+
files: ./coverage/cobertura.xml
34+
fail_ci_if_error: true

0 commit comments

Comments
 (0)