-
Notifications
You must be signed in to change notification settings - Fork 42
feat: add built-in caching via inputs #89
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
bd95779
refactor: convert action to TS
csvn f61c059
chore: add deno workspace config for VSCode
csvn 663669c
refactor: add build script for bundling
csvn 505d7bb
feat: add built-in caching via inputs
csvn b451c2d
Merge branch 'main' into feat/add-caching
dsherret 1df61d4
update after merge
dsherret dd2d33b
Remove dist dir before build
dsherret f281974
update to have descriptive error when JSON output is missing denoDir …
dsherret 099f587
maybe fix ci
dsherret 6fb52a5
try fix cache again
dsherret 37a45d8
use deno.lock in test because the package-lock.json is now gone from …
dsherret 0dadfab
Update README.md
dsherret File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,6 +80,41 @@ jobs: | |
- name: Check binary exists | ||
run: deno_foo -V | ||
|
||
test-setup-cache: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, windows-latest, macos-latest] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup Deno | ||
uses: ./ | ||
with: | ||
cache: true | ||
cache-hash: ${{ hashFiles('**/deno.lock') }} | ||
|
||
- name: Download dependencies for cache | ||
run: deno install --global --no-config npm:[email protected] | ||
|
||
test-cache: | ||
needs: test-setup-cache | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, windows-latest, macos-latest] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup Deno | ||
uses: ./ | ||
with: | ||
cache: true | ||
cache-hash: ${{ hashFiles('**/deno.lock') }} | ||
|
||
- name: Run with cached dependencies | ||
run: deno run --cached-only --no-config -RE npm:[email protected] "It works!" | ||
|
||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,11 +13,20 @@ inputs: | |
deno-binary-name: | ||
description: The name to use for the binary. | ||
default: "deno" | ||
cache: | ||
description: Cache downloaded modules & packages automatically in GitHub Actions cache. | ||
default: "false" | ||
cache-hash: | ||
description: A hash used as part of the cache key. Use e.g. `$\{{ hashFiles('**/deno.lock') }}` to cache based on the lockfile contents. | ||
outputs: | ||
cache-hit: | ||
description: A boolean indicating whether the cache was hit. | ||
Comment on lines
+22
to
+23
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This output can be used to conditionally run - uses: denoland/setup-deno@v2
id: deno
with:
cache: true
- if: steps.deno.outputs.cache-hit != 'true'
run: deno install
- run: deno test |
||
deno-version: | ||
description: "The Deno version that was installed." | ||
release-channel: | ||
description: "The release channel of the installed version." | ||
runs: | ||
using: "node20" | ||
main: "dist/main.mjs" | ||
post: "dist/post.mjs" | ||
post-if: always() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if maybe this should be an implicit
cache: true
? Maybe something for a follow-up.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition to that, maybe doing:
should be an implicit
cache-hash: ${{ hashFiles('**/deno.lock') }}
and someone can disable this by doingcache-hash: ''
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed internally and we'd like to make this automatically hash the deno.lock by default similar to how https://github.com/Swatinem/rust-cache does it by default. I'll open a PR that adds this shortly after merging this one then do a release.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh, yeah that could be nice; if
cache-hash
is set,cache: true
is implied. I can for sure do a follow-up PR with that 😃Note worth mentioning,
cache-hash
is not mandatory. I just had it in the README.md as I think it's best practice. So it's possible to just usecache: true
. The primary cache key should then become`deno-cache-${RUNNER_OS}-${RUNNER_ARCH}-${GITHUB_JOB}-`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh, sure. Sounds like a good idea. I just looking at
actions/setup-node
, and did not look much at others. Improving defaults and having less boilerplate sounds great!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added here: #98