-
Notifications
You must be signed in to change notification settings - Fork 16
Cache uv dependencies to speed up PR checks #333
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
base: main
Are you sure you want to change the base?
Changes from all commits
f0cdf34
fade2dd
61690be
3fefebc
19f30c9
c737fa4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | |||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,49 @@ | |||||||||||||||||||||||||||||
| name: Build uv cache | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| permissions: | |||||||||||||||||||||||||||||
| contents: read | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| on: | |||||||||||||||||||||||||||||
| push: | |||||||||||||||||||||||||||||
| branches: | |||||||||||||||||||||||||||||
| - main | |||||||||||||||||||||||||||||
| paths: | |||||||||||||||||||||||||||||
| - "uv.lock" | |||||||||||||||||||||||||||||
| - "**/pyproject.toml" | |||||||||||||||||||||||||||||
| workflow_dispatch: | |||||||||||||||||||||||||||||
| schedule: | |||||||||||||||||||||||||||||
| - cron: '0 0 * * *' | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| jobs: | |||||||||||||||||||||||||||||
| build-cache: | |||||||||||||||||||||||||||||
| name: build cache on ${{ matrix.python-version }} | |||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | |||||||||||||||||||||||||||||
| strategy: | |||||||||||||||||||||||||||||
| fail-fast: false | |||||||||||||||||||||||||||||
| matrix: | |||||||||||||||||||||||||||||
| python-version: ["3.10", "3.11", "3.12", "3.13"] | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| steps: | |||||||||||||||||||||||||||||
| - name: Checkout repository | |||||||||||||||||||||||||||||
| uses: actions/checkout@v4 | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| - name: Install uv | |||||||||||||||||||||||||||||
| uses: astral-sh/setup-uv@eac588ad8def6316056a12d4907a9d4d84ff7a3b # v7 | |||||||||||||||||||||||||||||
| with: | |||||||||||||||||||||||||||||
| python-version: ${{ matrix.python-version }} | |||||||||||||||||||||||||||||
| enable-cache: false | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| - name: Install dependencies and populate cache | |||||||||||||||||||||||||||||
| run: | | |||||||||||||||||||||||||||||
| echo "Building global UV cache..." | |||||||||||||||||||||||||||||
| uv sync --all-packages --all-extras | |||||||||||||||||||||||||||||
| echo "Cache populated successfully" | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| - name: Save uv caches | |||||||||||||||||||||||||||||
| uses: actions/cache/save@v4 | |||||||||||||||||||||||||||||
| with: | |||||||||||||||||||||||||||||
| path: | | |||||||||||||||||||||||||||||
| ~/.cache/uv | |||||||||||||||||||||||||||||
| ~/.local/share/uv | |||||||||||||||||||||||||||||
| .venv | |||||||||||||||||||||||||||||
| key: uv-main-${{ matrix.python-version }}-${{ hashFiles('uv.lock') }} | |||||||||||||||||||||||||||||
|
Comment on lines
+19
to
+49
Check warningCode scanning / CodeQL Workflow does not contain permissions Medium
Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
This autofix suggestion was applied.
Show autofix suggestion
Hide autofix suggestion
Copilot AutofixAI 3 months ago In general, the fix is to explicitly declare a restrictive The best minimal fix without changing existing behavior is to add a root-level Concretely: in permissions:
contents: readbetween line 1 (
Suggested changeset
1
.github/workflows/cache-dependencies.yml
Copilot is powered by AI and may make mistakes. Always verify output.
Refresh and try again.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So I guess we need a top level: permissions:
contents: readblock. But to write to the cache, maybe we need read,write? Might have to play with it. I'm not seeing cache-management explicitly discussed in this doc on workflow permissions syntax |
|||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was this for your own debugging or is this something we want to keep around? It looks like it overlaps somewhat with our noxfile tests |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| name: Check Latest Pypi Release | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| release-version: | ||
| type: string | ||
| description: Choose which release tag to test (no leading v) | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 1 | ||
| sparse-checkout: | | ||
| tests/integration_tests/dbt_projects/project1 | ||
| tests/integration_tests/package_upgrades/mixed_versions | ||
| sparse-checkout-cone-mode: false | ||
|
|
||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@eac588ad8def6316056a12d4907a9d4d84ff7a3b # v7 | ||
|
|
||
| - name: Create new uv project | ||
| run: uv init | ||
|
|
||
| - name: Install specified release | ||
| run: uv add dbt-autofix==${{ inputs.release-version }} | ||
|
|
||
| - name: Display uv dependencies | ||
| run: uv tree | ||
|
|
||
| - name: Check version | ||
| run: uv run dbt-autofix --version | ||
|
|
||
| - name: Test deprecations | ||
| run: uv run dbt-autofix deprecations --all --path tests/integration_tests/dbt_projects/project1 | ||
|
|
||
| - name: Test package upgrade | ||
| run: uv run dbt-autofix packages --force-upgrade --path tests/integration_tests/package_upgrades/mixed_versions |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,25 +20,47 @@ jobs: | |
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: astral-sh/setup-uv@e58605a9b6da7c637471fab8847a5e5a6b8df081 # v5 | ||
| - name: Restore global uv cache | ||
| id: cache-restore | ||
| uses: actions/cache/restore@v4 | ||
| with: | ||
| path: | | ||
| ~/.cache/uv | ||
| ~/.local/share/uv | ||
| .venv | ||
| key: uv-main-${{ matrix.python-version }}-${{ hashFiles('uv.lock') }} | ||
| restore-keys: | | ||
| uv-main-${{ matrix.python-version }}- | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not really clear why |
||
|
|
||
| - uses: astral-sh/setup-uv@eac588ad8def6316056a12d4907a9d4d84ff7a3b # v7 | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
| enable-cache: true | ||
| cache-suffix: test | ||
| enable-cache: false | ||
|
|
||
| - run: uv sync --all-extras --all-packages | ||
| - run: uv run pytest | ||
|
|
||
| - name: Save uv caches | ||
| if: steps.cache-restore.outputs.cache-hit != 'true' | ||
| uses: actions/cache/save@v4 | ||
| with: | ||
| path: | | ||
| ~/.cache/uv | ||
| ~/.local/share/uv | ||
| .venv | ||
| key: uv-main-${{ matrix.python-version }}-${{ hashFiles('uv.lock') }} | ||
|
|
||
| lint: | ||
| name: lint | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 5 | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: astral-sh/setup-uv@e58605a9b6da7c637471fab8847a5e5a6b8df081 # v5 | ||
| - uses: astral-sh/setup-uv@eac588ad8def6316056a12d4907a9d4d84ff7a3b # v7 | ||
| with: | ||
| python-version: "3.10" | ||
| enable-cache: true | ||
| cache-suffix: lint | ||
| - run: uv tool run ruff@0.14.14 check . --config pyproject.toml | ||
| - run: uv tool run ruff@0.14.14 format --check --diff . --config pyproject.toml | ||
| - run: uv tool run ruff@0.14.14 format --check --diff . --config pyproject.toml | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,7 +36,7 @@ jobs: | |
| persist-credentials: false | ||
|
|
||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@caf0cab7a618c569241d31dcd442f54681755d39 # astral-sh/setup-uv@v3 | ||
| uses: astral-sh/setup-uv@eac588ad8def6316056a12d4907a9d4d84ff7a3b # v7 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks for the upgrades! |
||
|
|
||
| - name: Build artifacts | ||
| run: uv build --all | ||
|
|
||
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.
Nice! Was wondering how our multi-python version stuff would make this differ from the post you linked.
Pretty simple - just run across all python versions and include python-version in the cache key!