-
Notifications
You must be signed in to change notification settings - Fork 0
274 lines (230 loc) Β· 7.4 KB
/
ci.yml
File metadata and controls
274 lines (230 loc) Β· 7.4 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
name: CI
on:
push:
branches: [main]
paths:
- 'src/**'
- 'tests/**'
- 'pyproject.toml'
- 'uv.lock'
- '.github/workflows/ci.yml'
pull_request:
branches: [main]
paths:
- 'src/**'
- 'tests/**'
- 'pyproject.toml'
- 'uv.lock'
- '.github/workflows/ci.yml'
workflow_dispatch:
inputs:
python_version:
description: 'Python version to test'
required: false
default: 'all'
type: choice
options:
- 'all'
- '3.10'
- '3.11'
- '3.12'
permissions:
contents: read
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
env:
FORCE_COLOR: 1
UV_SYSTEM_PYTHON: 1
jobs:
# Job 1: Lint and type checking
lint:
name: Lint & Type Check
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.11'
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
version: 'latest'
enable-cache: true
- name: Cache dependencies
uses: actions/cache@v5
with:
path: |
~/.cache/uv
.venv
key: lint-${{ runner.os }}-${{ hashFiles('**/uv.lock') }}
restore-keys: |
lint-${{ runner.os }}-
- name: Install dependencies
run: |
uv sync --frozen --extra dev
- name: Run ruff format check
run: |
echo "π¨ Checking code formatting..."
uv run ruff format --check .
echo "β
Format check passed"
- name: Run ruff linting
run: |
echo "π Running linting checks..."
uv run ruff check .
echo "β
Linting passed"
- name: Run mypy type checking
continue-on-error: true
run: |
echo "π Running type checking (informational only)..."
uv run mypy src/taskrepo || echo "β οΈ Type checking found issues (non-blocking)"
# Job 2: Test matrix across Python versions
test:
name: Test (Python ${{ matrix.python-version }})
runs-on: ubuntu-latest
needs: lint
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
python-version: ${{ (github.event_name == 'workflow_dispatch' && github.event.inputs.python_version != 'all') && fromJson(format('["{0}"]', github.event.inputs.python_version)) || fromJson('["3.10", "3.11", "3.12"]') }}
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
version: 'latest'
enable-cache: true
- name: Cache dependencies
uses: actions/cache@v5
with:
path: |
~/.cache/uv
.venv
key: test-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/uv.lock') }}
restore-keys: |
test-${{ runner.os }}-${{ matrix.python-version }}-
- name: Install dependencies
run: |
uv sync --frozen --extra dev
- name: Run unit tests
run: |
echo "π§ͺ Running unit tests..."
uv run pytest tests/unit -v
echo "β
Unit tests passed"
- name: Run integration tests
run: |
echo "π§ͺ Running integration tests..."
# Allow empty test collection (exit code 5)
uv run pytest tests/integration -v || [ $? -eq 5 ] && echo "β
Integration tests passed (or no tests found)"
# Job 3: Coverage reporting
coverage:
name: Coverage Report
runs-on: ubuntu-latest
needs: lint
timeout-minutes: 15
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.11'
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
version: 'latest'
enable-cache: true
- name: Cache dependencies
uses: actions/cache@v5
with:
path: |
~/.cache/uv
.venv
key: coverage-${{ runner.os }}-${{ hashFiles('**/uv.lock') }}
restore-keys: |
coverage-${{ runner.os }}-
- name: Install dependencies
run: |
uv sync --frozen --extra dev
- name: Run tests with coverage
run: |
echo "π Running full test suite with coverage..."
uv run pytest tests/ -v --cov=taskrepo --cov-report=term-missing --cov-report=xml
echo "β
Coverage report generated"
- name: Upload coverage artifact
uses: actions/upload-artifact@v6
with:
name: coverage-report
path: coverage.xml
retention-days: 30
# Job 4: Build verification
build:
name: Build Package
runs-on: ubuntu-latest
needs: lint
timeout-minutes: 10
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.11'
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
version: 'latest'
enable-cache: true
- name: Install dependencies
run: |
uv sync --frozen --extra dev
- name: Build package
run: |
echo "π¦ Building package..."
uv build
echo "β
Package built successfully"
- name: Verify package metadata
run: |
echo "π Verifying package contents..."
ls -lh dist/
uv run python -m tarfile -l dist/*.tar.gz
echo "β
Package verification complete"
- name: Upload build artifacts
uses: actions/upload-artifact@v6
with:
name: dist-packages
path: dist/
retention-days: 7
# Summary job
ci-summary:
name: CI Summary
runs-on: ubuntu-latest
needs: [lint, test, coverage, build]
if: always()
steps:
- name: Generate summary
run: |
echo "## π CI Pipeline Results" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Job | Status |" >> $GITHUB_STEP_SUMMARY
echo "|-----|--------|" >> $GITHUB_STEP_SUMMARY
echo "| Lint & Type Check | ${{ needs.lint.result == 'success' && 'β
Passed' || 'β Failed' }} |" >> $GITHUB_STEP_SUMMARY
echo "| Tests | ${{ needs.test.result == 'success' && 'β
Passed' || 'β Failed' }} |" >> $GITHUB_STEP_SUMMARY
echo "| Coverage | ${{ needs.coverage.result == 'success' && 'β
Passed' || 'β Failed' }} |" >> $GITHUB_STEP_SUMMARY
echo "| Build | ${{ needs.build.result == 'success' && 'β
Passed' || 'β Failed' }} |" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
ALL_PASSED=${{ needs.lint.result == 'success' && needs.test.result == 'success' && needs.coverage.result == 'success' && needs.build.result == 'success' }}
if [[ "$ALL_PASSED" == "true" ]]; then
echo "π **All CI checks passed!**" >> $GITHUB_STEP_SUMMARY
else
echo "β οΈ **Some CI checks failed - please review the logs above**" >> $GITHUB_STEP_SUMMARY
fi