Compare commits

...

146 Commits

Author SHA1 Message Date
81423d07fe Update licenses 2022-08-24 11:32:31 +00:00
c1dbd4593f Update @actions/core to 1.9.1 2022-08-24 11:26:37 +00:00
5f975d03e6 Merge pull request #896 from actions/bishal-pdMSFT-patch-1
Add readme section for good practices
2022-08-23 16:33:03 +05:30
8a9a57869f Update README.md 2022-08-23 15:20:27 +05:30
fb1d96e3ff Update README.md 2022-08-23 13:19:05 +05:30
2048ecfa86 Merge pull request #903 from actions/vsvipul/sort-inputs
Sort inputs and remove whitespaces after exclamation
2022-08-22 21:19:36 +05:30
8954b07458 Removed unnecessary backslash in regex 2022-08-22 13:05:20 +00:00
0ae6818675 Formatted files with prettier 2022-08-22 12:57:35 +00:00
f316f94f31 Generate build and fix format 2022-08-22 12:45:18 +00:00
204fa1ab69 Sort inputs and remove whitespaces after exclamation at the beginning of lines 2022-08-22 12:42:01 +00:00
fd5de65bc8 Merge pull request #899 from actions/kotewar/download-and-compression-fix
Updated actions/cache toolkit dep to v3.0.4
2022-08-22 12:07:42 +05:30
d49b6bb21d Updated actions/cache toolkit dep to v3.0.4 2022-08-18 14:13:31 +00:00
23d218be27 Add section for good practices 2022-08-14 14:35:33 +05:30
a7c34adf76 Merge pull request #894 from actions/kotewar/update-toolkit-version
Fix for the download stuck problem
2022-08-11 14:56:44 +05:30
83394c99b7 Updated cache version in license file 2022-08-11 07:59:07 +00:00
e839c25979 Updated actions/cache version to 3.0.3 2022-08-11 07:57:29 +00:00
33a923d660 Added release information 2022-08-09 16:48:03 +00:00
a404368986 Updated actions/cache version to 3.0.2 2022-08-09 16:43:43 +00:00
f4278025ab Merge pull request #887 from actions/pdotl-version-patch
Update toolkit's cache npm module to latest. Bump cache version to v3.0.6
2022-08-05 12:38:26 +05:30
9916fe1701 Update cache version in licences 2022-08-04 10:46:56 +00:00
318935ef66 Update README and RELEASES 2022-08-04 10:37:56 +00:00
85efbb58b9 Update cache npm module to latest 2022-08-04 10:00:08 +00:00
4387dbc81a Merge pull request #835 from shivamarora1/clojure-lein-example
feat: 🎸 add example for clojure lein project deps
2022-08-01 13:27:13 +05:30
71e3ee5cce Add phantsure to PR reviewers 2022-07-28 00:10:09 +05:30
c316eb7911 Add phantsure to issue assignment 2022-07-28 00:09:39 +05:30
0865c47f36 new release (#855) 2022-07-13 10:27:51 +05:30
354a2ae15e Consuming 3.0 actions/cache (#834)
* Consuming 3.0 actions/cache

* formatting and error

* updated package version

* resolve package

* dist

* review comment

* dist

* dist
2022-07-07 21:56:17 +05:30
baed3516c3 Merge pull request #530 from axelson/document-where-to-cache
Make it more obvious that the cache call does double duty
2022-06-27 10:56:37 +05:30
8829e97be1 Update README.md
Co-authored-by: Lucas Costi <lucascosti@users.noreply.github.com>
2022-06-27 10:48:52 +05:30
eec8cd3f5f Merge pull request #836 from actions/vsvipul/fix-auto-assign
Add kotewar and remove phantsure from auto-assignees lists
2022-06-26 20:03:54 +05:30
5cc84c0123 Add kotewar and remove phantsure from auto-assignees lists 2022-06-26 05:26:49 +00:00
a0e530f115 feat: 🎸 add example for clojure lein project deps
In Clojure, Lein tool is used to generate template for various projects.
Lein project metadata (including project dependencies) are stored in
prject.clj (in root directory) file. Lein downloads dependencies in
classpath (~/.m2/repository). So here I am caching ~/.m2/repository path
for reusing cache in subsequent builds.
2022-06-26 00:39:24 +05:30
afc669e7fc Merge pull request #819 from mpilgrem/haskell-stack-example
Adapt existing Haskell Stack example for Windows
2022-06-23 16:13:06 +05:30
a0efc56c52 Use pull_request_target instead of pull_request
Fixes autoassign reviewer for PRs from forked repos.
2022-06-21 22:38:08 +05:30
d25c51bbfd Adapt existing Haskell Stack example for Windows
The default `STACK_ROOT` is `~/.stack` only on Unix-like operating systems. On Windows, the default is `%APPDATA%/stack` (usually `%HOME%\AppData\Roaming\stack`).

On Unix-like OSs, Stack stores GHC and other tools in a `programs` directory in the `STACK_ROOT`. On Windows, Stack stores those tools and MSYS2 in `%LOCALAPPDATA%\Programs\stack` (usually `%HOME%\AppData\Local\Programs\stack`).
2022-06-21 13:15:08 +01:00
a080a3bda4 Merge pull request #816 from lobis/main
Fixed bad yaml in README example
2022-06-21 09:55:20 +05:30
02be3a9c73 fixed bad yaml in README example 2022-06-08 21:43:57 +02:00
c3f1317a9e Merge pull request #813 from actions/users/kotewar/upgrading-cache-to-v2.0.6
Updated README file with release info
2022-06-07 13:07:13 +05:30
d0a54b996c Fixed typo 2022-06-07 07:14:00 +00:00
8c5bd0c82d Updated README file with release info 2022-06-07 07:11:42 +00:00
c9c0f73558 Merge pull request #812 from actions/users/kotewar/upgrading-cache-to-v2.0.6
Updated @actions/cache to v2.0.6
2022-06-07 12:27:10 +05:30
2b6caae3c9 Merge pull request #495 from ostera/patch-1
Add sample cache for Erlang with Rebar3
2022-06-06 18:39:03 +05:30
dd58d1315f Added release info and upgraded version 2022-06-06 12:31:18 +00:00
acace7fa1b Merge branch 'main' into patch-1 2022-06-06 14:26:51 +02:00
438628ac22 Merge pull request #554 from albertstill/improve-restore-key-docs
Improve restore-key documentation
2022-06-06 17:29:02 +05:30
c296e6a08c Updated @actions/cache version in license file 2022-06-06 09:55:39 +00:00
7ed7f22ed8 Updated actions/cache to v2.0.6 2022-06-06 09:40:27 +00:00
30f413bfed Merge pull request #808 from actions/users/kotewar/update-actions-cache-version
Upgraded @actions/cache to 2.0.5
2022-05-31 12:33:10 +05:30
f2ea0f25f2 Updated Readme with what's new and removed v2 info 2022-05-31 03:33:14 +00:00
d5956bbc3c Updated release and package versions 2022-05-30 12:01:54 +00:00
a686c72e4a Revert "Updated package version to 3.0.3 and dependencies"
This reverts commit 4ce1a96732.
2022-05-30 11:54:57 +00:00
8e680ea440 Revert "Added release information for 3.0.2 in RELEASES.md"
This reverts commit c376fc84c9.
2022-05-30 11:54:45 +00:00
c376fc84c9 Added release information for 3.0.2 in RELEASES.md 2022-05-30 09:03:33 +00:00
4ce1a96732 Updated package version to 3.0.3 and dependencies 2022-05-30 08:03:00 +00:00
a2bd439f8e Updated license version and dist 2022-05-30 06:36:08 +00:00
35ef551d1f Upgraded @actions/cache to 2.0.5 2022-05-30 05:59:51 +00:00
14c4fd4871 Merge pull request #690 from pimterry/patch-1
Simplify the Node.js NPM caching example
2022-05-26 11:18:34 +05:30
455d267066 Merge pull request #804 from actions/Phantsure-patch-1
Update README to call out for version of cache
2022-05-26 09:26:58 +05:30
ccaf2d8fb1 Tweak npm example description for cleaner links 2022-05-25 12:00:49 +02:00
34f9efca11 Simplify the Node.js NPM caching example 2022-05-25 11:58:58 +02:00
11dd8059a1 Addressing comments 2022-05-24 06:31:12 +00:00
e19e89eb2a Update to call out for version of cache 2022-05-20 14:38:22 +05:30
95f200e41c Merge pull request #762 from magnetikonline/remove-win-load-app-data
Remove final incorrect instances of `%AppData%` / `%LocalAppData%` from Windows cache examples
2022-05-11 16:14:36 +05:30
9c784e290b Merge pull request #738 from kubo39/fix-dub
[D] Fix: should use dub.selections.json for cache
2022-05-11 16:13:29 +05:30
a34051afb0 Merge pull request #802 from actions/vsvipul/alert-fix
Update ts-jest version and package-lock.json
2022-05-09 11:14:12 +05:30
bdb21a7177 Update ts-jest version and package-lock.json 2022-05-09 00:04:20 +05:30
d55d005ab0 Merge pull request #801 from actions/vsvipul/fix-dep
Update dependencies to suppress dependabot alerts related to minimist version <"1.2.6"
2022-05-07 22:58:45 +05:30
b44d6c5cbf Update inactive issue message. 2022-05-05 11:58:06 +05:30
60742c2acf lint 2022-05-04 13:46:41 +00:00
12086c7bbf new build 2022-05-04 13:43:52 +00:00
626c44ce85 Update restore.ts 2022-05-04 21:26:37 +08:00
f2d5621efc Turning error from any to unknown 2022-05-04 12:32:55 +00:00
cab6d27614 Update licenses 2022-05-04 16:58:48 +05:30
69811fd677 Update other outdated red dependencies 2022-05-04 16:51:09 +05:30
887b9060fe Update dependencies with older minimist version 2022-05-04 16:47:33 +05:30
c6762fdd6a Set days before issue stale to 200 2022-05-04 14:54:27 +05:30
95c3ae75f4 Add Bishal to auto assign issues list. 2022-05-04 14:41:53 +05:30
797382fe42 Add Bishal to auto assign PRs list 2022-05-04 14:41:16 +05:30
36dbd93a7c Create auto-assign-issues.yml 2022-05-02 13:15:05 +05:30
45f362d0ca Create auto_assign.yml 2022-05-02 13:03:27 +05:30
ca0688b4ab Rename auto-assign.yaml to auto-assign.yml 2022-05-02 13:02:07 +05:30
ef8498dcba Create auto-assign.yaml 2022-05-02 13:01:55 +05:30
8f1e2e0286 Bump GitHub actions actions/checkout and actions/setup-node (#763)
* Bump GitHub actions

* Bump Node.js version used to `16.x` in workflows

* Bump `actions/upload-artifact@v3`
2022-04-12 00:06:07 +05:30
48af2dc4a9 Update actions/cache version (#786)
* Updang actions/cache version

* New build

* Update licenses

Co-authored-by: vsvipul <vsvipul@github.com>
2022-04-11 11:56:23 +05:30
f63a711791 Merge pull request #781 from actions/t-dedah/cacheSize
Updated @actions/cache to 2.0.1
2022-04-05 15:48:50 +05:30
770a27cf65 Update licenses 2022-04-05 12:17:59 +05:30
c2131abcd8 New build 2022-04-05 06:40:46 +00:00
575160481d Updated @actions/cache to 2.0.1 2022-04-05 05:53:11 +00:00
136d96b4ae Enabling actions/cache for GHES based on presence of AC service (#774)
* initial changes

* Update package-lock.json

* Update package-lock.json

* review comments and updated test cases

* package.json

* changed name

* added new line

* changed tookit

* updated with 2.0

* changed with public released package

* ran code format

* linting errors

* Update actionUtils.test.ts

* Update cache.dep.yml

* Update package.json

* Update README.md

* Create RELEASES.md

* Update RELEASES.md

* Update package.json

* Update package-lock.json

* typo
2022-03-30 15:46:49 +05:30
7d4f40b464 Bumping up the version to fix download issue for files > 2 GB. (#775)
* Bumping up the version to fix download issue for files > 2 GB.

* Update license for cache

Co-authored-by: vsvipul <vsvipul@github.com>
2022-03-30 15:33:23 +05:30
2d8d0d1c9b Updated what's new. (#771)
* Updated what's new.

* Segregated major versions and added changelog.

* Update README.md
2022-03-22 14:04:39 +05:30
7799d864d9 Updated the usage and docs to the major version release. (#770) 2022-03-21 14:31:26 +05:30
4b0cf6cc46 Merge pull request #769 from actions/users/ashwinsangem/bump_major_version
Bumped up to a major version(v3.0.0)
2022-03-21 13:56:53 +05:30
60c606a2b4 Update licensed files 2022-03-21 12:01:49 +05:30
b6e9a919a7 Revert "Updated to the latest version."
This reverts commit c842503583.
2022-03-21 04:56:07 +00:00
c842503583 Updated to the latest version. 2022-03-21 04:53:37 +00:00
2b7da2a62c Bumped up to a major version. 2022-03-21 04:42:02 +00:00
3722efebf1 Remove final incorrect instances of %AppData% / %LocalAppData% for Windows cache examples 2022-03-10 10:44:10 +11:00
deae296ab3 Merge pull request #651 from magnetikonline/fix-golang-windows-example
Fix Golang windows example - updated `README.md` test badge markdown.
2022-03-09 18:22:38 +05:30
c7c46bcb6d Merge pull request #707 from duxtland/main
Add Deno cache example
2022-02-24 15:51:48 +05:30
6535c5fb5f Regenerated examples.md TOC 2022-02-24 16:36:38 +11:00
3fdafa472e Update GitHub Actions status badge markdown in README.md 2022-02-24 16:32:52 +11:00
341e6d75d9 Merge branch 'actions:main' into fix-golang-windows-example 2022-02-24 16:28:28 +11:00
3fe001f5ca chore: add Deno cache example to readme 2022-02-23 16:18:41 -05:00
ab4bea262c Merge pull request #567 from yuichkun/fix-typo-in-lerna-example
Fix typo of cache path in Lerna example
2022-02-23 11:24:07 +05:30
7772fcab79 remove unnecessary sub directory from search path 2022-02-23 12:39:46 +09:00
6c2ab9416b Merge pull request #747 from malob/add-stack-example
Add example for Haskell Stack
2022-02-23 02:21:45 +05:30
2c7b30f330 Add example for Haskell Stack 2022-02-22 10:21:09 -08:00
73cb7e0405 Merge pull request #742 from actions/node-update
Update node version, @types/node and some outdated dependencies
2022-02-16 11:09:30 +05:30
757c5a8ca4 Update deps 2022-02-15 16:44:17 +05:30
4e817c1f42 Update to node16
Node 12 has an end of life on April 30, 2022.

This PR updates the default runtime to [node16](https://github.blog/changelog/2021-12-10-github-actions-github-hosted-runners-now-run-node-js-16-by-default/), rather then node12. 

This is supported on all Actions Runners v2.285.0 or later.
2022-02-15 16:38:00 +05:30
5074380beb [D] Fix: should use dub.selections.json for cache 2022-02-12 03:17:32 +09:00
72d1e4fdff Merge pull request #730 from actions/up-dep2
Update actions/cache package
2022-02-09 10:39:42 +05:30
8e70c71aee Update licenses for packages 2022-02-08 22:23:08 +05:30
4d3516739c Update build files 2022-02-08 16:33:33 +00:00
9c2f1a93d4 Update actions/cache package 2022-02-08 16:28:23 +00:00
5df1ae880d Merge pull request #727 from ygnoh/patch-1
Fix test description
2022-02-07 11:30:27 +05:30
45bb0b1552 Fix test description 2022-02-07 14:20:40 +09:00
b32c91dfec Merge pull request #724 from actions/resolve-dep
Resolve dependabot alerts
2022-02-01 11:05:06 +05:30
7f8b9fe1f0 Fix line ending for windows test 2022-01-31 13:00:27 +05:30
0ac93353cd Update eslint and prettier 2022-01-31 12:55:11 +05:30
051d7bc106 Resolve dependabot alerts 2022-01-31 12:06:04 +05:30
934cc8fa30 Merge pull request #722 from actions/up-dep-2
Update types/node and eslint-plugin-import
2022-01-31 11:43:58 +05:30
35dd74a1a0 Merge pull request #721 from JJ/patch-1 2022-01-30 11:09:43 +05:30
869d93f182 Update deps 2022-01-28 11:00:27 +00:00
a848fb313f This is a good tip if you're using Alpine
(Which does not have a POSIX-compliant tar by default)
2022-01-28 07:38:27 +01:00
de7c17c6a9 chore: add Deno cache example 2022-01-15 19:33:29 -05:00
611465405c Merge pull request #706 from nomeata/patch-1
Improve Haskell example
2022-01-05 22:03:41 -08:00
c64c5261d3 Fix syntax 2021-12-30 11:54:15 +01:00
4e8aa1cc93 Improve Haskell example
as proposed in https://github.com/actions/cache/issues/555
2021-12-29 20:50:37 +01:00
f7a7367bb2 Create close-inactive-issues.yml 2021-12-23 13:22:29 +05:30
3bb5ffcc9c Merge pull request #688 from tgrall/issue-687
Document the fact that this action is not supported on GitHub Enterprise Server
2021-12-17 15:48:10 +05:30
e6890046a6 Update README.md
Co-authored-by: Brian Cristante <33549821+brcrista@users.noreply.github.com>
2021-12-17 15:43:24 +05:30
62fa565f30 Merge pull request #696 from actions/bishal-pdMSFT-patch-1
Add actions-cache team in CODEOWNERS
2021-12-15 16:43:45 +05:30
e882008267 Update CODEOWNERS 2021-12-15 16:42:22 +05:30
8e0501dcaf Add actions-cache team in CODEOWNERS 2021-12-10 14:33:25 +05:30
a3b6799c91 update readme for issue #687 2021-11-29 14:51:07 +00:00
bd49291365 Update README.md - 10GB support 2021-11-23 21:35:12 +05:30
447f0fd1d3 Chomp some markdown whitespace 2021-09-26 22:10:48 +10:00
47e8bd685f Small fix to README.md examples link 2021-09-26 22:10:29 +10:00
795a8f09a9 Fixed Windows Golang cache paths in example 2021-09-26 22:05:48 +10:00
4762de4681 simplify path in lerna example 2021-04-21 02:47:03 +09:00
12ed05f49a Fix typo of cache path in Lerna example 2021-04-17 12:35:30 +09:00
3767bf0386 Improve restore-key documentation 2021-03-26 10:36:55 +11:00
2086306d9c Make it more obvious that the cache call does double duty 2021-02-06 13:36:42 -10:00
009fe4e01c Add sample cache for Erlang with Rebar3 2020-12-29 13:33:30 +01:00
41 changed files with 25755 additions and 9890 deletions

View File

@ -9,15 +9,14 @@
"plugin:import/errors",
"plugin:import/warnings",
"plugin:import/typescript",
"plugin:prettier/recommended",
"prettier/@typescript-eslint"
"plugin:prettier/recommended"
],
"plugins": ["@typescript-eslint", "simple-import-sort", "jest"],
"rules": {
"import/first": "error",
"import/newline-after-import": "error",
"import/no-duplicates": "error",
"simple-import-sort/sort": "error",
"simple-import-sort/imports": "error",
"sort-imports": "off"
}
}

3
.gitattributes vendored
View File

@ -1 +1,2 @@
.licenses/** -diff linguist-generated=true
.licenses/** -diff linguist-generated=true
* text=auto eol=lf

2
.github/CODEOWNERS vendored
View File

@ -1 +1 @@
* @actions/artifacts-actions
* @actions/actions-cache

18
.github/auto_assign.yml vendored Normal file
View File

@ -0,0 +1,18 @@
# Set to true to add reviewers to pull requests
addReviewers: true
# Set to true to add assignees to pull requests
addAssignees: false
# A list of reviewers to be added to pull requests (GitHub user name)
reviewers:
- phantsure
- kotewar
- aparna-ravindra
- tiwarishub
- vsvipul
- bishal-pdmsft
# A number of reviewers added to the pull request
# Set 0 to add all the reviewers (default: 0)
numberOfReviewers: 1

View File

@ -0,0 +1,15 @@
name: Issue assignment
on:
issues:
types: [opened]
jobs:
auto-assign:
runs-on: ubuntu-latest
steps:
- name: 'Auto-assign issue'
uses: pozil/auto-assign-issue@v1.4.0
with:
assignees: phantsure,kotewar,tiwarishub,aparna-ravindra,vsvipul,bishal-pdmsft
numOfAssignee: 1

10
.github/workflows/auto-assign.yml vendored Normal file
View File

@ -0,0 +1,10 @@
name: 'Auto Assign'
on:
pull_request_target:
types: [opened, ready_for_review]
jobs:
add-reviews:
runs-on: ubuntu-latest
steps:
- uses: kentaro-m/auto-assign-action@v1.2.1

View File

@ -22,16 +22,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set Node.js 12.x
uses: actions/setup-node@v1
- uses: actions/checkout@v3
- name: Setup Node.js 16.x
uses: actions/setup-node@v3
with:
node-version: 12.x
node-version: 16.x
- name: Install dependencies
run: npm ci
- name: Rebuild the dist/ directory
run: npm run build
@ -45,7 +42,7 @@ jobs:
id: diff
# If index.js was different than expected, upload the expected version as an artifact
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
with:
name: dist

View File

@ -0,0 +1,22 @@
name: Close inactive issues
on:
schedule:
- cron: "30 8 * * *"
jobs:
close-issues:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- uses: actions/stale@v3
with:
days-before-issue-stale: 200
days-before-issue-close: 5
stale-issue-label: "stale"
stale-issue-message: "This issue is stale because it has been open for 200 days with no activity. Leave a comment to avoid closing this issue in 5 days."
close-issue-message: "This issue was closed because it has been inactive for 5 days since being marked as stale."
days-before-pr-stale: -1
days-before-pr-close: -1
repo-token: ${{ secrets.GITHUB_TOKEN }}

View File

@ -14,7 +14,7 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
@ -24,7 +24,7 @@ jobs:
# the head of the pull request instead of the merge commit.
- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1

View File

@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
name: Check licenses
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- run: npm ci
- name: Install licensed
run: |

View File

@ -24,17 +24,17 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v1
uses: actions/checkout@v3
- name: Setup Node.js 16.x
uses: actions/setup-node@v3
with:
node-version: '12.x'
node-version: 16.x
- name: Determine npm cache directory
id: npm-cache
run: |
echo "::set-output name=dir::$(npm config get cache)"
- name: Restore npm cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ${{ steps.npm-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
@ -57,7 +57,7 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Generate files in working directory
shell: bash
run: __tests__/create-cache-files.sh ${{ runner.os }} test-cache
@ -80,7 +80,7 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Restore cache
uses: ./
with:
@ -110,7 +110,7 @@ jobs:
https_proxy: http://squid-proxy:3128
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Generate files
run: __tests__/create-cache-files.sh proxy test-cache
- name: Save cache
@ -133,7 +133,7 @@ jobs:
https_proxy: http://squid-proxy:3128
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Restore cache
uses: ./
with:

View File

@ -1,20 +1,20 @@
---
name: "@actions/cache"
version: 1.0.8
version: 3.0.4
type: npm
summary: Actions cache lib
homepage: https://github.com/actions/toolkit/tree/main/packages/cache
summary:
homepage:
license: mit
licenses:
- sources: LICENSE.md
text: |-
The MIT License (MIT)
- sources: LICENSE.md
text: |-
The MIT License (MIT)
Copyright 2019 GitHub
Copyright 2019 GitHub
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
notices: []

View File

@ -1,6 +1,6 @@
---
name: "@actions/core"
version: 1.6.0
version: 1.9.1
type: npm
summary: Actions core lib
homepage: https://github.com/actions/toolkit/tree/main/packages/core

View File

@ -1,9 +1,9 @@
---
name: "@actions/exec"
version: 1.1.0
version: 1.1.1
type: npm
summary: Actions exec lib
homepage: https://github.com/actions/toolkit/tree/main/packages/exec
summary:
homepage:
license: mit
licenses:
- sources: LICENSE.md

View File

@ -1,9 +1,9 @@
---
name: "@actions/http-client"
version: 1.0.11
version: 2.0.1
type: npm
summary: Actions Http Client
homepage: https://github.com/actions/http-client#readme
homepage: https://github.com/actions/toolkit/tree/main/packages/http-client
license: mit
licenses:
- sources: LICENSE

View File

@ -1,9 +1,9 @@
---
name: "@actions/io"
version: 1.1.1
version: 1.1.2
type: npm
summary: Actions io lib
homepage: https://github.com/actions/toolkit/tree/main/packages/io
summary:
homepage:
license: mit
licenses:
- sources: LICENSE.md

View File

@ -1,9 +1,9 @@
---
name: "@azure/core-asynciterator-polyfill"
version: 1.0.0
version: 1.0.2
type: npm
summary: Polyfill for IE/Node 8 for Symbol.asyncIterator
homepage: https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/core/core-asynciterator-polyfill
summary:
homepage:
license: mit
licenses:
- sources: LICENSE

View File

@ -1,6 +1,6 @@
---
name: "@azure/core-http"
version: 2.2.2
version: 2.2.4
type: npm
summary: Isomorphic client Runtime for Typescript/node.js/browser javascript client
libraries generated using AutoRest

View File

@ -1,10 +1,9 @@
---
name: "@azure/core-lro"
version: 2.2.1
version: 2.2.4
type: npm
summary: Isomorphic client library for supporting long-running operations in node.js
and browser.
homepage: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/core/core-lro/README.md
summary:
homepage:
license: mit
licenses:
- sources: LICENSE

View File

@ -1,6 +1,6 @@
---
name: "@azure/core-paging"
version: 1.2.0
version: 1.2.1
type: npm
summary: Core types for paging async iterable iterators
homepage: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/core-paging/README.md

View File

@ -1,10 +1,9 @@
---
name: "@azure/ms-rest-js"
version: 2.6.0
version: 2.6.1
type: npm
summary: Isomorphic client Runtime for Typescript/node.js/browser javascript client
libraries generated using AutoRest
homepage: https://github.com/Azure/ms-rest-js
summary:
homepage:
license: mit
licenses:
- sources: LICENSE

View File

@ -1,9 +1,9 @@
---
name: "@azure/storage-blob"
version: 12.8.0
version: 12.9.0
type: npm
summary: Microsoft Azure Storage SDK for JavaScript - Blob
homepage: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/storage-blob/
summary:
homepage:
license: mit
licenses:
- sources: LICENSE

View File

@ -1,6 +1,6 @@
---
name: "@opentelemetry/api"
version: 1.0.3
version: 1.0.4
type: npm
summary: Public API for OpenTelemetry
homepage: https://github.com/open-telemetry/opentelemetry-js-api#readme
@ -218,10 +218,6 @@ licenses:
[discussions-url]: https://github.com/open-telemetry/opentelemetry-js/discussions
[license-url]: https://github.com/open-telemetry/opentelemetry-js-api/blob/main/LICENSE
[license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat
[dependencies-image]: https://status.david-dm.org/gh/open-telemetry/opentelemetry-js-api.svg
[dependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js-api
[devDependencies-image]: https://status.david-dm.org/gh/open-telemetry/opentelemetry-js-api.svg?type=dev
[devDependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js-api?type=dev
[npm-url]: https://www.npmjs.com/package/@opentelemetry/api
[npm-img]: https://badge.fury.io/js/%40opentelemetry%2Fapi.svg
[docs-tracing]: https://github.com/open-telemetry/opentelemetry-js-api/blob/main/docs/tracing.md

View File

@ -1,9 +1,9 @@
---
name: "@types/node-fetch"
version: 2.5.12
version: 2.6.1
type: npm
summary: TypeScript definitions for node-fetch
homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node-fetch
summary:
homepage:
license: mit
licenses:
- sources: LICENSE

View File

@ -1,6 +1,6 @@
---
name: "@types/node"
version: 12.20.37
version: 16.11.33
type: npm
summary: TypeScript definitions for Node.js
homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node

View File

@ -1,6 +1,6 @@
---
name: node-fetch
version: 2.6.6
version: 2.6.7
type: npm
summary: A light-weight module that brings window.fetch to node.js
homepage: https://github.com/bitinn/node-fetch

145
README.md
View File

@ -2,43 +2,43 @@
This action allows caching dependencies and build outputs to improve workflow execution time.
<a href="https://github.com/actions/cache/actions?query=workflow%3ATests"><img alt="GitHub Actions status" src="https://github.com/actions/cache/workflows/Tests/badge.svg?branch=main&event=push"></a>
[![Tests](https://github.com/actions/cache/actions/workflows/workflow.yml/badge.svg)](https://github.com/actions/cache/actions/workflows/workflow.yml)
## Documentation
See ["Caching dependencies to speed up workflows"](https://help.github.com/github/automating-your-workflow-with-github-actions/caching-dependencies-to-speed-up-workflows).
## What's New
### v3
* Added support for caching from GHES 3.5.
* Fixed download issue for files > 2GB during restore.
* Updated the minimum runner version support from node 12 -> node 16.
* Fixed avoiding empty cache save when no files are available for caching.
* Fixed tar creation error while trying to create tar with path as `~/` home folder on `ubuntu-latest`.
* Fixed zstd failing on amazon linux 2.0 runners.
* Fixed cache not working with github workspace directory or current directory.
* Fixed the download stuck problem by introducing a timeout of 1 hour for cache downloads.
* Fix zstd not working for windows on gnu tar in issues.
* Allowing users to provide a custom timeout as input for aborting download of a cache segment using an environment variable `SEGMENT_DOWNLOAD_TIMEOUT_MIN`. Default is 60 minutes.
* Added support for multiple paths, [glob patterns](https://github.com/actions/toolkit/tree/main/packages/glob), and single file caches.
```yaml
- name: Cache multiple paths
uses: actions/cache@v2
with:
path: |
~/cache
!~/cache/exclude
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
```
* Increased performance and improved cache sizes using `zstd` compression for Linux and macOS runners
* Allowed caching for all events with a ref. See [events that trigger workflow](https://help.github.com/en/actions/reference/events-that-trigger-workflows) for info on which events do not have a `GITHUB_REF`
* Released the [`@actions/cache`](https://github.com/actions/toolkit/tree/main/packages/cache) npm package to allow other actions to utilize caching
* Added a best-effort cleanup step to delete the archive after extraction to reduce storage space
Refer [here](https://github.com/actions/cache/blob/v1/README.md) for previous versions
Refer [here](https://github.com/actions/cache/blob/v2/README.md) for previous versions
## Usage
### Pre-requisites
Create a workflow `.yml` file in your repositories `.github/workflows` directory. An [example workflow](#example-workflow) is available below. For more information, reference the GitHub Help Documentation for [Creating a workflow file](https://help.github.com/en/articles/configuring-a-workflow#creating-a-workflow-file).
If you are using this inside a container, a POSIX-compliant `tar` needs to be included and accessible in the execution path.
### Inputs
* `path` - A list of files, directories, and wildcard patterns to cache and restore. See [`@actions/glob`](https://github.com/actions/toolkit/tree/main/packages/glob) for supported patterns.
* `path` - A list of files, directories, and wildcard patterns to cache and restore. See [`@actions/glob`](https://github.com/actions/toolkit/tree/main/packages/glob) for supported patterns.
* `key` - An explicit key for restoring and saving the cache
* `restore-keys` - An ordered list of keys to use for restoring the cache if no cache hit occurred for key
* `restore-keys` - An ordered list of keys to use for restoring stale cache if no cache hit occurred for key. Note
`cache-hit` returns false in this case.
#### Environment Variables
* `SEGMENT_DOWNLOAD_TIMEOUT_MIN` - Segment download timeout (in minutes, default `60`) to abort download of the segment if not completed in the defined number of minutes. [Read more](#cache-segment-restore-timeout)
### Outputs
@ -47,7 +47,7 @@ Create a workflow `.yml` file in your repositories `.github/workflows` directory
> See [Skipping steps based on cache-hit](#Skipping-steps-based-on-cache-hit) for info on using this output
### Cache scopes
The cache is scoped to the key and branch. The default branch cache is available to other branches.
The cache is scoped to the key and branch. The default branch cache is available to other branches.
See [Matching a cache key](https://help.github.com/en/actions/configuring-and-managing-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key) for more info.
@ -63,11 +63,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Cache Primes
id: cache-primes
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: prime-numbers
key: ${{ runner.os }}-primes
@ -80,17 +80,22 @@ jobs:
run: /primes.sh -d prime-numbers
```
> Note: You must use the `cache` action in your workflow before you need to use the files that might be restored from the cache. If the provided `key` doesn't match an existing cache, a new cache is automatically created if the job completes successfully.
## Implementation Examples
Every programming language and framework has its own way of caching.
See [Examples](examples.md) for a list of `actions/cache` implementations for use with:
- [C# - Nuget](./examples.md#c---nuget)
- [C# - NuGet](./examples.md#c---nuget)
- [Clojure - Lein Deps](./examples.md#clojure---lein-deps)
- [D - DUB](./examples.md#d---dub)
- [Deno](./examples.md#deno)
- [Elixir - Mix](./examples.md#elixir---mix)
- [Go - Modules](./examples.md#go---modules)
- [Haskell - Cabal](./examples.md#haskell---cabal)
- [Haskell - Stack](./examples.md#haskell---stack)
- [Java - Gradle](./examples.md#java---gradle)
- [Java - Maven](./examples.md#java---maven)
- [Node - npm](./examples.md#node---npm)
@ -115,11 +120,11 @@ A cache key can include any of the contexts, functions, literals, and operators
For example, using the [`hashFiles`](https://help.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#hashfiles) function allows you to create a new cache when dependencies change.
```yaml
- uses: actions/cache@v2
- uses: actions/cache@v3
with:
path: |
path: |
path/to/dependencies
some/other/dependencies
some/other/dependencies
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
```
@ -133,7 +138,7 @@ Additionally, you can use arbitrary command output in a cache key, such as a dat
echo "::set-output name=date::$(/bin/date -u "+%Y%m%d")"
shell: bash
- uses: actions/cache@v2
- uses: actions/cache@v3
with:
path: path/to/dependencies
key: ${{ runner.os }}-${{ steps.get-date.outputs.date }}-${{ hashFiles('**/lockfiles') }}
@ -143,7 +148,7 @@ See [Using contexts to create cache keys](https://help.github.com/en/actions/con
## Cache Limits
A repository can have up to 5GB of caches. Once the 5GB limit is reached, older caches will be evicted based on when the cache was last accessed. Caches that are not accessed within the last week will also be evicted.
A repository can have up to 10GB of caches. Once the 10GB limit is reached, older caches will be evicted based on when the cache was last accessed. Caches that are not accessed within the last week will also be evicted.
## Skipping steps based on cache-hit
@ -152,9 +157,9 @@ Using the `cache-hit` output, subsequent steps (such as install or build) can be
Example:
```yaml
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: actions/cache@v2
- uses: actions/cache@v3
id: cache
with:
path: path/to/dependencies
@ -167,6 +172,82 @@ steps:
> Note: The `id` defined in `actions/cache` must match the `id` in the `if` statement (i.e. `steps.[ID].outputs.cache-hit`)
## Cache Version
Cache version is unique for a combination of compression tool used for compression of cache (Gzip, Zstd, etc based on runner OS) and the path of directories being cached. If two caches have different versions, they are identified as unique cache entries. This also means that a cache created on `windows-latest` runner can't be restored on `ubuntu-latest` as cache `Version`s are different.
Example: Below example will create 3 unique caches with same keys. Ubuntu and windows runners will use different compression technique and hence create two different caches. And `build-linux` will create two different caches as the `paths` are different.
```yaml
jobs:
build-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Cache Primes
id: cache-primes
uses: actions/cache@v3
with:
path: prime-numbers
key: primes
- name: Generate Prime Numbers
if: steps.cache-primes.outputs.cache-hit != 'true'
run: ./generate-primes.sh -d prime-numbers
- name: Cache Numbers
id: cache-numbers
uses: actions/cache@v3
with:
path: numbers
key: primes
- name: Generate Numbers
if: steps.cache-numbers.outputs.cache-hit != 'true'
run: ./generate-primes.sh -d numbers
build-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: Cache Primes
id: cache-primes
uses: actions/cache@v3
with:
path: prime-numbers
key: primes
- name: Generate Prime Numbers
if: steps.cache-primes.outputs.cache-hit != 'true'
run: ./generate-primes -d prime-numbers
```
## Cache segment restore timeout
A cache gets downloaded in multiple segments of fixed sizes (`1GB` for a `32-bit` runner and `2GB` for a `64-bit` runner). Sometimes, a segment download gets stuck which causes the workflow job to be stuck forever and fail. Version `v3.0.8` of `actions/cache` introduces a segment download timeout. The segment download timeout will allow the segment download to get aborted and hence allow the job to proceed with a cache miss.
Default value of this timeout is 60 minutes and can be customized by specifying an [environment variable](https://docs.github.com/en/actions/learn-github-actions/environment-variables) named `SEGMENT_DOWNLOAD_TIMEOUT_MINS` with timeout value in minutes.
## Known practices and workarounds
Following are some of the known practices/workarounds which community has used to fulfill specific requirements. You may choose to use them if suits your use case. Note these are not necessarily the only or the recommended solution.
#### Update a cache
A cache today is immutable and cannot be updated. But some use cases require the cache to be saved even though there was a "hit" during restore. To do so, use a `key` which is unique for every run and use `restore-keys` to restore the nearest cache. For example:
```
- name: update cache on every commit
uses: actions/cache@v3
with:
path: prime-numbers
key: primes-${{ runner.os }}-${{ github.run_id }} # Can use time based key as well
restore-keys: |
primes-${{ runner.os }}
```
Please note that this will create a new cache on every run and hence will consume the cache [quota](#cache-limits).
#### Use cache across feature branches
Reusing cache across feature branches is not allowed today to provide cache [isolation](https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#restrictions-for-accessing-a-cache). However if both feature branches are from the default branch, a good way to achieve this is to ensure that the default branch has a cache. This cache will then be consumable by both feature branches.
## Contributing
We would love for you to contribute to `actions/cache`, pull requests are welcome! Please see the [CONTRIBUTING.md](CONTRIBUTING.md) for more information.

31
RELEASES.md Normal file
View File

@ -0,0 +1,31 @@
# Releases
### 3.0.0
- Updated minimum runner version support from node 12 -> node 16
### 3.0.1
- Added support for caching from GHES 3.5.
- Fixed download issue for files > 2GB during restore.
### 3.0.2
- Added support for dynamic cache size cap on GHES.
### 3.0.3
- Fixed avoiding empty cache save when no files are available for caching. ([issue](https://github.com/actions/cache/issues/624))
### 3.0.4
- Fixed tar creation error while trying to create tar with path as `~/` home folder on `ubuntu-latest`. ([issue](https://github.com/actions/cache/issues/689))
### 3.0.5
- Removed error handling by consuming actions/cache 3.0 toolkit, Now cache server error handling will be done by toolkit. ([PR](https://github.com/actions/cache/pull/834))
### 3.0.6
- Fixed [#809](https://github.com/actions/cache/issues/809) - zstd -d: no such file or directory error
- Fixed [#833](https://github.com/actions/cache/issues/833) - cache doesn't work with github workspace directory
### 3.0.7
- Fixed [#810](https://github.com/actions/cache/issues/810) - download stuck issue. A new timeout is introduced in the download process to abort the download if it gets stuck and doesn't finish within an hour.
### 3.0.8
- Fix zstd not working for windows on gnu tar in issues [#888](https://github.com/actions/cache/issues/888) and [#891](https://github.com/actions/cache/issues/891).
- Allowing users to provide a custom timeout as input for aborting download of a cache segment using an environment variable `SEGMENT_DOWNLOAD_TIMEOUT_MIN`. Default is 60 minutes.

View File

@ -1,3 +1,4 @@
import * as cache from "@actions/cache";
import * as core from "@actions/core";
import { Events, Outputs, RefKey, State } from "../src/constants";
@ -5,6 +6,7 @@ import * as actionUtils from "../src/utils/actionUtils";
import * as testUtils from "../src/utils/testUtils";
jest.mock("@actions/core");
jest.mock("@actions/cache");
beforeAll(() => {
jest.spyOn(core, "getInput").mockImplementation((name, options) => {
@ -26,7 +28,7 @@ test("isGhes returns true if server url is not github.com", () => {
}
});
test("isGhes returns true when server url is github.com", () => {
test("isGhes returns false when server url is github.com", () => {
try {
process.env["GITHUB_SERVER_URL"] = "http://github.com";
expect(actionUtils.isGhes()).toBe(false);
@ -213,6 +215,39 @@ test("getInputAsArray handles empty lines correctly", () => {
expect(actionUtils.getInputAsArray("foo")).toEqual(["bar", "baz"]);
});
test("getInputAsArray sorts files correctly", () => {
testUtils.setInput(
"foo",
"bar\n!baz\nwaldo\nqux\nquux\ncorge\ngrault\ngarply"
);
expect(actionUtils.getInputAsArray("foo")).toEqual([
"!baz",
"bar",
"corge",
"garply",
"grault",
"quux",
"qux",
"waldo"
]);
});
test("getInputAsArray removes spaces after ! at the beginning", () => {
testUtils.setInput(
"foo",
"! bar\n! baz\n! qux\n!quux\ncorge\ngrault! garply\n!\r\t waldo"
);
expect(actionUtils.getInputAsArray("foo")).toEqual([
"!bar",
"!baz",
"!quux",
"!qux",
"!waldo",
"corge",
"grault! garply"
]);
});
test("getInputAsInt returns undefined if input not set", () => {
expect(actionUtils.getInputAsInt("undefined")).toBeUndefined();
});
@ -232,3 +267,41 @@ test("getInputAsInt throws if required and value missing", () => {
actionUtils.getInputAsInt("undefined", { required: true })
).toThrowError();
});
test("isCacheFeatureAvailable for ac enabled", () => {
jest.spyOn(cache, "isFeatureAvailable").mockImplementation(() => true);
expect(actionUtils.isCacheFeatureAvailable()).toBe(true);
});
test("isCacheFeatureAvailable for ac disabled on GHES", () => {
jest.spyOn(cache, "isFeatureAvailable").mockImplementation(() => false);
const message =
"Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.";
const infoMock = jest.spyOn(core, "info");
try {
process.env["GITHUB_SERVER_URL"] = "http://example.com";
expect(actionUtils.isCacheFeatureAvailable()).toBe(false);
expect(infoMock).toHaveBeenCalledWith(`[warning]${message}`);
} finally {
delete process.env["GITHUB_SERVER_URL"];
}
});
test("isCacheFeatureAvailable for ac disabled on dotcom", () => {
jest.spyOn(cache, "isFeatureAvailable").mockImplementation(() => false);
const message =
"An internal error has occurred in cache backend. Please check https://www.githubstatus.com/ for any ongoing issue in actions.";
const infoMock = jest.spyOn(core, "info");
try {
process.env["GITHUB_SERVER_URL"] = "http://github.com";
expect(actionUtils.isCacheFeatureAvailable()).toBe(false);
expect(infoMock).toHaveBeenCalledWith(`[warning]${message}`);
} finally {
delete process.env["GITHUB_SERVER_URL"];
}
});

View File

@ -34,6 +34,9 @@ beforeEach(() => {
process.env[RefKey] = "refs/heads/feature-branch";
jest.spyOn(actionUtils, "isGhes").mockImplementation(() => false);
jest.spyOn(actionUtils, "isCacheFeatureAvailable").mockImplementation(
() => true
);
});
afterEach(() => {
@ -55,10 +58,12 @@ test("restore with invalid event outputs warning", async () => {
expect(failedMock).toHaveBeenCalledTimes(0);
});
test("restore on GHES should no-op", async () => {
jest.spyOn(actionUtils, "isGhes").mockImplementation(() => true);
test("restore without AC available should no-op", async () => {
jest.spyOn(actionUtils, "isGhes").mockImplementation(() => false);
jest.spyOn(actionUtils, "isCacheFeatureAvailable").mockImplementation(
() => false
);
const logWarningMock = jest.spyOn(actionUtils, "logWarning");
const restoreCacheMock = jest.spyOn(cache, "restoreCache");
const setCacheHitOutputMock = jest.spyOn(actionUtils, "setCacheHitOutput");
@ -67,9 +72,54 @@ test("restore on GHES should no-op", async () => {
expect(restoreCacheMock).toHaveBeenCalledTimes(0);
expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1);
expect(setCacheHitOutputMock).toHaveBeenCalledWith(false);
expect(logWarningMock).toHaveBeenCalledWith(
"Cache action is not supported on GHES. See https://github.com/actions/cache/issues/505 for more details"
});
test("restore on GHES without AC available should no-op", async () => {
jest.spyOn(actionUtils, "isGhes").mockImplementation(() => true);
jest.spyOn(actionUtils, "isCacheFeatureAvailable").mockImplementation(
() => false
);
const restoreCacheMock = jest.spyOn(cache, "restoreCache");
const setCacheHitOutputMock = jest.spyOn(actionUtils, "setCacheHitOutput");
await run();
expect(restoreCacheMock).toHaveBeenCalledTimes(0);
expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1);
expect(setCacheHitOutputMock).toHaveBeenCalledWith(false);
});
test("restore on GHES with AC available ", async () => {
jest.spyOn(actionUtils, "isGhes").mockImplementation(() => true);
const path = "node_modules";
const key = "node-test";
testUtils.setInputs({
path: path,
key
});
const infoMock = jest.spyOn(core, "info");
const failedMock = jest.spyOn(core, "setFailed");
const stateMock = jest.spyOn(core, "saveState");
const setCacheHitOutputMock = jest.spyOn(actionUtils, "setCacheHitOutput");
const restoreCacheMock = jest
.spyOn(cache, "restoreCache")
.mockImplementationOnce(() => {
return Promise.resolve(key);
});
await run();
expect(restoreCacheMock).toHaveBeenCalledTimes(1);
expect(restoreCacheMock).toHaveBeenCalledWith([path], key, []);
expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1);
expect(setCacheHitOutputMock).toHaveBeenCalledWith(true);
expect(infoMock).toHaveBeenCalledWith(`Cache restored from key: ${key}`);
expect(failedMock).toHaveBeenCalledTimes(0);
});
test("restore with no path should fail", async () => {
@ -97,7 +147,7 @@ test("restore with no key", async () => {
test("restore with too many keys should fail", async () => {
const path = "node_modules";
const key = "node-test";
const restoreKeys = [...Array(20).keys()].map(x => x.toString());
const restoreKeys = [...Array(20).keys()].map(x => x.toString()).sort();
testUtils.setInputs({
path: path,
key,
@ -177,40 +227,6 @@ test("restore with no cache found", async () => {
);
});
test("restore with server error should fail", async () => {
const path = "node_modules";
const key = "node-test";
testUtils.setInputs({
path: path,
key
});
const logWarningMock = jest.spyOn(actionUtils, "logWarning");
const failedMock = jest.spyOn(core, "setFailed");
const stateMock = jest.spyOn(core, "saveState");
const restoreCacheMock = jest
.spyOn(cache, "restoreCache")
.mockImplementationOnce(() => {
throw new Error("HTTP Error Occurred");
});
const setCacheHitOutputMock = jest.spyOn(actionUtils, "setCacheHitOutput");
await run();
expect(restoreCacheMock).toHaveBeenCalledTimes(1);
expect(restoreCacheMock).toHaveBeenCalledWith([path], key, []);
expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
expect(logWarningMock).toHaveBeenCalledTimes(1);
expect(logWarningMock).toHaveBeenCalledWith("HTTP Error Occurred");
expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1);
expect(setCacheHitOutputMock).toHaveBeenCalledWith(false);
expect(failedMock).toHaveBeenCalledTimes(0);
});
test("restore with restore keys and no cache found", async () => {
const path = "node_modules";
const key = "node-test";

View File

@ -54,6 +54,9 @@ beforeEach(() => {
process.env[RefKey] = "refs/heads/feature-branch";
jest.spyOn(actionUtils, "isGhes").mockImplementation(() => false);
jest.spyOn(actionUtils, "isCacheFeatureAvailable").mockImplementation(
() => true
);
});
afterEach(() => {
@ -101,18 +104,67 @@ test("save with no primary key in state outputs warning", async () => {
expect(failedMock).toHaveBeenCalledTimes(0);
});
test("save on GHES should no-op", async () => {
jest.spyOn(actionUtils, "isGhes").mockImplementation(() => true);
test("save without AC available should no-op", async () => {
jest.spyOn(actionUtils, "isCacheFeatureAvailable").mockImplementation(
() => false
);
const logWarningMock = jest.spyOn(actionUtils, "logWarning");
const saveCacheMock = jest.spyOn(cache, "saveCache");
await run();
expect(saveCacheMock).toHaveBeenCalledTimes(0);
expect(logWarningMock).toHaveBeenCalledWith(
"Cache action is not supported on GHES. See https://github.com/actions/cache/issues/505 for more details"
});
test("save on ghes without AC available should no-op", async () => {
jest.spyOn(actionUtils, "isGhes").mockImplementation(() => true);
jest.spyOn(actionUtils, "isCacheFeatureAvailable").mockImplementation(
() => false
);
const saveCacheMock = jest.spyOn(cache, "saveCache");
await run();
expect(saveCacheMock).toHaveBeenCalledTimes(0);
});
test("save on GHES with AC available", async () => {
jest.spyOn(actionUtils, "isGhes").mockImplementation(() => true);
const failedMock = jest.spyOn(core, "setFailed");
const primaryKey = "Linux-node-bb828da54c148048dd17899ba9fda624811cfb43";
const savedCacheKey = "Linux-node-";
jest.spyOn(core, "getState")
// Cache Entry State
.mockImplementationOnce(() => {
return savedCacheKey;
})
// Cache Key State
.mockImplementationOnce(() => {
return primaryKey;
});
const inputPath = "node_modules";
testUtils.setInput(Inputs.Path, inputPath);
testUtils.setInput(Inputs.UploadChunkSize, "4000000");
const cacheId = 4;
const saveCacheMock = jest
.spyOn(cache, "saveCache")
.mockImplementationOnce(() => {
return Promise.resolve(cacheId);
});
await run();
expect(saveCacheMock).toHaveBeenCalledTimes(1);
expect(saveCacheMock).toHaveBeenCalledWith([inputPath], primaryKey, {
uploadChunkSize: 4000000
});
expect(failedMock).toHaveBeenCalledTimes(0);
});
test("save with exact match returns early", async () => {
@ -215,7 +267,6 @@ test("save with large cache outputs warning", async () => {
});
test("save with reserve cache failure outputs warning", async () => {
const infoMock = jest.spyOn(core, "info");
const logWarningMock = jest.spyOn(actionUtils, "logWarning");
const failedMock = jest.spyOn(core, "setFailed");
@ -254,10 +305,10 @@ test("save with reserve cache failure outputs warning", async () => {
expect.anything()
);
expect(infoMock).toHaveBeenCalledWith(
expect(logWarningMock).toHaveBeenCalledWith(
`Unable to reserve cache with key ${primaryKey}, another job may be creating this cache.`
);
expect(logWarningMock).toHaveBeenCalledTimes(0);
expect(logWarningMock).toHaveBeenCalledTimes(1);
expect(failedMock).toHaveBeenCalledTimes(0);
});

View File

@ -9,7 +9,7 @@ inputs:
description: 'An explicit key for restoring and saving the cache'
required: true
restore-keys:
description: 'An ordered list of keys to use for restoring the cache if no cache hit occurred for key'
description: 'An ordered list of keys to use for restoring stale cache if no cache hit occurred for key. Note `cache-hit` returns false in this case.'
required: false
upload-chunk-size:
description: 'The chunk size used to split up large files during upload, in bytes'
@ -18,7 +18,7 @@ outputs:
cache-hit:
description: 'A boolean value to indicate an exact match was found for the primary key'
runs:
using: 'node12'
using: 'node16'
main: 'dist/restore/index.js'
post: 'dist/save/index.js'
post-if: 'success()'

8047
dist/restore/index.js vendored

File diff suppressed because it is too large Load Diff

8031
dist/save/index.js vendored

File diff suppressed because it is too large Load Diff

View File

@ -1,21 +1,25 @@
# Examples
- [C# - NuGet](#c---nuget)
- [Clojure - Lein Deps](#clojure---lein-deps)
- [D - DUB](#d---dub)
- [POSIX](#posix)
- [Windows](#windows)
- [Elixir - Mix](#elixir---mix)
- [Go - Modules](#go---modules)
- [Deno](#deno)
- [Linux](#linux)
- [macOS](#macos)
- [Windows](#windows-1)
- [Elixir - Mix](#elixir---mix)
- [Erlang - Rebar3](#erlang--rebar3)
- [Go - Modules](#go---modules)
- [Linux](#linux-1)
- [macOS](#macos-1)
- [Windows](#windows-2)
- [Haskell - Cabal](#haskell---cabal)
- [Haskell - Stack](#haskell---stack)
- [Java - Gradle](#java---gradle)
- [Java - Maven](#java---maven)
- [Node - npm](#node---npm)
- [macOS and Ubuntu](#macos-and-ubuntu)
- [Windows](#windows-2)
- [Using multiple systems and `npm config`](#using-multiple-systems-and-npm-config)
- [Node - Lerna](#node---lerna)
- [Node - Yarn](#node---yarn)
- [Node - Yarn 2](#node---yarn-2)
@ -28,8 +32,6 @@
- [Using pip to get cache location](#using-pip-to-get-cache-location)
- [Python - pipenv](#python---pipenv)
- [R - renv](#r---renv)
- [Simple example](#simple-example-1)
- [Multiple OS's in a workflow](#multiple-oss-in-a-workflow-1)
- [Ruby - Bundler](#ruby---bundler)
- [Rust - Cargo](#rust---cargo)
- [Scala - SBT](#scala---sbt)
@ -42,7 +44,7 @@
Using [NuGet lock files](https://docs.microsoft.com/nuget/consume-packages/package-references-in-project-files#locking-dependencies):
```yaml
- uses: actions/cache@v2
- uses: actions/cache@v3
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
@ -51,10 +53,10 @@ Using [NuGet lock files](https://docs.microsoft.com/nuget/consume-packages/packa
```
Depending on the environment, huge packages might be pre-installed in the global cache folder.
With `actions/cache@v2` you can now exclude unwanted packages with [exclude pattern](https://github.com/actions/toolkit/tree/main/packages/glob#exclude-patterns)
With `actions/cache@v3` you can now exclude unwanted packages with [exclude pattern](https://github.com/actions/toolkit/tree/main/packages/glob#exclude-patterns)
```yaml
- uses: actions/cache@v2
- uses: actions/cache@v3
with:
path: |
~/.nuget/packages
@ -66,11 +68,12 @@ With `actions/cache@v2` you can now exclude unwanted packages with [exclude patt
Or you could move the cache folder like below.
>Note: This workflow does not work for projects that require files to be placed in user profile package folder
```yaml
env:
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
steps:
- uses: actions/cache@v2
- uses: actions/cache@v3
with:
path: ${{ github.workspace }}/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
@ -78,15 +81,28 @@ steps:
${{ runner.os }}-nuget-
```
## Clojure - Lein Deps
```yaml
- name: Cache lein project dependencies
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-clojure-${{ hashFiles('**/project.clj') }}
restore-keys: |
${{ runner.os }}-clojure
```
## D - DUB
### POSIX
```yaml
- uses: actions/cache@v2
- uses: actions/cache@v3
with:
path: ~/.dub
key: ${{ runner.os }}-dub-${{ hashFiles('**/dub.json') }}
key: ${{ runner.os }}-dub-${{ hashFiles('**/dub.selections.json') }}
restore-keys: |
${{ runner.os }}-dub-
```
@ -94,18 +110,53 @@ steps:
### Windows
```yaml
- uses: actions/cache@v2
- uses: actions/cache@v3
with:
path: ~\AppData\Local\dub
key: ${{ runner.os }}-dub-${{ hashFiles('**/dub.json') }}
key: ${{ runner.os }}-dub-${{ hashFiles('**/dub.selections.json') }}
restore-keys: |
${{ runner.os }}-dub-
```
## Deno
### Linux
```yaml
- uses: actions/cache@v3
with:
path: |
~/.deno
~/.cache/deno
key: ${{ runner.os }}-deno-${{ hashFiles('**/deps.ts') }}
```
### macOS
```yaml
- uses: actions/cache@v3
with:
path: |
~/.deno
~/Library/Caches/deno
key: ${{ runner.os }}-deno-${{ hashFiles('**/deps.ts') }}
```
### Windows
```yaml
- uses: actions/cache@v3
with:
path: |
~\.deno
~\AppData\Local\deno
key: ${{ runner.os }}-deno-${{ hashFiles('**/deps.ts') }}
```
## Elixir - Mix
```yaml
- uses: actions/cache@v2
- uses: actions/cache@v3
with:
path: |
deps
@ -115,12 +166,24 @@ steps:
${{ runner.os }}-mix-
```
## Erlang - Rebar3
```yaml
- uses: actions/cache@v2
with:
path: |
~/.cache/rebar3
_build
key: ${{ runner.os }}-erlang-${{ env.OTP_VERSION }}-${{ hashFiles('**/*rebar.lock') }}
restore-keys: |
${{ runner.os }}-erlang-${{ env.OTP_VERSION }}-
```
## Go - Modules
### Linux
```yaml
- uses: actions/cache@v2
- uses: actions/cache@v3
with:
path: |
~/.cache/go-build
@ -133,7 +196,7 @@ steps:
### macOS
```yaml
- uses: actions/cache@v2
- uses: actions/cache@v3
with:
path: |
~/Library/Caches/go-build
@ -146,11 +209,11 @@ steps:
### Windows
```yaml
- uses: actions/cache@v2
- uses: actions/cache@v3
with:
path: |
%LocalAppData%\go-build
~/go/pkg/mod
~\AppData\Local\go-build
~\go\pkg\mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
@ -162,13 +225,56 @@ We cache the elements of the Cabal store separately, as the entirety of `~/.caba
```yaml
- name: Cache ~/.cabal/packages, ~/.cabal/store and dist-newstyle
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: |
~/.cabal/packages
~/.cabal/store
dist-newstyle
key: ${{ runner.os }}-${{ matrix.ghc }}
key: ${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('**/*.cabal', '**/cabal.project', '**/cabal.project.freeze') }}
restore-keys: ${{ runner.os }}-${{ matrix.ghc }}-
```
## Haskell - Stack
### Linux or macOS
```yaml
- uses: actions/cache@v3
name: Cache ~/.stack
with:
path: ~/.stack
key: ${{ runner.os }}-stack-global-${{ hashFiles('stack.yaml') }}-${{ hashFiles('package.yaml') }}
restore-keys: |
${{ runner.os }}-stack-global-
- uses: actions/cache@v3
name: Cache .stack-work
with:
path: .stack-work
key: ${{ runner.os }}-stack-work-${{ hashFiles('stack.yaml') }}-${{ hashFiles('package.yaml') }}-${{ hashFiles('**/*.hs') }}
restore-keys: |
${{ runner.os }}-stack-work-
```
### Windows
```yaml
- uses: actions/cache@v3
name: Cache %APPDATA%\stack %LOCALAPPDATA%\Programs\stack
with:
path: |
~\AppData\Roaming\stack
~\AppData\Local\Programs\stack
key: ${{ runner.os }}-stack-global-${{ hashFiles('stack.yaml') }}-${{ hashFiles('package.yaml') }}
restore-keys: |
${{ runner.os }}-stack-global-
- uses: actions/cache@v3
name: Cache .stack-work
with:
path: .stack-work
key: ${{ runner.os }}-stack-work-${{ hashFiles('stack.yaml') }}-${{ hashFiles('package.yaml') }}-${{ hashFiles('**/*.hs') }}
restore-keys: |
${{ runner.os }}-stack-work-
```
## Java - Gradle
@ -176,7 +282,7 @@ We cache the elements of the Cabal store separately, as the entirety of `~/.caba
>Note: Ensure no Gradle daemons are running anymore when your workflow completes. Creating the cache package might fail due to locks being held by Gradle. Refer to the [Gradle Daemon documentation](https://docs.gradle.org/current/userguide/gradle_daemon.html) on how to disable or stop the Gradle Daemons.
```yaml
- uses: actions/cache@v2
- uses: actions/cache@v3
with:
path: |
~/.gradle/caches
@ -190,7 +296,7 @@ We cache the elements of the Cabal store separately, as the entirety of `~/.caba
```yaml
- name: Cache local Maven repository
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
@ -200,46 +306,18 @@ We cache the elements of the Cabal store separately, as the entirety of `~/.caba
## Node - npm
For npm, cache files are stored in `~/.npm` on Posix, or `%AppData%/npm-cache` on Windows. See https://docs.npmjs.com/cli/cache#cache
For npm, cache files are stored in `~/.npm` on Posix, or `~\AppData\npm-cache` on Windows, but it's possible to use `npm config get cache` to find the path on any platform. See [the npm docs](https://docs.npmjs.com/cli/cache#cache) for more details.
If using `npm config` to retrieve the cache directory, ensure you run [actions/setup-node](https://github.com/actions/setup-node) first to ensure your `npm` version is correct.
>Note: It is not recommended to cache `node_modules`, as it can break across Node versions and won't work with `npm ci`
### macOS and Ubuntu
```yaml
- uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
```
### Windows
```yaml
- name: Get npm cache directory
id: npm-cache
run: |
echo "::set-output name=dir::$(npm config get cache)"
- uses: actions/cache@v2
with:
path: ${{ steps.npm-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
```
### Using multiple systems and `npm config`
```yaml
- name: Get npm cache directory
id: npm-cache-dir
run: |
echo "::set-output name=dir::$(npm config get cache)"
- uses: actions/cache@v2
- uses: actions/cache@v3
id: npm-cache # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true'
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
@ -252,11 +330,9 @@ If using `npm config` to retrieve the cache directory, ensure you run [actions/s
```yaml
- name: restore lerna
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: |
node_modules
*/*/node_modules
path: **/node_modules
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
```
@ -268,7 +344,7 @@ The yarn cache directory will depend on your operating system and version of `ya
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
- uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
@ -286,7 +362,7 @@ The yarn 2 cache directory will depend on your config. See https://yarnpkg.com/c
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
- uses: actions/cache@v2
- uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
@ -301,7 +377,7 @@ Esy allows you to export built dependencies and import pre-built dependencies.
```yaml
- name: Restore Cache
id: restore-cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: _export
key: ${{ runner.os }}-esy-${{ hashFiles('esy.lock/index.json') }}
@ -330,7 +406,7 @@ Esy allows you to export built dependencies and import pre-built dependencies.
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- uses: actions/cache@v2
- uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
@ -351,7 +427,7 @@ Locations:
### Simple example
```yaml
- uses: actions/cache@v2
- uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
@ -364,7 +440,7 @@ Replace `~/.cache/pip` with the correct `path` if not using Ubuntu.
### Multiple OS's in a workflow
```yaml
- uses: actions/cache@v2
- uses: actions/cache@v3
if: startsWith(runner.os, 'Linux')
with:
path: ~/.cache/pip
@ -372,7 +448,7 @@ Replace `~/.cache/pip` with the correct `path` if not using Ubuntu.
restore-keys: |
${{ runner.os }}-pip-
- uses: actions/cache@v2
- uses: actions/cache@v3
if: startsWith(runner.os, 'macOS')
with:
path: ~/Library/Caches/pip
@ -380,7 +456,7 @@ Replace `~/.cache/pip` with the correct `path` if not using Ubuntu.
restore-keys: |
${{ runner.os }}-pip-
- uses: actions/cache@v2
- uses: actions/cache@v3
if: startsWith(runner.os, 'Windows')
with:
path: ~\AppData\Local\pip\Cache
@ -406,7 +482,7 @@ jobs:
- os: windows-latest
path: ~\AppData\Local\pip\Cache
steps:
- uses: actions/cache@v2
- uses: actions/cache@v3
with:
path: ${{ matrix.path }}
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
@ -424,7 +500,7 @@ jobs:
echo "::set-output name=dir::$(pip cache dir)"
- name: pip cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
@ -442,7 +518,7 @@ jobs:
- uses: actions/cache@v2
- uses: actions/cache@v3
with:
path: ~/.local/share/virtualenvs
key: ${{ runner.os }}-python-${{ steps.setup-python.outputs.python-version }}-pipenv-${{ hashFiles('Pipfile.lock') }}
@ -469,7 +545,7 @@ For renv, the cache directory will vary by OS. The `RENV_PATHS_ROOT` environment
cat("##[set-output name=r-version;]", R.Version()$version.string, sep = "")
shell: Rscript {0}
- name: Restore Renv package cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ${{ env.RENV_PATHS_ROOT }}
key: ${{ steps.get-version.outputs.os-version }}-${{ steps.get-version.outputs.r-version }}-${{ inputs.cache-version }}-${{ hashFiles('renv.lock') }}
@ -495,7 +571,7 @@ whenever possible:
## Rust - Cargo
```yaml
- uses: actions/cache@v2
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
@ -510,7 +586,7 @@ whenever possible:
```yaml
- name: Cache SBT
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: |
~/.ivy2/cache
@ -521,7 +597,7 @@ whenever possible:
## Swift, Objective-C - Carthage
```yaml
- uses: actions/cache@v2
- uses: actions/cache@v3
with:
path: Carthage
key: ${{ runner.os }}-carthage-${{ hashFiles('**/Cartfile.resolved') }}
@ -532,7 +608,7 @@ whenever possible:
## Swift, Objective-C - CocoaPods
```yaml
- uses: actions/cache@v2
- uses: actions/cache@v3
with:
path: Pods
key: ${{ runner.os }}-pods-${{ hashFiles('**/Podfile.lock') }}
@ -543,7 +619,7 @@ whenever possible:
## Swift - Swift Package Manager
```yaml
- uses: actions/cache@v2
- uses: actions/cache@v3
with:
path: .build
key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }}

View File

@ -17,7 +17,7 @@ const processStdoutWrite = process.stdout.write.bind(process.stdout);
process.stdout.write = (str, encoding, cb) => {
// Core library will directly call process.stdout.write for commands
// We don't want :: commands to be executed by the runner during tests
if (!str.match(/^::/)) {
if (!String(str).match(/^::/)) {
return processStdoutWrite(str, encoding, cb);
}
};

18573
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"name": "cache",
"version": "2.1.7",
"version": "3.0.8",
"private": true,
"description": "Cache dependencies and build outputs",
"main": "dist/restore/index.js",
@ -23,29 +23,29 @@
"author": "GitHub",
"license": "MIT",
"dependencies": {
"@actions/cache": "^1.0.8",
"@actions/core": "^1.2.6",
"@actions/exec": "^1.0.1",
"@actions/io": "^1.1.0"
"@actions/cache": "^3.0.4",
"@actions/core": "^1.9.1",
"@actions/exec": "^1.1.1",
"@actions/io": "^1.1.2"
},
"devDependencies": {
"@types/jest": "^24.0.13",
"@types/jest": "^27.5.0",
"@types/nock": "^11.1.0",
"@types/node": "^12.20.7",
"@typescript-eslint/eslint-plugin": "^2.7.0",
"@typescript-eslint/parser": "^2.7.0",
"@types/node": "^16.11.33",
"@typescript-eslint/eslint-plugin": "^5.22.0",
"@typescript-eslint/parser": "^5.22.0",
"@zeit/ncc": "^0.20.5",
"eslint": "^6.6.0",
"eslint-config-prettier": "^6.15.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jest": "^23.20.0",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-simple-import-sort": "^5.0.2",
"jest": "^24.8.0",
"jest-circus": "^24.7.1",
"nock": "^11.7.0",
"prettier": "^1.19.1",
"ts-jest": "^26.5.4",
"typescript": "^3.9.9"
"eslint": "^8.14.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jest": "^26.1.5",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-simple-import-sort": "^7.0.0",
"jest": "^28.0.3",
"jest-circus": "^27.5.1",
"nock": "^13.2.4",
"prettier": "^2.6.2",
"ts-jest": "^28.0.2",
"typescript": "^4.6.4"
}
}
}

View File

@ -6,10 +6,7 @@ import * as utils from "./utils/actionUtils";
async function run(): Promise<void> {
try {
if (utils.isGhes()) {
utils.logWarning(
"Cache action is not supported on GHES. See https://github.com/actions/cache/issues/505 for more details"
);
if (!utils.isCacheFeatureAvailable()) {
utils.setCacheHitOutput(false);
return;
}
@ -32,39 +29,31 @@ async function run(): Promise<void> {
required: true
});
try {
const cacheKey = await cache.restoreCache(
cachePaths,
primaryKey,
restoreKeys
const cacheKey = await cache.restoreCache(
cachePaths,
primaryKey,
restoreKeys
);
if (!cacheKey) {
core.info(
`Cache not found for input keys: ${[
primaryKey,
...restoreKeys
].join(", ")}`
);
if (!cacheKey) {
core.info(
`Cache not found for input keys: ${[
primaryKey,
...restoreKeys
].join(", ")}`
);
return;
}
// Store the matched cache key
utils.setCacheState(cacheKey);
const isExactKeyMatch = utils.isExactKeyMatch(primaryKey, cacheKey);
utils.setCacheHitOutput(isExactKeyMatch);
core.info(`Cache restored from key: ${cacheKey}`);
} catch (error) {
if (error.name === cache.ValidationError.name) {
throw error;
} else {
utils.logWarning(error.message);
utils.setCacheHitOutput(false);
}
return;
}
} catch (error) {
core.setFailed(error.message);
// Store the matched cache key
utils.setCacheState(cacheKey);
const isExactKeyMatch = utils.isExactKeyMatch(primaryKey, cacheKey);
utils.setCacheHitOutput(isExactKeyMatch);
core.info(`Cache restored from key: ${cacheKey}`);
} catch (error: unknown) {
core.setFailed((error as Error).message);
}
}

View File

@ -11,10 +11,7 @@ process.on("uncaughtException", e => utils.logWarning(e.message));
async function run(): Promise<void> {
try {
if (utils.isGhes()) {
utils.logWarning(
"Cache action is not supported on GHES. See https://github.com/actions/cache/issues/505 for more details"
);
if (!utils.isCacheFeatureAvailable()) {
return;
}
@ -47,22 +44,15 @@ async function run(): Promise<void> {
required: true
});
try {
await cache.saveCache(cachePaths, primaryKey, {
uploadChunkSize: utils.getInputAsInt(Inputs.UploadChunkSize)
});
const cacheId = await cache.saveCache(cachePaths, primaryKey, {
uploadChunkSize: utils.getInputAsInt(Inputs.UploadChunkSize)
});
if (cacheId != -1) {
core.info(`Cache saved with key: ${primaryKey}`);
} catch (error) {
if (error.name === cache.ValidationError.name) {
throw error;
} else if (error.name === cache.ReserveCacheError.name) {
core.info(error.message);
} else {
utils.logWarning(error.message);
}
}
} catch (error) {
utils.logWarning(error.message);
} catch (error: unknown) {
utils.logWarning((error as Error).message);
}
}

View File

@ -1,3 +1,4 @@
import * as cache from "@actions/cache";
import * as core from "@actions/core";
import { Outputs, RefKey, State } from "../constants";
@ -60,8 +61,9 @@ export function getInputAsArray(
return core
.getInput(name, options)
.split("\n")
.map(s => s.trim())
.filter(x => x !== "");
.map(s => s.replace(/^!\s+/, "!").trim())
.filter(x => x !== "")
.sort();
}
export function getInputAsInt(
@ -74,3 +76,20 @@ export function getInputAsInt(
}
return value;
}
export function isCacheFeatureAvailable(): boolean {
if (!cache.isFeatureAvailable()) {
if (isGhes()) {
logWarning(
"Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not."
);
} else {
logWarning(
"An internal error has occurred in cache backend. Please check https://www.githubstatus.com/ for any ongoing issue in actions."
);
}
return false;
}
return true;
}