-
Notifications
You must be signed in to change notification settings - Fork 2
245 lines (210 loc) Β· 8.06 KB
/
Copy pathci.yaml
File metadata and controls
245 lines (210 loc) Β· 8.06 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
name: π Continuous Integration
env:
COLUMNS: 120 # Makes the error summary table printed by pytest-pretty much easier to read
PROJECT_NAME: "strawchemy"
UV_PYTHON_INSTALL_DIR: ${{ github.workspace }}/.uv-python
on:
push:
branches: [ main, ci/*, dependabot/*, renovate/* ]
tags:
- "v*.*.*"
pull_request:
branches: [ main ]
concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
pre:
runs-on: ubuntu-latest
# Map a step output to a job output. Also skip the redundant branch run for
# cocogitto version-bump commits; the tag push still runs CI because the jobs
# below bypass should_skip when github.ref_type == 'tag'.
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip == 'true' || (github.event_name == 'push' && contains(github.event.head_commit.message, '[ci-skip]')) }}
steps:
- name: Skip check
id: skip_check
uses: step-security/skip-duplicate-actions@4eef6ae57f2ca5ea100e5c1da2ead9138483f53c # v5
with:
concurrent_skipping: "never"
skip_after_successful_duplicate: "true"
paths_ignore: '["**/**.md", "**/.vscode/**", "**/.idea/**"]'
paths: '["src/**", "tests/**", "uv.lock", "pyproject.toml", ".github/workflows/ci.yaml", "noxfile.py", "mise.toml"]'
generate-jobs-tests:
name: π» Generate test matrix
needs: pre
if: github.ref_type == 'tag' || needs.pre.outputs.should_skip != 'true'
runs-on: ubuntu-latest
outputs:
sessions: ${{ steps.set-matrix.outputs.sessions }}
steps:
- name: Checkout repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
- name: Setup mise
uses: jdx/mise-action@dba19683ed58901619b14f395a24841710cb4925 # v4
with:
cache: true
log_level: debug
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup uv
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
with:
enable-cache: true
- name: Generate test matrix
id: set-matrix
shell: bash
run: |
echo sessions=$(mise run ci:test-matrix) | tee --append $GITHUB_OUTPUT
tests:
name: π¬ ${{ matrix.session.job_name }}
needs: [ pre, generate-jobs-tests ]
if: github.ref_type == 'tag' || needs.pre.outputs.should_skip != 'true'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
session: ${{ fromJson(needs.generate-jobs-tests.outputs.sessions) }}
steps:
- name: Checkout repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
- name: Set up Docker Buildx
if: contains(matrix.session.tags, 'docker')
id: docker-buildx
uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4
- name: nox cache
id: cache
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
with:
path: |
~/.nox
.nox
${{ github.workspace }}/.uv-python
key:
${{ runner.os }}-nox-${{ matrix.session.session }}-${{
hashFiles('**/uv.lock') }}-${{ hashFiles('**/noxfile.py') }}
restore-keys: |
${{ runner.os }}-nox-${{ matrix.session.session }}
- name: Setup uv
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
with:
enable-cache: true
- name: Setup mise
uses: jdx/mise-action@dba19683ed58901619b14f395a24841710cb4925 # v4
with:
cache: true
log_level: debug
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Run tests
run: mise run ci:test "${{ matrix.session.session }}"
- name: Rename coverage and junit files
run: |
mv .coverage* .coverage.${{ matrix.session.session }}
mv junit* junit-${{ matrix.session.session }}.xml
- name: Upload coverage data
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
id: upload-coverage-data
if: ${{ always() }}
with:
name: coverage-${{ matrix.session.session }}
path: .coverage.${{ matrix.session.session }}
include-hidden-files: true
- name: Upload test results data
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
id: upload-test-results-data
if: ${{ always() }}
with:
name: test-results-${{ matrix.session.session }}
path: junit-${{ matrix.session.session }}.xml
upload-coverage:
name: π Upload Coverage
needs: [ tests, generate-jobs-tests ]
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
- name: Download test artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
pattern: coverage-*
merge-multiple: true
- uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6
with:
python-version: "3.14"
- name: Combine coverage files
run: |
python -Im pip install coverage covdefaults
python -Im coverage combine
python -Im coverage xml -i
- name: Upload coverage to Codeocv
id: upload-coverage
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7
with:
name: ${{env.PROJECT_NAME}}-tests
report_type: coverage
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
verbose: true
upload-test-results:
name: π Upload test results
needs: [ tests, generate-jobs-tests ]
runs-on: ubuntu-latest
strategy:
matrix:
session: ${{ fromJson(needs.generate-jobs-tests.outputs.sessions) }}
steps:
- name: Checkout repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
- name: Download test artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
pattern: test-results-*
- name: Upload test results to Codecov
id: upload-test-results
if: ${{ !cancelled() }}
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7
with:
name: ${{env.PROJECT_NAME}}-test-results
report_type: test_results
token: ${{ secrets.CODECOV_TOKEN }}
flags: ${{ matrix.session.session }}
verbose: true
lint:
name: β¨ Lint
needs: pre
if: github.ref_type == 'tag' || needs.pre.outputs.should_skip != 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
- name: Setup mise
uses: jdx/mise-action@dba19683ed58901619b14f395a24841710cb4925 # v4
with:
cache: true
log_level: debug
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup uv
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
with:
enable-cache: true
- name: Install dependencies
run: mise run uv:install
- name: Run linting
run: mise run lint
# Ensure the workflow is successful only if all job in matrixes are successful
result:
name: β
Result
if: (github.ref_type == 'tag' || needs.pre.outputs.should_skip != 'true') && always()
runs-on: ubuntu-latest
needs:
- pre
- tests
- lint
steps:
- name: Mark workflow as failed if lint or test did not pass or were cancelled
if: contains(fromJson('["failure", "cancelled"]'), needs.tests.result) || contains(fromJson('["failure", "cancelled"]'), needs.lint.result)
run: exit 1
- name: Invoke release workflow
if: github.ref_type == 'tag'
uses: benc-uk/workflow-dispatch@e2e5e9a103e331dad343f381a29e654aea3cf8fc # v1
with:
workflow: π Continuous Deployment