Skip to content

Commit

Permalink
add working-dir parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
eifinger committed Dec 9, 2023
1 parent 26ef609 commit 7d1e64d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/test-cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,27 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Simluate rye-project
run: cp -r ./__tests__/fixtures/rye-project/* .
- name: Setup with cache
uses: ./
with:
version: '0.11.0'
enable-cache: true
working-directory: __tests__/fixtures/rye-project
cache-key: ${{ github.run_id }}-${{ github.run_attempt }}
- run: rye sync
working-directory: __tests__/fixtures/rye-project
test-restore-cache:
runs-on: ubuntu-latest
needs: test-setup-cache
steps:
- uses: actions/checkout@v4
- name: Simluate rye-project
run: cp -r ./__tests__/fixtures/rye-project/* .
- name: Restore with cache
id: restore
uses: ./
with:
version: '0.11.0'
enable-cache: true
working-directory: __tests__/fixtures/rye-project
cache-key: ${{ github.run_id }}-${{ github.run_attempt }}
- name: Cache was hit
run: |
Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ You can also specify a specific version of rye
### Validate checksum
You can also specify a checksum to validate the downloaded file.
Checksums of versions 0.12.0 and later are automatically verified by this action.
The sha265 hashes can be found on the [releases page](https://github.com/mitsuhiko/rye/releases)
of the rye repo.
Expand Down Expand Up @@ -60,6 +61,19 @@ You can optionally define a custom cache key prefix.
cache-prefix: 'optional-prefix'
```

#### Working directory

If your rye project is not at the root of the repository you can specify the working directory
relative to the repository root. This is useful for monorepos.

```yaml
- name: Enable caching and define a working directory
uses: eifinger/setup-rye@v1
with:
enable-cache: true
working-directory: 'path/to/rye/project'
```

## How it works

This action downloads rye from the releases of the [rye repo](https://github.com/mitsuhiko/rye) and uses the [GitHub Actions Toolkit](https://github.com/actions/toolkit) to cache it as a tool to speed up consecutive runs especially on self-hosted runners.
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ inputs:
enable-cache:
description: 'Enable caching of .venv'
default: 'false'
working-directory:
description: 'The location of the rye project relative to the root of the repository'
required: false
cache-prefix:
description: 'Prefix for the cache key'
required: false
Expand Down

0 comments on commit 7d1e64d

Please sign in to comment.