Skip to content
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

add cache-local-storage-path #150

Merged
merged 3 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/test-cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test-setup-cache:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -39,3 +43,39 @@ jobs:
fi
env:
CACHE_HIT: ${{ steps.restore.outputs.cache-hit }}

test-setup-cache-local:
runs-on: oracle-aarch64
steps:
- uses: actions/checkout@v4
- name: Setup with cache
uses: ./
with:
version: '0.11.0'
enable-cache: true
working-directory: __tests__/fixtures/rye-project
cache-prefix: ${{ github.run_id }}-${{ github.run_attempt }}
cache-local-storage-path: /tmp/rye-cache
- run: rye sync
working-directory: __tests__/fixtures/rye-project
test-restore-cache-local:
runs-on: oracle-aarch64
needs: test-setup-cache-local
steps:
- uses: actions/checkout@v4
- name: Restore with cache
id: restore
uses: ./
with:
version: '0.11.0'
enable-cache: true
working-directory: __tests__/fixtures/rye-project
cache-prefix: ${{ github.run_id }}-${{ github.run_attempt }}
cache-local-storage-path: /tmp/rye-cache
- name: Cache was hit
run: |
if [ "$CACHE_HIT" != "true" ]; then
exit 1
fi
env:
CACHE_HIT: ${{ steps.restore.outputs.cache-hit }}
22 changes: 22 additions & 0 deletions .github/workflows/test-latest-scheduled.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: 'test-latest-scheduled'
on:
pull_request:
push:
branches:
- main
schedule:
- cron: "0 0 * * *"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test-rye-sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup rye
uses: ./
- run: rye sync
working-directory: __tests__/fixtures/rye-project
4 changes: 4 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
runs-on: ${{ matrix.os }}
Expand Down
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,19 @@ relative to the repository root. This is useful for monorepos.
working-directory: 'path/to/rye/project'
```

#### Local storage path

If you want to save the cache to a local path you can specify the path with the `cache-local-storage-path` input.
This can be useful if you are on a self hosted runner and want to save time and network traffic.

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

## 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 @@ -17,6 +17,9 @@ inputs:
cache-prefix:
description: 'Prefix for the cache key'
required: false
cache-local-storage-path:
description: 'Local path to store the cache. Will be used instead of the GitHub Actions cache'
required: false
outputs:
rye-version:
description: "The installed rye version. Useful when using latest."
Expand Down
77 changes: 51 additions & 26 deletions dist/save-cache/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/save-cache/index.js.map

Large diffs are not rendered by default.

44 changes: 33 additions & 11 deletions dist/setup/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/setup/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "setup-rye",
"version": "1.4.0",
"version": "1.11.0",
"private": true,
"description": "TypeScript template action",
"main": "dist/index.js",
Expand Down
Loading