Skip to content

Commit a6cae20

Browse files
committed
Add GitHub Actions workflow for pytest
- Run tests on Python 3.9, 3.10, 3.11, 3.12 - Trigger on push to main/develop/add-ci branches and PRs - Include coverage reporting and caching for faster builds
1 parent 8d5fd05 commit a6cae20

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

.github/workflows/test.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [ main, develop, add-ci ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: ['3.9', '3.10', '3.11', '3.12']
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Set up Python ${{ matrix.python-version }}
20+
uses: actions/setup-python@v4
21+
with:
22+
python-version: ${{ matrix.python-version }}
23+
24+
- name: Cache pip dependencies
25+
uses: actions/cache@v3
26+
with:
27+
path: ~/.cache/pip
28+
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
29+
restore-keys: |
30+
${{ runner.os }}-pip-
31+
32+
- name: Install dependencies
33+
run: |
34+
python -m pip install --upgrade pip
35+
pip install -r requirements.txt
36+
pip install -e .
37+
38+
- name: Run tests with pytest
39+
run: |
40+
pytest tests/ -v --tb=short
41+
42+
- name: Run tests with coverage
43+
if: matrix.python-version == '3.12'
44+
run: |
45+
pip install pytest-cov
46+
pytest tests/ --cov=tesseract_sim --cov-report=xml --cov-report=term-missing
47+
48+
- name: Upload coverage to Codecov
49+
if: matrix.python-version == '3.12'
50+
uses: codecov/codecov-action@v3
51+
with:
52+
file: ./coverage.xml
53+
flags: unittests
54+
name: codecov-umbrella
55+
fail_ci_if_error: false

0 commit comments

Comments
 (0)