-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate to the reusable tox workflow #1102
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
name: "🧪 Test" | ||
|
||
on: | ||
push: | ||
branches: | ||
- "main" | ||
pull_request: null | ||
# build weekly at 4:00 AM UTC | ||
schedule: | ||
- cron: '0 4 * * 1' | ||
|
||
jobs: | ||
test: | ||
name: "${{ matrix.name }}" | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
# The `include` array below will match against these names | ||
# and add additional keys and values to the JSON object. | ||
name: | ||
- "Linux" | ||
- "macOS" | ||
- "Windows" | ||
- "Quality" | ||
|
||
# The `include` array below will also inherit these values, | ||
# which are critical for effective cache-busting. | ||
# The nested list syntax ensures that the full array of values is inherited. | ||
cache-key-hash-files: | ||
- | ||
- "requirements/*/*.txt" | ||
- "pyproject.toml" | ||
- "toxfile.py" | ||
|
||
include: | ||
- name: "Linux" | ||
runner: "ubuntu-latest" | ||
cpythons: | ||
- "3.8" | ||
- "3.9" | ||
- "3.10" | ||
- "3.11" | ||
- "3.12" | ||
- "3.13" | ||
tox-post-environments: | ||
- "py3.8-mindeps" | ||
- "coverage_report" | ||
|
||
- name: "macOS" | ||
runner: "macos-latest" | ||
cpythons: | ||
- "3.11" | ||
tox-post-environments: | ||
- "coverage_report" | ||
|
||
- name: "Windows" | ||
runner: "windows-latest" | ||
cpythons: | ||
- "3.11" | ||
tox-post-environments: | ||
- "coverage_report" | ||
|
||
- name: "Quality" | ||
runner: "ubuntu-latest" | ||
cpythons: | ||
- "3.13" | ||
tox-environments: | ||
- "check-min-python-is-tested" | ||
- "mypy" | ||
- "mypy-test" | ||
- "poetry-check" | ||
- "pylint" | ||
- "test-lazy-imports" | ||
- "twine-check" | ||
cache-paths: | ||
- ".mypy_cache/" | ||
|
||
uses: "globus/workflows/.github/workflows/tox.yaml@04b4abd6fcb9b4be7263bc9d6994ae2ada220739" # v1.1 | ||
with: | ||
config: "${{ toJSON(matrix) }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have been wondering, over the past week, about whether or not
tox-uv
's faster venv building makes it unnecessary to cache the.tox
dir contents. As long as theuv
action's cache is populated,.tox/
can be quickly rebuilt.One of the things I wonder is whether or not the balance between the two may, in fact, favor rebuilding over caching (since caching and hashing take some time).
I'm curious if you've given this any thought?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have. Caching the tarballs and wheels, instead of caching everything that was installed, hasn't previously been faster.
The numbers are borne out best on Windows, so I'll share from the feedparser logs, which tests the highest and lowest supported CPython versions (and which I recommend doing here, but didn't introduce in this PR).
Here's the timings reported by feedparser tests for Windows with a cache miss:
and for a cache hit:
(Note that the first tox environment always has the wheel build step counted in as a part of its
setup
.) Since thecmd
times per tox environment are within ~0.5s of each other between the cache-miss and cache-hit executions, I'm more inclined to trust that thesetup
times aren't simply GitHub runner jitter.So, my interpretation is that this is a win of ~13 seconds across 2 tox environments on Windows.
It took 1 second to look up the cache and miss, and then 5 seconds to upload the cache from the cache-miss job; it subsequently took 2 seconds to download the cache for the cache-hit job, which is an additional ~4 seconds won.
I have consistently found that it's faster to cache what's installed, rather than caching what needs to be installed.
tox-uv
makes environment creation and package installation fast, but I don't think it's fast enough.You're welcome to try improving on this! It's mechanically trivial, but extremely time-consuming. Here's the steps:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find this explanation 110% satisfactory. I'm probably not going to experiment with this at least within the next few days: my main question was about the comparison between
time(cache miss + tox_uv setup + cache save)
vstime(cache hit + tox_uv setup)
and you've already provided numbers for that.I am willing to accept some minor regressions in CI speeds if it gives us other improvements (e.g., workflow simplicity). In particular, I've been trying to track in the PRs as you've converted us over to the new workflow -- what exactly is being used for cache keys and is it "correct"?
The
uv
action cache carries all of the raw packages already (in the runner's homedir), so there's some interesting interplay there with the.tox
dir.Thanks for laying this all out for me!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I think I see what you're referring to. This isn't using the
uv
GitHub action, so there's no side caching happening, and pip caching isn't enabled for thesetup-python
action.For cache keys, here's the rule that I've generally been following:
Already-included files
These files are always included by the reusable workflow:
.python-identifiers
(generated by the
kurtmckee/detect-pythons
action; ensures that the cache -- which contains symlinks to Python interpreter executables -- is invalidated if the Python versions change).workflow-config.json
(ensures that changes to the requested configuration invalidates the cache)
tox.ini
(ensures that changes to the tox configuration invalidates the cache)
Files you should use with
cache-key-hash-files
In general, any files that contain tool configuration directives should be hashed for cache-busting.
pyproject.toml
mypy.ini
.flake8
.pre-commit-config.yaml
setup.cfg
requirements/*/*.txt
poetry.lock
If these files change, it can indicate that different dependencies should be installed, or that a tool like mypy should change how it's writing its own cache, or any number of other things that might make the workflow cache less useful.