Skip to content

Commit ad60635

Browse files
committed
feat: Add Github action to install & test on different Python env versions
1 parent 82acd3c commit ad60635

1 file changed

Lines changed: 69 additions & 0 deletions

File tree

.github/workflows/test.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches: [main, feat/action]
6+
pull_request:
7+
branches: [main]
8+
9+
# Cancel in-progress runs on new pushes to the same branch
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
test:
16+
name: Test (Python ${{ matrix.python-version }}, ${{ matrix.os }})
17+
runs-on: ${{ matrix.os }}
18+
strategy:
19+
# Run all matrix jobs in parallel; don't cancel others if one fails
20+
fail-fast: false
21+
matrix:
22+
os: [ubuntu-latest, macos-latest]
23+
python-version: ["3.10", "3.11", "3.12", "3.13"]
24+
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v4
28+
with:
29+
fetch-depth: 1 # Fetch only the latest commit for efficiency
30+
31+
- name: Set up Python ${{ matrix.python-version }}
32+
uses: actions/setup-python@v5
33+
with:
34+
python-version: ${{ matrix.python-version }}
35+
36+
- name: Upgrade pip and install build tools
37+
run: |
38+
python -m pip install --upgrade pip uv pre-commit
39+
40+
- name: Cache UV
41+
uses: actions/cache@v4
42+
with:
43+
path: |
44+
${{ runner.os == 'macOS' && '~/Library/Caches/uv' || '~/.cache/uv' }}
45+
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock', 'pyproject.toml') }}
46+
restore-keys: |
47+
uv-${{ runner.os }}-
48+
49+
- name: Install dev dependencies and run Copier template tests
50+
run: |
51+
make install
52+
make test
53+
54+
- name: Upload pytest artifacts (if generated)
55+
if: always() && (success() || failure())
56+
uses: actions/upload-artifact@v4
57+
with:
58+
name: pytest-results-${{ matrix.os }}-${{ matrix.python-version }}
59+
path: |
60+
.pytest_cache/
61+
htmlcov/
62+
.coverage
63+
retention-days: 7
64+
continue-on-error: true
65+
66+
- name: Print test summary
67+
if: always()
68+
run: |
69+
echo "Test run completed for Python ${{ matrix.python-version }} on ${{ matrix.os }}"

0 commit comments

Comments
 (0)