-
Notifications
You must be signed in to change notification settings - Fork 1
222 lines (190 loc) Β· 7.1 KB
/
ci.yaml
File metadata and controls
222 lines (190 loc) Β· 7.1 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
name: π Tests and linting
env:
COLUMNS: 120 # Makes the error summary table printed by pytest-pretty much easier to read
PROJECT_NAME: "strawchemy"
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
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- name: Skip check
id: skip_check
uses: fkirc/skip-duplicate-actions@f75f66ce1886f00957d99748a42c724f4330bdcf # v5
with:
concurrent_skipping: "never"
skip_after_successful_duplicate: "true"
paths_ignore: '["**/**.md", "**/.vscode/**", "**/.dockerignore", "Makefile"]'
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@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
- name: Setup mise
uses: jdx/mise-action@146a28175021df8ca24f8ee1828cc2a60f980bd5 # v3
with:
cache: true
log_level: debug
- 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@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
- name: Set up Docker Buildx
if: contains(matrix.session.tags, 'docker')
id: docker-buildx
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3
- name: Pip and nox cache
id: cache
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5
with:
path: |
~/.cache
~/.nox
.nox
key:
${{ runner.os }}-nox-${{ matrix.session.session }}-${{ env.pythonLocation }}-${{
hashFiles('**/uv.lock') }}-${{ hashFiles('**/noxfile.py') }}
restore-keys: |
${{ runner.os }}-nox-${{ matrix.session.session }}-${{ env.pythonLocation }}
- name: Setup mise
uses: jdx/mise-action@146a28175021df8ca24f8ee1828cc2a60f980bd5 # v3
with:
cache: true
log_level: debug
- 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@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
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@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
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@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
- name: Download test artifacts
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7
with:
pattern: coverage-*
merge-multiple: true
- uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6
with:
python-version: "3.13"
- 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@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5
with:
name: ${{env.PROJECT_NAME}}-tests
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@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
- name: Download test artifacts
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7
with:
pattern: test-results-*
- name: Upload test results to Codecov
id: upload-test-results
if: ${{ !cancelled() }}
uses: codecov/test-results-action@47f89e9acb64b76debcd5ea40642d25a4adced9f # v1
with:
name: ${{env.PROJECT_NAME}}-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@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
- name: Setup mise
uses: jdx/mise-action@146a28175021df8ca24f8ee1828cc2a60f980bd5 # v3
with:
cache: true
log_level: debug
- 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