-
Notifications
You must be signed in to change notification settings - Fork 0
81 lines (79 loc) · 2.29 KB
/
ci.yaml
File metadata and controls
81 lines (79 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
name: CI
on:
pull_request:
push:
branches: [main]
permissions:
contents: read
jobs:
pre-commit:
name: Pre-commit Checks
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: 'pip'
- name: Cache pre-commit environments
uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
restore-keys: |
pre-commit-
- name: Install pre-commit
run: |
python -m pip install --upgrade pip
pip install pre-commit
- name: Run pre-commit (fast path)
id: precommit_fast
run: |
pre-commit run --all-files
- name: Generate pre-commit log (only on failure)
if: failure() && steps.precommit_fast.outcome == 'failure'
run: |
chmod +x template/scripts/run-precommit.sh
./template/scripts/run-precommit.sh
- name: Upload pre-commit log artifact (only on failure)
if: failure() && steps.precommit_fast.outcome == 'failure'
uses: actions/upload-artifact@v4
with:
name: pre-commit-log
path: artifacts/pre-commit.log
retention-days: 7
tests:
name: Unit Tests
runs-on: ubuntu-latest
needs: [pre-commit]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
# Install repo dependencies if present
if [ -f requirements.txt ]; then
pip install -r requirements.txt
fi
if [ -f requirements-dev.txt ]; then
pip install -r requirements-dev.txt
fi
# Only install pytest if tests exist
if [ -d tests ]; then
pip install pytest
fi
- name: Run pytest (if tests exist)
run: |
if [ -d tests ]; then
pytest -q
else
echo "No tests/ directory found; skipping pytest."
fi