Skip to content

Commit 9cb0a9d

Browse files
authored
Update the tox workflow (#21)
2 parents 16f2a46 + 2420b16 commit 9cb0a9d

File tree

2 files changed

+37
-16
lines changed

2 files changed

+37
-16
lines changed

.github/workflows/tox.yaml

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ on:
1313
type: "string"
1414

1515
env:
16-
CHECK_JSONSCHEMA_VERSION: "0.34.0"
16+
# These variables lock application versions for reproducibility.
17+
CHECK_JSONSCHEMA_VERSION: "0.35.0"
18+
PYTHON_VERSION: "3.13"
19+
UV_VERSION: "0.9.11"
1720

1821
jobs:
1922
tox:
@@ -32,13 +35,19 @@ jobs:
3235
- name: "Setup Python for tox config validation/transformation"
3336
uses: "actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548" # v6.1.0
3437
with:
35-
python-version: "3.13"
38+
python-version: "${{ env.PYTHON_VERSION }}"
39+
40+
- name: "Install uv"
41+
uses: "astral-sh/setup-uv@1e862dfacbd1d6d858c55d9b792c756523627244" # v7.1.4
42+
with:
43+
version: "${{ env.UV_VERSION }}"
44+
enable-cache: false
3645

3746
# If a previous workflow run successfully validated an identical config object,
3847
# a cache hit is sufficient to demonstrate that no further validation is required.
3948
- name: "Check if raw tox config is already validated"
4049
id: "lookup-config-cache"
41-
uses: "actions/cache/restore@9255dc7a253b0ccc959486e2bca901246202afeb" # v5.0.1
50+
uses: "actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830" # v4.3.0
4251
with:
4352
lookup-only: true
4453
path: ".tox-config.raw.json"
@@ -119,7 +128,7 @@ jobs:
119128
}
120129
},
121130
"cpythons": {
122-
"description": "A list of CPython interpreter versions. Typically, the *last version* listed will be the default Python interpreter when 'python' is invoked, and will be the version used when installing and executing tox.",
131+
"description": "A list of CPython interpreter versions. The *last version* listed will be the default Python interpreter when 'python' is invoked, and will be the version used when installing and executing tox.",
123132
"type": "array",
124133
"minItems": 1,
125134
"items": {
@@ -128,12 +137,12 @@ jobs:
128137
}
129138
},
130139
"cpython-beta": {
131-
"description": "A CPython version to install as a beta. Unless the 'cpythons' list is empty, this version will never be the default Python interpreter.",
140+
"description": "A CPython version to install as a beta. A beta CPython interpreter will never be the default Python interpreter.",
132141
"type": "string",
133142
"minLength": 3
134143
},
135144
"pypys": {
136-
"description": "A list of PyPy interpreter versions.",
145+
"description": "A list of PyPy interpreter versions. PyPy interpreters will never be the default Python interpreter.",
137146
"type": "array",
138147
"minItems": 1,
139148
"items": {
@@ -219,16 +228,14 @@ jobs:
219228
if: "steps.lookup-config-cache.outputs.cache-hit == false"
220229
shell: "bash"
221230
run: |
222-
pip install --target="${RUNNER_TEMP}/check-jsonschema" "check-jsonschema==${CHECK_JSONSCHEMA_VERSION}"
223-
export PYTHONPATH="${RUNNER_TEMP}/check-jsonschema"
224-
"${RUNNER_TEMP}/check-jsonschema/bin/check-jsonschema" \
231+
uv tool run --from="check-jsonschema==${CHECK_JSONSCHEMA_VERSION}" check-jsonschema \
225232
--schemafile "${RUNNER_TEMP}/tox-schema.json" \
226233
--regex-variant python \
227234
".tox-config.raw.json"
228235
229236
- name: "Create a 'config-is-validated' cache key"
230237
if: "steps.lookup-config-cache.outputs.cache-hit == false"
231-
uses: "actions/cache/save@9255dc7a253b0ccc959486e2bca901246202afeb" # v5.0.1
238+
uses: "actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830" # v4.3.0
232239
with:
233240
path: ".tox-config.raw.json"
234241
key: "${{ steps.lookup-config-cache.outputs.cache-primary-key }}"
@@ -313,7 +320,7 @@ jobs:
313320
# END: tox_config_transformer.py
314321
315322
- name: "Checkout the repository"
316-
uses: "actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8" # v6.0.1
323+
uses: "actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3" # v6.0.0
317324

318325
- name: "Save the tox config to a file for cache-busting"
319326
shell: "bash"
@@ -350,7 +357,7 @@ jobs:
350357

351358
- name: "Restore cache"
352359
id: "restore-cache"
353-
uses: "actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb" # v5.0.1
360+
uses: "actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830" # v4.3.0
354361
with:
355362
path: |
356363
.tox/
@@ -378,9 +385,8 @@ jobs:
378385
- name: "Create a virtual environment"
379386
if: "steps.restore-cache.outputs.cache-hit == false"
380387
run: |
381-
python -m venv .venv
382-
${{ env.venv-path }}/python -m pip install --upgrade pip setuptools wheel
383-
${{ env.venv-path }}/pip install tox tox-uv
388+
uv venv .venv
389+
uv pip install --directory .venv tox tox-gh tox-uv
384390
385391
- name: "Setup Pythons (requested)"
386392
if: "fromJSON(env.tox-config).python-versions-required != fromJSON(env.tox-config).python-versions-requested"
@@ -391,8 +397,14 @@ jobs:
391397
python-version: "${{ fromJSON(env.tox-config).python-versions-requested }}"
392398
allow-prereleases: true
393399

400+
- name: "Create the tox environments"
401+
env:
402+
TOX_SKIP_ENV: "${{ fromJSON(env.tox-config).tox-skip-environments-regex }}"
403+
run: |
404+
${{ env.venv-path }}/tox run --colored=yes --notest ${{ fromJSON(env.tox-config).tox-environments && format('-e "{0}"', join(fromJSON(env.tox-config).tox-environments, ',')) }}
405+
394406
- name: "Run the test suite"
395407
env:
396408
TOX_SKIP_ENV: "${{ fromJSON(env.tox-config).tox-skip-environments-regex }}"
397409
run: |
398-
${{ env.venv-path }}/tox run --colored yes ${{ fromJSON(env.tox-config).tox-environments && format('-e "{0}"', join(fromJSON(env.tox-config).tox-environments, ',')) }}
410+
${{ env.venv-path }}/tox run --colored=yes --no-provision --skip-pkg-install ${{ fromJSON(env.tox-config).tox-environments && format('-e "{0}"', join(fromJSON(env.tox-config).tox-environments, ',')) }}

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
The changelog is continuous. All changes are made to the current version branch.
44

5+
## v1.4
6+
7+
### `tox.yaml`
8+
9+
- Separate tox environment creation from execution.
10+
- Add the tox-gh plugin to group tox environment output.
11+
- Update check-jsonschema to v0.35.0.
12+
- Use uv for venv creation and check-jsonschema execution.
13+
514
## v1.3
615

716
### `pr_has_changelog.yaml`

0 commit comments

Comments
 (0)