Skip to content

Use uv and tox-uv in GitHub Actions - #1636

Open
pganssle wants to merge 3 commits into
masterfrom
ci-uv
Open

pganssle wants to merge 3 commits into
masterfrom
ci-uv

Conversation

@pganssle

@pganssle pganssle commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

Summary of changes

This uses uv and tox-uv for CI environment creation and dependency installation, with the uv cache shared between runs. The existing interpreter matrix and distribution testing remain in place, so the packaging migration can follow separately.

Pull Request Checklist

  • Changes have tests
  • Authors have been added to AUTHORS.md
  • News fragment added in changelog.d. See CONTRIBUTING.md for details

@pganssle
pganssle marked this pull request as ready for review October 23, 2026 23:53
Comment thread .github/workflows/validate.yml Outdated
default: false

env:
TOX_UV_PATH: uv

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I don't think tox-uv reads TOX_UV_PATH anywhere. It always runs the binary from the uv wheel it depends on (find_uv_bin()), so this is a no-op and tox ends up using a different uv than the one setup-uv installs. The cache is still shared because setup-uv exports UV_CACHE_DIR, so I think we can just drop this line.

Comment thread .github/workflows/validate.yml Outdated
if: startsWith(matrix.os, 'ubuntu')
- name: Install dependencies
run: python -m pip install -U tox
- name: Set up uv

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This step is copied verbatim into five jobs, and #1638 then has to edit all five copies. Actions supports YAML anchors now, so let'st try using &setup-uv on this one and use - *setup-uv in the others.

Comment thread .github/workflows/validate.yml Outdated
uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
with:
enable-cache: true
cache-suffix: ${{ github.job }}-${{ matrix.python-version || matrix.toxenv || 'tools' }}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Doesn't setup-uv already put the OS in the cache key? If so I think the 'tools' fallback isn't buying anything, since it only kicks in for jobs without a matrix and github.job already tells those apart.

Comment thread .github/workflows/validate.yml Outdated
setup.cfg
setup.py
tox.ini
.github/workflows/*.yml

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Why the workflow files? With this, any edit to publish.yml throws away every uv cache. I guess it's for the darker pin, but that only matters to the darker job.

Comment thread .github/workflows/validate.yml Outdated
- name: Run tox on the wheel
shell: bash
run: python -m tox --installpkg "$(ls dist/*.whl)"
run: tox -x "testenv:py.base_python=${{ steps.python.outputs.python-path }}" --installpkg "$(ls dist/*.whl)"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This override is not needed, since tox will already run the py environment in whatever Python it itself is running under (which we set up with setup_python.

That said, I am reconsidering the idea of using setup_python — I think instead we should have tox and all its dependencies running on some stable Python and then let uv handle picking up the Python version. I think it will be slightly slower for cache misses, but it makes it so that tox or something being incompatible with the Python we're trying to test doesn't break our tests.

Same applies in the sdist tests.

Comment thread CONTRIBUTING.md

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant