Optimize cache for pre-commit workflow

This commit is contained in:
Yurii Motov committed 2026-08-06 21:20:52 +02:00
1 parent 0622a151c1
commit a6d35b9052
2 files changed
+48

No files matched your search

+5
View File
@@ -7,6 +7,7 @@ permissions: {}
env:
# Forks and Dependabot don't have access to secrets
HAS_SECRETS: ${{ secrets.PRE_COMMIT != '' }}
UV_NO_SYNC: true
jobs:
pre-commit:
@@ -48,6 +49,10 @@ jobs:
# Before upgrading uv version, make sure astral-sh/setup-uv knows its checksum.
# See: https://github.com/astral-sh/setup-uv/issues/851#issuecomment-4282017837
version: "0.11.18"
cache-suffix: dev-all
# Cache written by workflow triggered by pull_request is PR-scoped and almost useless.
# Disable saving here, it will be populated by `warm-cache.yml`.
save-cache: false
cache-dependency-glob: |
pyproject.toml
uv.lock
+43
View File
@@ -0,0 +1,43 @@
name: Warm Cache
# Populates the `dev-all` uv cache at default-branch scope so that it could be used by
# `pre-commit.yml` (it has `pull_request` trigger and can't write cache available across PRs)
# and some others that use subset of dev dependencies.
on:
push:
branches:
- master
schedule:
- cron: "0 4 * * *"
workflow_dispatch:
permissions: {}
jobs:
warm-cache:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version-file: ".python-version"
- name: Setup uv
id: setup-uv
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
with:
# Before upgrading uv version, make sure astral-sh/setup-uv knows its checksum.
# See: https://github.com/astral-sh/setup-uv/issues/851#issuecomment-4282017837
version: "0.11.18"
enable-cache: true
cache-suffix: dev-all
cache-dependency-glob: |
pyproject.toml
uv.lock
- name: Populate the cache
if: steps.setup-uv.outputs.cache-hit != 'true'
run: uv sync --locked --extra all