From 7d1e64ddab19bf62705405e9c0c04b3d25113a2a Mon Sep 17 00:00:00 2001 From: Kevin Stillhammer Date: Sat, 9 Dec 2023 09:37:06 +0100 Subject: [PATCH] add working-dir parameter --- .github/workflows/test-cache.yml | 7 +++---- README.md | 14 ++++++++++++++ action.yml | 3 +++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-cache.yml b/.github/workflows/test-cache.yml index 4460c0d..985ebbd 100644 --- a/.github/workflows/test-cache.yml +++ b/.github/workflows/test-cache.yml @@ -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: | diff --git a/README.md b/README.md index 2879003..37522f1 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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. diff --git a/action.yml b/action.yml index 5d58378..fbc57ea 100644 --- a/action.yml +++ b/action.yml @@ -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