Skip to content

Commit

Permalink
Add **/requirements*.txt to default cache-dependency-glob (#185)
Browse files Browse the repository at this point in the history
Contributes to: #181
  • Loading branch information
eifinger authored Dec 8, 2024
1 parent bdcda7e commit be4207d
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 3 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/test-cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,41 @@ 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 venv
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 venv
uv pip install -r requirements.txt
working-directory: __tests__/fixtures/requirements-txt-project
test-setup-cache-dependency-glob:
runs-on: ubuntu-latest
Expand Down
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
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
Expand Up @@ -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
Expand Down

0 comments on commit be4207d

Please sign in to comment.