Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 28 additions & 16 deletions .github/workflows/tox.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ on:
type: "string"

env:
CHECK_JSONSCHEMA_VERSION: "0.34.0"
# These variables lock application versions for reproducibility.
CHECK_JSONSCHEMA_VERSION: "0.35.0"
PYTHON_VERSION: "3.13"
UV_VERSION: "0.9.11"

jobs:
tox:
Expand All @@ -32,13 +35,19 @@ jobs:
- name: "Setup Python for tox config validation/transformation"
uses: "actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548" # v6.1.0
with:
python-version: "3.13"
python-version: "${{ env.PYTHON_VERSION }}"

- name: "Install uv"
uses: "astral-sh/setup-uv@1e862dfacbd1d6d858c55d9b792c756523627244" # v7.1.4
with:
version: "${{ env.UV_VERSION }}"
enable-cache: false

# If a previous workflow run successfully validated an identical config object,
# a cache hit is sufficient to demonstrate that no further validation is required.
- name: "Check if raw tox config is already validated"
id: "lookup-config-cache"
uses: "actions/cache/restore@9255dc7a253b0ccc959486e2bca901246202afeb" # v5.0.1
uses: "actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830" # v4.3.0
with:
lookup-only: true
path: ".tox-config.raw.json"
Expand Down Expand Up @@ -119,7 +128,7 @@ jobs:
}
},
"cpythons": {
"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.",
"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.",
"type": "array",
"minItems": 1,
"items": {
Expand All @@ -128,12 +137,12 @@ jobs:
}
},
"cpython-beta": {
"description": "A CPython version to install as a beta. Unless the 'cpythons' list is empty, this version will never be the default Python interpreter.",
"description": "A CPython version to install as a beta. A beta CPython interpreter will never be the default Python interpreter.",
"type": "string",
"minLength": 3
},
"pypys": {
"description": "A list of PyPy interpreter versions.",
"description": "A list of PyPy interpreter versions. PyPy interpreters will never be the default Python interpreter.",
"type": "array",
"minItems": 1,
"items": {
Expand Down Expand Up @@ -219,16 +228,14 @@ jobs:
if: "steps.lookup-config-cache.outputs.cache-hit == false"
shell: "bash"
run: |
pip install --target="${RUNNER_TEMP}/check-jsonschema" "check-jsonschema==${CHECK_JSONSCHEMA_VERSION}"
export PYTHONPATH="${RUNNER_TEMP}/check-jsonschema"
"${RUNNER_TEMP}/check-jsonschema/bin/check-jsonschema" \
uv tool run --from="check-jsonschema==${CHECK_JSONSCHEMA_VERSION}" check-jsonschema \
--schemafile "${RUNNER_TEMP}/tox-schema.json" \
--regex-variant python \
".tox-config.raw.json"

- name: "Create a 'config-is-validated' cache key"
if: "steps.lookup-config-cache.outputs.cache-hit == false"
uses: "actions/cache/save@9255dc7a253b0ccc959486e2bca901246202afeb" # v5.0.1
uses: "actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830" # v4.3.0
with:
path: ".tox-config.raw.json"
key: "${{ steps.lookup-config-cache.outputs.cache-primary-key }}"
Expand Down Expand Up @@ -313,7 +320,7 @@ jobs:
# END: tox_config_transformer.py

- name: "Checkout the repository"
uses: "actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8" # v6.0.1
uses: "actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3" # v6.0.0

- name: "Save the tox config to a file for cache-busting"
shell: "bash"
Expand Down Expand Up @@ -350,7 +357,7 @@ jobs:

- name: "Restore cache"
id: "restore-cache"
uses: "actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb" # v5.0.1
uses: "actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830" # v4.3.0
with:
path: |
.tox/
Expand Down Expand Up @@ -378,9 +385,8 @@ jobs:
- name: "Create a virtual environment"
if: "steps.restore-cache.outputs.cache-hit == false"
run: |
python -m venv .venv
${{ env.venv-path }}/python -m pip install --upgrade pip setuptools wheel
${{ env.venv-path }}/pip install tox tox-uv
uv venv .venv
uv pip install --directory .venv tox tox-gh tox-uv
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like us to upstream a variant of #20 into the original workflow.

As we're growing the list of automatically installed plugins, I would like us to give downstream repos control so that they can set tox-plugins = [] or tox-plugins = ['tox-uv'].

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that can be arranged! 👍


- name: "Setup Pythons (requested)"
if: "fromJSON(env.tox-config).python-versions-required != fromJSON(env.tox-config).python-versions-requested"
Expand All @@ -391,8 +397,14 @@ jobs:
python-version: "${{ fromJSON(env.tox-config).python-versions-requested }}"
allow-prereleases: true

- name: "Create the tox environments"
env:
TOX_SKIP_ENV: "${{ fromJSON(env.tox-config).tox-skip-environments-regex }}"
run: |
${{ env.venv-path }}/tox run --colored=yes --notest ${{ fromJSON(env.tox-config).tox-environments && format('-e "{0}"', join(fromJSON(env.tox-config).tox-environments, ',')) }}

- name: "Run the test suite"
env:
TOX_SKIP_ENV: "${{ fromJSON(env.tox-config).tox-skip-environments-regex }}"
run: |
${{ env.venv-path }}/tox run --colored yes ${{ fromJSON(env.tox-config).tox-environments && format('-e "{0}"', join(fromJSON(env.tox-config).tox-environments, ',')) }}
${{ 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, ',')) }}
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

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

## v1.4

### `tox.yaml`

- Separate tox environment creation from execution.
- Add the tox-gh plugin to group tox environment output.
- Update check-jsonschema to v0.35.0.
- Use uv for venv creation and check-jsonschema execution.

## v1.3

### `pr_has_changelog.yaml`
Expand Down