Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add **/requirements*.txt to default cache-dependency-glob
Browse files Browse the repository at this point in the history
eifinger committed Dec 8, 2024
1 parent bdcda7e commit 4c5e119
Showing 5 changed files with 43 additions and 3 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/test-cache.yml
Original file line number Diff line number Diff line change
@@ -41,6 +41,37 @@ jobs:
CACHE_HIT: ${{ steps.restore.outputs.cache-hit }}
- run: uv sync
working-directory: __tests__/fixtures/uv-project
test-setup-cache-requirements-txt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup with cache
uses: ./
with:
enable-cache: true
cache-suffix: ${{ github.run_id }}-${{ github.run_attempt }}-test-setup-cache-requirements-txt
- run: uv pip install -r requirements.txt
working-directory: __tests__/fixtures/requirements-txt-project
test-restore-cache-requirements-txt:
runs-on: ubuntu-latest
needs: test-setup-cache
steps:
- uses: actions/checkout@v4
- name: Restore with cache
id: restore
uses: ./
with:
enable-cache: true
cache-suffix: ${{ github.run_id }}-${{ github.run_attempt }}-test-setup-cache-requirements-txt
- name: Cache was hit
run: |
if [ "$CACHE_HIT" != "true" ]; then
exit 1
fi
env:
CACHE_HIT: ${{ steps.restore.outputs.cache-hit }}
- run: uv pip install -r requirements.txt
working-directory: __tests__/fixtures/requirements-txt-project

test-setup-cache-dependency-glob:
runs-on: ubuntu-latest
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -154,14 +154,19 @@ changes. If you use relative paths, they are relative to the repository root.

> [!NOTE]
>
> The default is `**/uv.lock`.
> The default is
> ```yaml
> cache-dependency-glob: |
> **/requirements*.txt
> **/uv.lock
> ```

```yaml
- name: Define a cache dependency glob
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
cache-dependency-glob: "**/requirements*.txt"
cache-dependency-glob: "**/pyproject.toml"
```

```yaml
1 change: 1 addition & 0 deletions __tests__/fixtures/requirements-txt-project/hello_world.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
print("Hello world")
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ruff>=0.6.2
4 changes: 3 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
@@ -25,7 +25,9 @@ inputs:
description:
"Glob pattern to match files relative to the repository root to control
the cache."
default: "**/uv.lock"
default: |
**/uv.lock
**/requirements*.txt
cache-suffix:
description: "Suffix for the cache key"
required: false

0 comments on commit 4c5e119

Please sign in to comment.