-
Notifications
You must be signed in to change notification settings - Fork 0
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
Fix tox + uv caching #29
Conversation
aca597a
to
4bcd774
Compare
4bcd774
to
31d5198
Compare
bc55777
to
9ff3c3f
Compare
.github/workflows/lint.yaml
Outdated
shell: bash | ||
run: uv venv |
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.
This is actually faster than using setup-python
and isolates things in a virtual env. One downside is that it just installs the latest Python version by default (3.13 currently). If we want to pin a version we could add one to this command or add a .python-version
file to the root of our project.
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.
[Praise] I like this! Nice that it's faster, and I also think it's helpful that it more closely matches the way we use uv for development.
- name: Install uv | ||
uses: astral-sh/setup-uv@v3 | ||
with: | ||
enable-cache: true | ||
cache-dependency-glob: pyproject.toml | ||
cache-suffix: docs | ||
uses: astral-sh/setup-uv@v4 |
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.
It's actually faster to run this without using the cache.
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.
[Praise] Common uv W 🚀
uses: astral-sh/setup-uv@v3 | ||
with: | ||
enable-cache: true | ||
cache-dependency-glob: pyproject.toml | ||
|
||
- name: Setup Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version-file: pyproject.toml | ||
|
||
- name: Install Python dependencies | ||
run: uv pip install . |
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.
None of this stuff is actually necessary to build the package, so we can remove it.
with: | ||
enable-cache: true | ||
cache-dependency-glob: pyproject.toml | ||
cache-suffix: tox | ||
cache-suffix: ${{ matrix.python-version }}-tox |
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.
This is the cause of the caching issue identified in ccao-data/ccao#33. Basically, uv
disables caching in CI by default because it's slower to recover the cache than it is to just uv pip install
(wild).
It's supposed to cache built-from-source wheels even when pruning is enabled. However, there's a race condition in the testing setup since the first-to-finish jobs are the ones to populate the cache, and those jobs won't have the built-from-source wheel.
The easy fix here is to just give each Python version its own cache.
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.
[Praise] This is wild 🤯 Great find!
passenv = | ||
UV_CACHE_DIR | ||
PYTHONUNBUFFERED |
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.
Not strictly necessary I don't think, but also can't hurt.
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.
Awesome work! I'll add these learnings over to my PR on ccao too.
.github/workflows/lint.yaml
Outdated
shell: bash | ||
run: uv venv |
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.
[Praise] I like this! Nice that it's faster, and I also think it's helpful that it more closely matches the way we use uv for development.
.github/workflows/lint.yaml
Outdated
|
||
- name: Install dependencies | ||
run: uv pip install . ruff | ||
|
||
- name: Lint with ruff | ||
run: ruff check --output-format=github . | ||
run: uv run ruff check --output-format=github . |
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.
[Question, non-blocking] This is totally unrelated to this PR, so no need to resolve now, but I wonder if we really need this lint
workflow at all given that pre-commit is running ruff anyway?
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.
Good thinking, another holdover from the R package. I removed it in 55e3225.
- name: Install uv | ||
uses: astral-sh/setup-uv@v3 | ||
with: | ||
enable-cache: true | ||
cache-dependency-glob: pyproject.toml | ||
cache-suffix: docs | ||
uses: astral-sh/setup-uv@v4 |
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.
[Praise] Common uv W 🚀
with: | ||
enable-cache: true | ||
cache-dependency-glob: pyproject.toml | ||
cache-suffix: tox | ||
cache-suffix: ${{ matrix.python-version }}-tox |
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.
[Praise] This is wild 🤯 Great find!
0d2737c
to
55e3225
Compare
This PR updates our GitHub Actions workflows to fix the caching integration between
tox
anduv
. It also switches most workflows over to usinguv
's built-in Python setup rather than thesetup-python
GitHub Action.