@@ -3,50 +3,193 @@ name: CI
3
3
4
4
on :
5
5
push :
6
- branches : [trunk]
7
- tags : ["*"]
6
+ branches : [main]
8
7
pull_request :
9
- branches : [trunk]
10
8
workflow_dispatch :
11
9
12
10
env :
13
11
FORCE_COLOR : " 1"
14
- PIP_DISABLE_VERSION_CHECK : " 1"
12
+ PIP_DISABLE_PIP_VERSION_CHECK : " 1"
13
+ PIP_NO_PYTHON_VERSION_WARNING : " 1"
15
14
16
- permissions :
17
- contents : read
15
+ permissions : {}
18
16
19
17
jobs :
20
- tests :
21
- name : nox on ${{ matrix.python-version }}
18
+ build-package :
19
+ name : Build and verify package
22
20
runs-on : ubuntu-latest
23
21
22
+ steps :
23
+ - uses : actions/checkout@v4
24
+ with :
25
+ fetch-depth : 0
26
+
27
+ - uses : hynek/build-and-inspect-python-package@v2
28
+ id : baipp
29
+
30
+ outputs :
31
+ python-versions : ${{ steps.baipp.outputs.supported_python_classifiers_json_array }}
32
+
33
+ tests :
34
+ name : Tests on ${{ matrix.python-version }}
35
+ needs : build-package
36
+ runs-on : ubuntu-latest
24
37
strategy :
25
38
fail-fast : false
26
39
matrix :
27
- python-version : ["3.8", "3.9", "3.10", "3.11", "3.12"]
40
+ python-version : ${{ fromJson(needs.build-package.outputs.python-versions) }}
28
41
29
42
steps :
30
- - name : Harden Runner
31
- uses : step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
32
- with :
33
- disable-sudo : true
34
- egress-policy : block
35
- allowed-endpoints : >
36
- docs.python.org:443
37
- files.pythonhosted.org:443
38
- github.com:443
39
- pypi.org:443
40
- - uses : actions/checkout@v4
43
+ - name : Download pre-built packages
44
+ uses : actions/download-artifact@v4
45
+ with :
46
+ name : Packages
47
+ path : dist
48
+ - run : tar xf dist/*.tar.gz --strip-components=1
41
49
- uses : actions/setup-python@v5
42
50
with :
43
51
python-version : ${{ matrix.python-version }}
44
- - name : " Install dependencies"
52
+ allow-prereleases : true
53
+ - name : Install test runner
45
54
run : |
46
55
python -VV
47
56
python -Im site
48
- python -Im pip install --upgrade pip setuptools wheel
49
57
python -Im pip install --upgrade nox
50
58
python -Im nox --version
51
- - name : " Run CI suite with nox"
52
- run : " python -Im nox --non-interactive --error-on-external-run --python ${{ matrix.python-version }}"
59
+ - name : Run tests
60
+ run : " python -Im nox --non-interactive --error-on-external-run --tag tests --python ${{ matrix.python-version }}"
61
+ - name : Upload coverage data
62
+ uses : actions/upload-artifact@v4
63
+ with :
64
+ name : coverage-data-${{ matrix.python-version }}
65
+ path : .coverage.*
66
+ include-hidden-files : true
67
+ if-no-files-found : ignore
68
+
69
+
70
+ coverage :
71
+ name : Combine and check coverage
72
+ needs : tests
73
+ runs-on : ubuntu-latest
74
+
75
+ steps :
76
+ - uses : actions/checkout@v4
77
+ - uses : actions/setup-python@v5
78
+ with :
79
+ python-version : " 3.12"
80
+ - uses : hynek/setup-cached-uv@v2
81
+ - run : python -Im pip install --system --upgrade coverage[toml]
82
+ - uses : actions/download-artifact@v4
83
+ with :
84
+ pattern : coverage-data-*
85
+ merge-multiple : true
86
+
87
+ - name : Combine coverage and fail under 100%
88
+ run : |
89
+ python -Im pip install --upgrade "coverage[toml]"
90
+ coverage combine
91
+ coverage html --skip-covered --skip-empty
92
+ # Report and write to summary.
93
+ coverage report --format=markdown >> $GITHUB_STEP_SUMMARY
94
+ # Report again and fail if under 100%.
95
+ coverage report --fail-under=100
96
+
97
+ - name : Upload HTML report if check failed.
98
+ uses : actions/upload-artifact@v4
99
+ with :
100
+ name : html-report
101
+ path : htmlcov
102
+ if : ${{ failure() }}
103
+
104
+
105
+ docs :
106
+ name : Check documentation
107
+ needs : build-package
108
+ runs-on : ubuntu-latest
109
+ steps :
110
+ - name : Download pre-built packages
111
+ uses : actions/download-artifact@v4
112
+ with :
113
+ name : Packages
114
+ path : dist
115
+ - run : tar xf dist/*.tar.gz --strip-components=1
116
+ - uses : actions/setup-python@v5
117
+ with :
118
+ python-version : " 3.12"
119
+ - name : Set up test runner
120
+ - run : |
121
+ python -VV
122
+ python -Im site
123
+ python -Im pip install --upgrade nox
124
+ python -Im nox --version
125
+ - name : Run documentation checks
126
+ run : " python -Im nox --non-interactive --error-on-external-run --tag docs"
127
+
128
+
129
+ lint-format :
130
+ name : Lint code and check formatting
131
+ needs : build-package
132
+ runs-on : ubuntu-latest
133
+ steps :
134
+ - name : Download pre-built packages
135
+ uses : actions/download-artifact@v4
136
+ with :
137
+ name : Packages
138
+ path : dist
139
+ - run : tar xf dist/*.tar.gz --strip-components=1
140
+ - uses : actions/setup-python@v5
141
+ with :
142
+ python-version : " 3.12"
143
+ - name : Set up test runner
144
+ - run : |
145
+ python -VV
146
+ python -Im site
147
+ python -Im pip install --upgrade nox
148
+ python -Im nox --version
149
+ - name : Check code formatting
150
+ run : " python -Im nox --non-interactive --error-on-external-run --tag formatters --python 3.12"
151
+ - name : Lint code
152
+ run : " python -Im nox --non-interactive --error-on-external-run --tag linters --python 3.12"
153
+
154
+
155
+ check-package :
156
+ name : Additional package checks
157
+ needs : build-package
158
+ runs-on : ubuntu-latest
159
+ steps :
160
+ - name : Download pre-built packages
161
+ uses : actions/download-artifact@v4
162
+ with :
163
+ name : Packages
164
+ path : dist
165
+ - run : tar xf dist/*.tar.gz --strip-components=1
166
+ - uses : actions/setup-python@v5
167
+ with :
168
+ python-version : " 3.12"
169
+ - name : Set up test runner
170
+ - run : |
171
+ python -VV
172
+ python -Im site
173
+ python -Im pip install --upgrade nox
174
+ python -Im nox --version
175
+ - name : Check package
176
+ run : " python -Im nox --non-interactive --error-on-external-run --tag packaging --python 3.12"
177
+
178
+
179
+ required-checks-pass :
180
+ name : Ensure required checks pass for branch protection
181
+ if : always()
182
+
183
+ needs :
184
+ - check-package
185
+ - coverage
186
+ - docs
187
+ - lint-format
188
+
189
+ runs-on : ubuntu-latest
190
+
191
+ steps :
192
+ - name : Decide whether the jobs succeeded or failed
193
+ uses : re-actors/alls-green@release/v1
194
+ with :
195
+ jobs : ${{ toJSON(needs) }}
0 commit comments