Skip to content

Commit 58572cb

Browse files
committed
Add CI workflow to run pytest
1 parent 730b13a commit 58572cb

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

.github/workflows/tests.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: CI — tests
2+
3+
on:
4+
push:
5+
branches:
6+
- '**' # run on pushes to any branch
7+
pull_request:
8+
branches:
9+
- main # run on PRs targeting main
10+
11+
jobs:
12+
test:
13+
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
python: [3.8] # add other versions if wanted, e.g. 3.9, 3.10
17+
steps:
18+
- name: Checkout repo
19+
uses: actions/checkout@v4
20+
21+
- name: Set up Python ${{ matrix.python }}
22+
uses: actions/setup-python@v4
23+
with:
24+
python-version: ${{ matrix.python }}
25+
26+
- name: Cache pip
27+
uses: actions/cache@v4
28+
with:
29+
path: ~/.cache/pip
30+
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}
31+
restore-keys: |
32+
${{ runner.os }}-pip-
33+
34+
- name: Install dependencies
35+
run: |
36+
python -m pip install --upgrade pip
37+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
38+
# if you have dev requirements for testing, install them too
39+
if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi
40+
# install package in editable mode so tests import src/ correctly
41+
pip install -e .
42+
43+
- name: Run pytest (produce junit xml)
44+
run: |
45+
mkdir -p test-results
46+
pytest -q --junitxml=test-results/junit.xml || true
47+
continue-on-error: false
48+
49+
- name: Upload pytest junit xml
50+
uses: actions/upload-artifact@v4
51+
with:
52+
name: junit-xml
53+
path: test-results/junit.xml
54+
55+
- name: Upload test logs (stdout/stderr)
56+
if: failure()
57+
uses: actions/upload-artifact@v4
58+
with:
59+
name: pytest-logs
60+
path: |
61+
pytest.log
62+
test-results/junit.xml

0 commit comments

Comments
 (0)