Repository navigation
391 lines (368 loc) · 16.4 KB
/
Copy pathpython-tests.yml
File metadata and controls
391 lines (368 loc) · 16.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
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
name: python tests+artifacts+release
on:
pull_request:
push:
branches:
- "*"
tags:
- "setuptools-scm-v*"
- "vcs-versioning-v*"
release:
types: [published]
# Tags created by GITHUB_TOKEN don't trigger push events for other workflows.
# create-release-tags.yml dispatches this workflow explicitly after tagging.
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions: {}
env:
FORCE_COLOR: 1
jobs:
package:
name: Build & inspect ${{ matrix.package }}
runs-on: ubuntu-latest
permissions:
contents: read
strategy:
matrix:
package:
- vcs-versioning
- setuptools-scm
env:
# Use no-local-version for package builds to ensure clean versions for PyPI uploads
SETUPTOOLS_SCM_NO_LOCAL: "1"
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
- name: Set pretend versions from release PR title
if: github.event_name == 'pull_request'
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
script: |
const title = context.payload.pull_request.title;
console.log(`PR title: ${title}`);
const scmMatch = title.match(/setuptools-scm v(\d+\.\d+\.\d+)/);
const vcsMatch = title.match(/vcs-versioning v(\d+\.\d+\.\d+)/);
if (!scmMatch && !vcsMatch) {
console.log('No release versions in PR title (normal for non-release PRs)');
return;
}
const fs = require('fs');
const envFile = process.env.GITHUB_ENV;
if (scmMatch) {
const ver = `${scmMatch[1]}.dev0`;
fs.appendFileSync(envFile, `SETUPTOOLS_SCM_PRETEND_VERSION_FOR_SETUPTOOLS_SCM=${ver}\n`);
console.log(`Set setuptools-scm pretend version: ${ver}`);
}
if (vcsMatch) {
const ver = `${vcsMatch[1]}.dev0`;
fs.appendFileSync(envFile, `SETUPTOOLS_SCM_PRETEND_VERSION_FOR_VCS_VERSIONING=${ver}\n`);
fs.appendFileSync(envFile, `VCS_VERSIONING_PRETEND_VERSION_FOR_VCS_VERSIONING=${ver}\n`);
console.log(`Set vcs-versioning pretend version: ${ver}`);
}
- name: Debug version inference
shell: bash
run: |
echo "=== Version Debug for ${{ matrix.package }} ==="
echo "Git describe:"
git describe --dirty --tags --long --match "${{ matrix.package }}-*" 2>&1 || echo "(no matching tags)"
echo "Relevant PRETEND env vars:"
env | grep -i PRETEND || echo "(none set)"
- name: Build ${{ matrix.package }}
uses: hynek/build-and-inspect-python-package@2abe76da66d0a6a4a227101f9348ee855797cfa5 # v3.0.1
with:
path: ${{ matrix.package }}
upload-name-suffix: -${{ matrix.package }}
test:
needs: [package]
runs-on: ${{ matrix.os }}
permissions:
contents: read
strategy:
fail-fast: false
matrix:
python_version: [ '3.8', '3.9', '3.10', '3.11', '3.12', '3.13', 'pypy-3.11' ]
os: [windows-latest, ubuntu-latest] #, macos-latest]
include:
- os: windows-latest
python_version: 'msys2'
env:
# Enable tracemalloc to debug gc errors with popen objects (especially on Windows)
PYTHONTRACEMALLOC: "1"
name: ${{ matrix.os }} - Python ${{ matrix.python_version }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
- name: Setup python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
if: matrix.python_version != 'msys2'
with:
python-version: ${{ matrix.python_version }}
architecture: x64
- name: Install the latest version of uv
# zizmor: ignore[cache-poisoning] test-only job; the published artifacts
# come from `package`, which builds without uv and without any cache
uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
- name: Setup MSYS2
uses: msys2/setup-msys2@66cd2cce69caa17b53920067426061ca1de3a884 # v2.32.0
if: matrix.python_version == 'msys2'
with:
msystem: MINGW64
install: git mingw-w64-x86_64-python mingw-w64-x86_64-python-setuptools
update: true
- name: Setup GnuPG and Mercurial on Windows
# At present, the Windows VMs only come with the copy of GnuPG that's bundled
# with Git for Windows. If we want to use this version _and_ be able to set
# arbitrary GnuPG home directories, then the test would need to figure out when
# to convert Windows-style paths into Unix-style paths with cygpath, which is
# unreasonable.
#
# Instead, we'll install a version of GnuPG that can handle Windows-style paths.
# However, due to <https://dev.gnupg.org/T5593>, installation fails if the PATH
# environment variable is too long. Consequently, we need to shorten PATH to
# something minimal before we can install GnuPG. For further details, see
# <https://github.com/actions/virtual-environments/issues/2876>.
#
# Additionally, we'll explicitly set `gpg.program` to ensure Git for Windows
# doesn't invoke the bundled GnuPG, otherwise we'll run into
# <https://dev.gnupg.org/T5504>. See also: <https://dev.gnupg.org/T3020>.
#
# Windows runners no longer ship with Mercurial pre-installed, so we install
# it via Chocolatey using the 'hg' package.
run: |
$env:PATH = "C:\Program Files\Git\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\ProgramData\Chocolatey\bin"
[Environment]::SetEnvironmentVariable("Path", $env:PATH, "Machine")
choco install gnupg hg -y --no-progress
echo "C:\Program Files\gnupg\bin" >> $env:GITHUB_PATH
echo "C:\Program Files\Mercurial\" >> $env:GITHUB_PATH
git config --system gpg.program "C:\Program Files\gnupg\bin\gpg.exe"
git config --system core.longpaths true
mkdir "D:\Temp"
echo "TEMP=D:\Temp" >> $env:GITHUB_ENV
if: runner.os == 'Windows'
- run: uv sync --all-packages --all-groups
- name: Download vcs-versioning packages
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: Packages-vcs-versioning
path: dist
- name: Download setuptools-scm packages
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: Packages-setuptools-scm
path: dist
- name: Install built wheels
shell: bash
run: |
# Use --no-deps: uv sync already resolved all dependencies from workspace;
# we just replace the editable installs with the built wheels.
uv pip install --no-deps dist/vcs_versioning-*.whl
uv pip install --no-deps dist/setuptools_scm-*.whl
- run: |
$(hg debuginstall --template "{pythonexe}") -m pip install hg-git --user
if: matrix.os == 'ubuntu-latest'
# this hopefully helps with os caches, hg init sometimes gets 20s timeouts
- run: hg version
shell: bash
- name: Install Jujutsu (jj) on Linux
if: runner.os == 'Linux'
run: |
JJ_VERSION="0.42.0"
curl -fsSL "https://github.com/jj-vcs/jj/releases/download/v${JJ_VERSION}/jj-v${JJ_VERSION}-x86_64-unknown-linux-musl.tar.gz" \
| tar xz --strip-components=0 -C /usr/local/bin ./jj
jj version
- name: Install Jujutsu (jj) on Windows
if: runner.os == 'Windows' && matrix.python_version != 'msys2'
shell: pwsh
run: |
$JJ_VERSION = "0.42.0"
Invoke-WebRequest -Uri "https://github.com/jj-vcs/jj/releases/download/v${JJ_VERSION}/jj-v${JJ_VERSION}-x86_64-pc-windows-msvc.zip" -OutFile jj.zip
Expand-Archive jj.zip -DestinationPath "$env:RUNNER_TEMP\jj"
echo "$env:RUNNER_TEMP\jj" >> $env:GITHUB_PATH
& "$env:RUNNER_TEMP\jj\jj.exe" version
- name: Run tests for both packages
run: uv run --no-sync pytest setuptools-scm/testing_scm/ vcs-versioning/testing_vcs/
timeout-minutes: 25
test-dependency-floor:
name: setuptools-scm against its declared vcs-versioning floor
needs: [package]
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
- name: Setup python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: '3.13'
- name: Install the latest version of uv
# zizmor: ignore[cache-poisoning] test-only job; the published artifacts
# come from `package`, which builds without uv and without any cache
uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
- name: Download setuptools-scm packages
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: Packages-setuptools-scm
path: dist
# Every other job resolves the newest vcs-versioning, so a stale lower
# bound stays green until a user hits it. setuptools-scm imports
# vcs-versioning's private modules, so the bound is a real claim: install
# the wheel against the oldest vcs-versioning its metadata permits, import
# every submodule, and run the testsuite. Importing alone misses the
# private names the integration hooks reach for inside function bodies.
- name: Test setuptools-scm against the oldest permitted vcs-versioning
run: uv run --no-project --with packaging python
src/vcs_versioning_workspace/check_dependency_floor.py dist
timeout-minutes: 20
test-standalone-vcs-versioning:
name: vcs-versioning testsuite without setuptools-scm
needs: [package]
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
- name: Setup python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: '3.13'
- name: Install the latest version of uv
# zizmor: ignore[cache-poisoning] test-only job; the published artifacts
# come from `package`, which builds without uv and without any cache
uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
- name: Download vcs-versioning packages
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: Packages-vcs-versioning
path: dist
- name: Create environment with vcs-versioning only
run: |
uv venv .venv-standalone
uv pip install --python .venv-standalone \
dist/vcs_versioning-*.whl pytest pytest-timeout pytest-xdist
- name: Assert setuptools-scm is absent
run: |
if ./.venv-standalone/bin/python -c "import setuptools_scm" 2>/dev/null; then
echo "setuptools-scm must not be installed for this check"
exit 1
fi
- name: Run the vcs-versioning testsuite
working-directory: vcs-versioning
run: ../.venv-standalone/bin/python -m pytest -n auto
timeout-minutes: 15
dist_upload_setuptools_scm:
runs-on: ubuntu-latest
if: |
github.repository == 'pypa/setuptools-scm' &&
((github.event_name == 'push' && startsWith(github.ref, 'refs/tags/setuptools-scm-v')) ||
(github.event_name == 'workflow_dispatch' && startsWith(github.ref, 'refs/tags/setuptools-scm-v')) ||
(github.event_name == 'release' && github.event.action == 'published' && startsWith(github.event.release.tag_name, 'setuptools-scm-v')))
permissions:
id-token: write
needs: [test]
steps:
- name: Download setuptools-scm packages
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: Packages-setuptools-scm
path: dist
- name: Publish setuptools-scm to PyPI
uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2
dist_upload_vcs_versioning:
runs-on: ubuntu-latest
if: |
github.repository == 'pypa/setuptools-scm' &&
((github.event_name == 'push' && startsWith(github.ref, 'refs/tags/vcs-versioning-v')) ||
(github.event_name == 'workflow_dispatch' && startsWith(github.ref, 'refs/tags/vcs-versioning-v')) ||
(github.event_name == 'release' && github.event.action == 'published' && startsWith(github.event.release.tag_name, 'vcs-versioning-v')))
permissions:
id-token: write
needs: [test]
steps:
- name: Download vcs-versioning packages
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: Packages-vcs-versioning
path: dist
- name: Publish vcs-versioning to PyPI
uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2
upload-release-assets-setuptools-scm:
runs-on: ubuntu-latest
if: |
github.repository == 'pypa/setuptools-scm' &&
((github.event_name == 'release' && github.event.action == 'published' && startsWith(github.event.release.tag_name, 'setuptools-scm-v')) ||
(github.event_name == 'workflow_dispatch' && startsWith(github.ref, 'refs/tags/setuptools-scm-v')))
needs: [test]
permissions:
contents: write
steps:
- name: Download setuptools-scm packages
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: Packages-setuptools-scm
path: dist
- name: Upload release assets
# zizmor: ignore[superfluous-actions] `gh release upload` would work, but
# this action already handles the glob and the empty-match failure mode
uses: softprops/action-gh-release@efb35369e0ad2afab669f228072c1b0d510eae64 # v3.0.3
with:
files: dist/*
fail_on_unmatched_files: true
upload-release-assets-vcs-versioning:
runs-on: ubuntu-latest
if: |
github.repository == 'pypa/setuptools-scm' &&
((github.event_name == 'release' && github.event.action == 'published' && startsWith(github.event.release.tag_name, 'vcs-versioning-v')) ||
(github.event_name == 'workflow_dispatch' && startsWith(github.ref, 'refs/tags/vcs-versioning-v')))
needs: [test]
permissions:
contents: write
steps:
- name: Download vcs-versioning packages
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: Packages-vcs-versioning
path: dist
- name: Upload release assets
# zizmor: ignore[superfluous-actions] `gh release upload` would work, but
# this action already handles the glob and the empty-match failure mode
uses: softprops/action-gh-release@efb35369e0ad2afab669f228072c1b0d510eae64 # v3.0.3
with:
files: dist/*
fail_on_unmatched_files: true
test-pypi-upload:
runs-on: ubuntu-latest
if: |
github.repository == 'pypa/setuptools-scm' &&
github.event_name == 'push' &&
(github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop')
needs: [test]
permissions:
id-token: write
steps:
- name: Download vcs-versioning packages
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: Packages-vcs-versioning
path: dist
- name: Download setuptools-scm packages
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: Packages-setuptools-scm
path: dist
- name: Publish package to PyPI
continue-on-error: true
uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2
with:
repository-url: https://test.pypi.org/legacy/