-
Notifications
You must be signed in to change notification settings - Fork 10
283 lines (274 loc) · 9.85 KB
/
ci.yml
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
275
276
277
278
279
280
281
282
283
name: CI
on:
pull_request: {}
push:
branches:
- main
- '*.*.x'
tags:
- '*.*'
- '*.*.*'
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
jobs:
linux:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
PYTHON:
- {VERSION: "3.12", NOXSESSION: "flake"}
- {VERSION: "pypy-3.9", NOXSESSION: "tests-nocoverage", TONGSUO: "8.4.0"}
- {VERSION: "pypy-3.10", NOXSESSION: "tests-nocoverage", TONGSUO: "8.4.0"}
- {VERSION: "3.12", NOXSESSION: "tests-randomorder", TONGSUO: "8.4.0"}
- {VERSION: "3.12", NOXSESSION: "tests", TONGSUO: "8.4.0"}
timeout-minutes: 15
steps:
- uses: actions/[email protected]
timeout-minutes: 3
with:
persist-credentials: false
- name: Setup python
id: setup-python
uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5.1.1
with:
python-version: ${{ matrix.PYTHON.VERSION }}
cache: pip
cache-dependency-path: ci-constraints-requirements.txt
- name: Set TONGSUO_HOME
shell: bash
run: echo "TONGSUO_HOME=${GITHUB_WORKSPACE}/tongsuo${VERSION}" >> $GITHUB_ENV
env:
VERSION: ${{ matrix.PYTHON.TONGSUO }}
if: matrix.PYTHON.TONGSUO
- name: Build custom Tongsuo
working-directory: ${{ runner.temp }}
run: |
wget "https://github.com/Tongsuo-Project/Tongsuo/archive/refs/tags/${VERSION}.tar.gz"
tar zxf "${VERSION}.tar.gz"
pushd "Tongsuo-${VERSION}"
./config enable-ntls no-shared --prefix=${TONGSUO_HOME}
make -s -j4
make install_sw
popd
env:
VERSION: ${{ matrix.PYTHON.TONGSUO }}
if: matrix.PYTHON.TONGSUO
- run: python -m pip install -c ci-constraints-requirements.txt 'nox' 'tomli; python_version < "3.11"'
- name: Create nox environment
run: |
nox -v --install-only
env:
NOXSESSION: ${{ matrix.PYTHON.NOXSESSION }}
- name: Tests
run: |
nox --no-install -- --color=yes
env:
NOXSESSION: ${{ matrix.PYTHON.NOXSESSION }}
COLUMNS: 80
- run: ls -l .nox
- name: Cache nox output
uses: actions/cache/save@v4
if: ${{ matrix.PYTHON.NOXSESSION == 'tests' }} || ${{ matrix.PYTHON.NOXSESSION == 'tests-randomorder' }}
with:
path: .nox
key: ${{ runner.os }}-nox-${{ matrix.PYTHON.NOXSESSION }}
- uses: ./.github/actions/upload-coverage
macos:
runs-on: ${{ matrix.RUNNER.OS }}
strategy:
fail-fast: false
matrix:
RUNNER:
- {OS: 'macos-13', ARCH: 'x86_64'}
- {OS: 'macos-14', ARCH: 'arm64'}
PYTHON:
- {VERSION: "3.7", NOXSESSION: "tests-nocoverage"}
- {VERSION: "3.12", NOXSESSION: "tests"}
exclude:
# We only test latest Python on arm64. py37 won't work since there's no universal2 binary
- PYTHON: {VERSION: "3.7", NOXSESSION: "tests-nocoverage"}
RUNNER: {OS: 'macos-14', ARCH: 'arm64'}
timeout-minutes: 15
steps:
- uses: actions/[email protected]
timeout-minutes: 3
with:
persist-credentials: false
- name: Setup python
id: setup-python
uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5.1.1
with:
python-version: ${{ matrix.PYTHON.VERSION }}
cache: pip
cache-dependency-path: ci-constraints-requirements.txt
timeout-minutes: 3
- run: python -m pip install -c ci-constraints-requirements.txt 'nox' 'tomli; python_version < "3.11"'
- name: Set TONGSUO_HOME
shell: bash
run: echo "TONGSUO_HOME=${GITHUB_WORKSPACE}/tongsuo${VERSION}" >> $GITHUB_ENV
env:
VERSION: 8.4.0
- name: Build custom Tongsuo
run: |
wget "https://github.com/Tongsuo-Project/Tongsuo/archive/refs/tags/${VERSION}.tar.gz"
tar zxf "${VERSION}.tar.gz"
pushd "Tongsuo-${VERSION}"
./config enable-ntls no-shared --prefix=${TONGSUO_HOME}
make -s -j4
make install_sw
popd
env:
VERSION: 8.4.0
- name: Build nox environment
run: |
nox -v --install-only
env:
NOXSESSION: ${{ matrix.PYTHON.NOXSESSION }}
- name: Tests
run: |
# delete openssl/include installed in macos-12, fix cffi compile failed
# rm -rf /usr/local/opt/[email protected]/include
nox --no-install -- --color=yes
env:
NOXSESSION: ${{ matrix.PYTHON.NOXSESSION }}
COLUMNS: 80
- uses: ./.github/actions/upload-coverage
windows:
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
WINDOWS:
- { ARCH: 'x86', WINDOWS: 'win32', CONFIG: 'VC-WIN32' }
- { ARCH: 'x64', WINDOWS: 'win64', CONFIG: 'VC-WIN64A' }
PYTHON:
- {VERSION: "3.7", NOXSESSION: "tests-nocoverage", TONGSUO: "8.4.0"}
- {VERSION: "3.12", NOXSESSION: "tests", TONGSUO: "8.4.0"}
JOB_NUMBER: [0, 1, 2]
timeout-minutes: 15
steps:
- uses: actions/[email protected]
timeout-minutes: 3
with:
persist-credentials: false
- run: choco install -y winrar
- uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.WINDOWS.WINDOWS }}
- uses: ilammy/setup-nasm@v1
with:
platform: ${{ matrix.WINDOWS.WINDOWS }}
- uses: shogo82148/actions-setup-perl@v1
- name: Setup python
id: setup-python
uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5.1.1
with:
python-version: ${{ matrix.PYTHON.VERSION }}
architecture: ${{ matrix.WINDOWS.ARCH }}
cache: pip
cache-dependency-path: ci-constraints-requirements.txt
timeout-minutes: 3
- run: python -m pip install -c ci-constraints-requirements.txt "nox" "tomli; python_version < '3.11'"
- name: Export env
shell: bash
run: |
echo "TONGSUO_VERSION=${VERSION}" >> $GITHUB_ENV
echo "TONGSUO_HOME=${GITHUB_WORKSPACE}\tongsuo${VERSION}" >> $GITHUB_ENV
env:
VERSION: ${{ matrix.PYTHON.TONGSUO }}
- name: Download Tongsuo source
run: |
wget "https://github.com/Tongsuo-Project/Tongsuo/archive/refs/tags/${env:TONGSUO_VERSION}.tar.gz" -OutFile "${env:TONGSUO_VERSION}.tar.gz"
shell: powershell
- run: '"C:\Program Files\WinRAR\WinRAR.exe" -INUL x ${{ matrix.PYTHON.TONGSUO }}.tar.gz'
shell: cmd
- name: Build custom Tongsuo
shell: cmd
run: |
pushd "Tongsuo-${{ matrix.PYTHON.TONGSUO }}"
mkdir _build
pushd _build
perl ..\Configure no-makedepend no-shared ${{ matrix.WINDOWS.CONFIG }} --prefix=%TONGSUO_HOME%
nmake /S
nmake install_sw
popd
popd
- name: Build nox environment
run: nox -v --install-only
env:
NOXSESSION: ${{ matrix.PYTHON.NOXSESSION }}
- name: Tests
run: |
nox --no-install -- --color=yes
env:
NOXSESSION: ${{ matrix.PYTHON.NOXSESSION }}
COLUMNS: 80
- uses: ./.github/actions/upload-coverage
all-green:
# https://github.community/t/is-it-possible-to-require-all-github-actions-tasks-to-pass-without-enumerating-them/117957/4?u=graingert
runs-on: ubuntu-latest
needs: [linux, macos, windows]
if: ${{ always() }}
timeout-minutes: 3
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
timeout-minutes: 3
with:
persist-credentials: false
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe
with:
jobs: ${{ toJSON(needs) }}
- name: Setup python
if: ${{ always() }}
uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5.1.1
with:
python-version: '3.12'
cache: pip
cache-dependency-path: ci-constraints-requirements.txt
timeout-minutes: 3
- run: pip install -c ci-constraints-requirements.txt coverage[toml]
if: ${{ always() }}
- name: Download coverage data
if: ${{ always() }}
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
pattern: coverage-data-*
merge-multiple: true
- name: Restore nox output
uses: actions/cache/restore@v4
with:
path: .nox
key: ${{ runner.os }}-nox
- run: ls -l .nox
- name: Combine coverage and fail if it's <85%.
if: ${{ always() }}
id: combinecoverage
run: |
set +e
python -m coverage combine
echo "## Python Coverage" >> $GITHUB_STEP_SUMMARY
python -m coverage report -m --fail-under=85 > COV_REPORT
COV_EXIT_CODE=$?
cat COV_REPORT
if [ $COV_EXIT_CODE -ne 0 ]; then
echo "🚨 Python Coverage failed. Under 85" | tee -a $GITHUB_STEP_SUMMARY
fi
echo '```' >> $GITHUB_STEP_SUMMARY
cat COV_REPORT >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
exit $COV_EXIT_CODE
- name: Create coverage HTML
run: python -m coverage html
if: ${{ failure() && steps.combinecoverage.outcome == 'failure' }}
- name: Upload HTML report.
uses: actions/[email protected]
with:
name: _html-report
path: htmlcov
if-no-files-found: ignore
if: ${{ failure() && steps.combinecoverage.outcome == 'failure' }}