mirror of
				https://github.com/actions/cache.git
				synced 2025-10-25 04:35:11 +07:00 
			
		
		
		
	Compare commits
	
		
			28 Commits
		
	
	
		
			bishal/deb
			...
			yacaovsnc/
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| c36458f13b | |||
| 13aacd865c | |||
| 53b35c5439 | |||
| 65b8989fab | |||
| d0be34d544 | |||
| 66cf064d47 | |||
| 1326563738 | |||
| e12d46a63a | |||
| 1baebfc3ba | |||
| eb94f1a6bf | |||
| e71876755e | |||
| 01229828ff | |||
| 3185ecfd61 | |||
| 25618a0a67 | |||
| a0a285ffd4 | |||
| b00bedba4a | |||
| 99d573b49d | |||
| 6f0a1fdd90 | |||
| 2001ca4114 | |||
| 0e9aed0d0d | |||
| 3b7dac1789 | |||
| b1378c8403 | |||
| 704facf57e | |||
| 17e2888746 | |||
| 667d8fdfa2 | |||
| f7ebb81a3f | |||
| 67b839edb6 | |||
| 57f0e3f198 | 
							
								
								
									
										2
									
								
								.github/workflows/check-dist.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/workflows/check-dist.yml
									
									
									
									
										vendored
									
									
								
							| @ -15,3 +15,5 @@ jobs: | ||||
|   call-check-dist: | ||||
|     name: Check dist/ | ||||
|     uses: actions/reusable-workflows/.github/workflows/check-dist.yml@main | ||||
|     with: | ||||
|       node-version: "20.x" | ||||
|  | ||||
							
								
								
									
										6
									
								
								.github/workflows/issue-opened-workflow.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								.github/workflows/issue-opened-workflow.yml
									
									
									
									
										vendored
									
									
								
							| @ -14,9 +14,3 @@ jobs: | ||||
|     - name: add_assignees | ||||
|       run: | | ||||
|         curl -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN}}" https://api.github.com/repos/${{github.repository}}/issues/${{ github.event.issue.number}}/assignees -d '{"assignees":["${{steps.oncall.outputs.CURRENT}}"]}' | ||||
|  | ||||
|     - uses: actions/add-to-project@v0.4.0 | ||||
|       name: Add to Project Board | ||||
|       with: | ||||
|         project-url: https://github.com/orgs/actions/projects/12                        | ||||
|         github-token: ${{ secrets.CACHE_BOARD_TOKEN }} | ||||
|  | ||||
							
								
								
									
										6
									
								
								.github/workflows/pr-opened-workflow.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								.github/workflows/pr-opened-workflow.yml
									
									
									
									
										vendored
									
									
								
							| @ -18,9 +18,3 @@ jobs: | ||||
|     - name: Add Assignee | ||||
|       run: | | ||||
|         curl -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN}}" https://api.github.com/repos/${{github.repository}}/issues/${{ github.event.pull_request.number}}/assignees -d '{"assignees":["${{steps.oncall.outputs.CURRENT}}"]}'     | ||||
|  | ||||
|     - uses: actions/add-to-project@v0.4.0 | ||||
|       name: Add to Project Board | ||||
|       with: | ||||
|         project-url: https://github.com/orgs/actions/projects/12                        | ||||
|         github-token: ${{ secrets.CACHE_BOARD_TOKEN }} | ||||
|  | ||||
							
								
								
									
										4
									
								
								.github/workflows/workflow.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								.github/workflows/workflow.yml
									
									
									
									
										vendored
									
									
								
							| @ -21,10 +21,10 @@ jobs: | ||||
|     steps: | ||||
|     - name: Checkout | ||||
|       uses: actions/checkout@v3 | ||||
|     - name: Setup Node.js 16.x | ||||
|     - name: Setup Node.js 20.x | ||||
|       uses: actions/setup-node@v3 | ||||
|       with: | ||||
|         node-version: 16.x | ||||
|         node-version: 20.x | ||||
|         cache: npm | ||||
|     - run: npm ci | ||||
|     - name: Prettier Format Check | ||||
|  | ||||
							
								
								
									
										8
									
								
								.licenses/npm/@actions/cache.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										8
									
								
								.licenses/npm/@actions/cache.dep.yml
									
									
									
										generated
									
									
									
								
							| @ -1,12 +1,12 @@ | ||||
| --- | ||||
| name: "@actions/cache" | ||||
| version: 3.2.1 | ||||
| version: 3.2.3 | ||||
| type: npm | ||||
| summary: | ||||
| homepage: | ||||
| summary: Actions cache lib | ||||
| homepage: https://github.com/actions/toolkit/tree/main/packages/cache | ||||
| license: mit | ||||
| licenses: | ||||
|   - sources: LICENSE.md | ||||
| - sources: LICENSE.md | ||||
|   text: |- | ||||
|     The MIT License (MIT) | ||||
|  | ||||
|  | ||||
							
								
								
									
										2
									
								
								.licenses/npm/@actions/http-client.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										2
									
								
								.licenses/npm/@actions/http-client.dep.yml
									
									
									
										generated
									
									
									
								
							| @ -1,6 +1,6 @@ | ||||
| --- | ||||
| name: "@actions/http-client" | ||||
| version: 2.0.1 | ||||
| version: 2.1.1 | ||||
| type: npm | ||||
| summary: Actions Http Client | ||||
| homepage: https://github.com/actions/toolkit/tree/main/packages/http-client | ||||
|  | ||||
							
								
								
									
										2
									
								
								.licenses/npm/@azure/core-http.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										2
									
								
								.licenses/npm/@azure/core-http.dep.yml
									
									
									
										generated
									
									
									
								
							| @ -1,6 +1,6 @@ | ||||
| --- | ||||
| name: "@azure/core-http" | ||||
| version: 3.0.0 | ||||
| version: 3.0.4 | ||||
| type: npm | ||||
| summary: Isomorphic client Runtime for Typescript/node.js/browser javascript client | ||||
|   libraries generated using AutoRest | ||||
|  | ||||
							
								
								
									
										7
									
								
								.licenses/npm/@azure/ms-rest-js.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										7
									
								
								.licenses/npm/@azure/ms-rest-js.dep.yml
									
									
									
										generated
									
									
									
								
							| @ -1,9 +1,10 @@ | ||||
| --- | ||||
| name: "@azure/ms-rest-js" | ||||
| version: 2.6.1 | ||||
| version: 2.7.0 | ||||
| type: npm | ||||
| summary:  | ||||
| homepage:  | ||||
| summary: Isomorphic client Runtime for Typescript/node.js/browser javascript client | ||||
|   libraries generated using AutoRest | ||||
| homepage: https://github.com/Azure/ms-rest-js | ||||
| license: mit | ||||
| licenses: | ||||
| - sources: LICENSE | ||||
|  | ||||
							
								
								
									
										34
									
								
								.licenses/npm/ip-regex.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										34
									
								
								.licenses/npm/ip-regex.dep.yml
									
									
									
										generated
									
									
									
								
							| @ -1,34 +0,0 @@ | ||||
| --- | ||||
| name: ip-regex | ||||
| version: 2.1.0 | ||||
| type: npm | ||||
| summary: Regular expression for matching IP addresses (IPv4 & IPv6) | ||||
| homepage: https://github.com/sindresorhus/ip-regex#readme | ||||
| license: mit | ||||
| licenses: | ||||
| - sources: license | ||||
|   text: | | ||||
|     The MIT License (MIT) | ||||
|  | ||||
|     Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com) | ||||
|  | ||||
|     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 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. | ||||
| - sources: readme.md | ||||
|   text: MIT © [Sindre Sorhus](https://sindresorhus.com) | ||||
| notices: [] | ||||
							
								
								
									
										43
									
								
								.licenses/npm/psl.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										43
									
								
								.licenses/npm/psl.dep.yml
									
									
									
										generated
									
									
									
								
							| @ -1,43 +0,0 @@ | ||||
| --- | ||||
| name: psl | ||||
| version: 1.8.0 | ||||
| type: npm | ||||
| summary: Domain name parser based on the Public Suffix List | ||||
| homepage: https://github.com/lupomontero/psl#readme | ||||
| license: mit | ||||
| licenses: | ||||
| - sources: LICENSE | ||||
|   text: | | ||||
|     The MIT License (MIT) | ||||
|  | ||||
|     Copyright (c) 2017 Lupo Montero lupomontero@gmail.com | ||||
|  | ||||
|     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 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. | ||||
| - sources: README.md | ||||
|   text: |- | ||||
|     The MIT License (MIT) | ||||
|  | ||||
|     Copyright (c) 2017 Lupo Montero <lupomontero@gmail.com> | ||||
|  | ||||
|     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 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: [] | ||||
							
								
								
									
										34
									
								
								.licenses/npm/punycode.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										34
									
								
								.licenses/npm/punycode.dep.yml
									
									
									
										generated
									
									
									
								
							| @ -1,34 +0,0 @@ | ||||
| --- | ||||
| name: punycode | ||||
| version: 2.1.1 | ||||
| type: npm | ||||
| summary: A robust Punycode converter that fully complies to RFC 3492 and RFC 5891, | ||||
|   and works on nearly all JavaScript platforms. | ||||
| homepage: https://mths.be/punycode | ||||
| license: mit | ||||
| licenses: | ||||
| - sources: LICENSE-MIT.txt | ||||
|   text: | | ||||
|     Copyright Mathias Bynens <https://mathiasbynens.be/> | ||||
|  | ||||
|     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 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. | ||||
| - sources: README.md | ||||
|   text: Punycode.js is available under the [MIT](https://mths.be/mit) license. | ||||
| notices: [] | ||||
							
								
								
									
										4
									
								
								.licenses/npm/semver.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										4
									
								
								.licenses/npm/semver.dep.yml
									
									
									
										generated
									
									
									
								
							| @ -1,9 +1,9 @@ | ||||
| --- | ||||
| name: semver | ||||
| version: 6.3.0 | ||||
| version: 6.3.1 | ||||
| type: npm | ||||
| summary: The semantic version parser used by npm. | ||||
| homepage: https://github.com/npm/node-semver#readme | ||||
| homepage:  | ||||
| license: isc | ||||
| licenses: | ||||
| - sources: LICENSE | ||||
|  | ||||
							
								
								
									
										23
									
								
								.licenses/npm/tough-cookie.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										23
									
								
								.licenses/npm/tough-cookie.dep.yml
									
									
									
										generated
									
									
									
								
							| @ -1,23 +0,0 @@ | ||||
| --- | ||||
| name: tough-cookie | ||||
| version: 3.0.1 | ||||
| type: npm | ||||
| summary: RFC6265 Cookies and Cookie Jar for node.js | ||||
| homepage: https://github.com/salesforce/tough-cookie | ||||
| license: bsd-3-clause | ||||
| licenses: | ||||
| - sources: LICENSE | ||||
|   text: | | ||||
|     Copyright (c) 2015, Salesforce.com, Inc. | ||||
|     All rights reserved. | ||||
|  | ||||
|     Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | ||||
|  | ||||
|     1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||||
|  | ||||
|     2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | ||||
|  | ||||
|     3. Neither the name of Salesforce.com nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. | ||||
|  | ||||
|     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||
| notices: [] | ||||
							
								
								
									
										2
									
								
								.licenses/npm/xml2js.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										2
									
								
								.licenses/npm/xml2js.dep.yml
									
									
									
										generated
									
									
									
								
							| @ -1,6 +1,6 @@ | ||||
| --- | ||||
| name: xml2js | ||||
| version: 0.4.23 | ||||
| version: 0.5.0 | ||||
| type: npm | ||||
| summary: Simple XML to JavaScript object converter. | ||||
| homepage: https://github.com/Leonidas-from-XIV/node-xml2js | ||||
|  | ||||
| @ -14,6 +14,11 @@ See ["Caching dependencies to speed up workflows"](https://docs.github.com/en/ac | ||||
|  | ||||
| ## What's New | ||||
|  | ||||
| ### v4 | ||||
|  | ||||
| * Updated to node 20 | ||||
| * Added a `save-always` flag to save the cache even if a prior step fails | ||||
|  | ||||
| ### v3 | ||||
|  | ||||
| * Added support for caching in GHES 3.5+. | ||||
|  | ||||
							
								
								
									
										13
									
								
								RELEASES.md
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								RELEASES.md
									
									
									
									
									
								
							| @ -107,3 +107,16 @@ | ||||
| ### 3.3.1 | ||||
|  | ||||
| - Reduced segment size to 128MB and segment timeout to 10 minutes to fail fast in case the cache download is stuck. | ||||
|  | ||||
| ### 3.3.2 | ||||
|  | ||||
| - Fixes bug with Azure SDK causing blob downloads to get stuck. | ||||
|  | ||||
| ### 3.3.3 | ||||
|  | ||||
| - Updates @actions/cache to v3.2.3 to fix accidental mutated path arguments to `getCacheVersion` [actions/toolkit#1378](https://github.com/actions/toolkit/pull/1378) | ||||
| - Additional audit fixes of npm package(s) | ||||
|  | ||||
| ### 4.0.0 | ||||
|  | ||||
| - Updated minimum runner version support from node 12 -> node 20 | ||||
|  | ||||
| @ -2,7 +2,7 @@ import * as cache from "@actions/cache"; | ||||
| import * as core from "@actions/core"; | ||||
|  | ||||
| import { Events, RefKey } from "../src/constants"; | ||||
| import run from "../src/restore"; | ||||
| import { restoreRun } from "../src/restoreImpl"; | ||||
| import * as actionUtils from "../src/utils/actionUtils"; | ||||
| import * as testUtils from "../src/utils/testUtils"; | ||||
|  | ||||
| @ -71,7 +71,7 @@ test("restore with no cache found", async () => { | ||||
|             return Promise.resolve(undefined); | ||||
|         }); | ||||
|  | ||||
|     await run(); | ||||
|     await restoreRun(); | ||||
|  | ||||
|     expect(restoreCacheMock).toHaveBeenCalledTimes(1); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith( | ||||
| @ -114,7 +114,7 @@ test("restore with restore keys and no cache found", async () => { | ||||
|             return Promise.resolve(undefined); | ||||
|         }); | ||||
|  | ||||
|     await run(); | ||||
|     await restoreRun(); | ||||
|  | ||||
|     expect(restoreCacheMock).toHaveBeenCalledTimes(1); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith( | ||||
| @ -156,7 +156,7 @@ test("restore with cache found for key", async () => { | ||||
|             return Promise.resolve(key); | ||||
|         }); | ||||
|  | ||||
|     await run(); | ||||
|     await restoreRun(); | ||||
|  | ||||
|     expect(restoreCacheMock).toHaveBeenCalledTimes(1); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith( | ||||
| @ -201,7 +201,7 @@ test("restore with cache found for restore key", async () => { | ||||
|             return Promise.resolve(restoreKey); | ||||
|         }); | ||||
|  | ||||
|     await run(); | ||||
|     await restoreRun(); | ||||
|  | ||||
|     expect(restoreCacheMock).toHaveBeenCalledTimes(1); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith( | ||||
| @ -246,7 +246,7 @@ test("Fail restore when fail on cache miss is enabled and primary + restore keys | ||||
|             return Promise.resolve(undefined); | ||||
|         }); | ||||
|  | ||||
|     await run(); | ||||
|     await restoreRun(); | ||||
|  | ||||
|     expect(restoreCacheMock).toHaveBeenCalledTimes(1); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith( | ||||
| @ -289,7 +289,7 @@ test("restore when fail on cache miss is enabled and primary key doesn't match r | ||||
|             return Promise.resolve(restoreKey); | ||||
|         }); | ||||
|  | ||||
|     await run(); | ||||
|     await restoreRun(); | ||||
|  | ||||
|     expect(restoreCacheMock).toHaveBeenCalledTimes(1); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith( | ||||
| @ -335,7 +335,7 @@ test("restore with fail on cache miss disabled and no cache found", async () => | ||||
|             return Promise.resolve(undefined); | ||||
|         }); | ||||
|  | ||||
|     await run(); | ||||
|     await restoreRun(); | ||||
|  | ||||
|     expect(restoreCacheMock).toHaveBeenCalledTimes(1); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith( | ||||
|  | ||||
| @ -2,7 +2,7 @@ import * as cache from "@actions/cache"; | ||||
| import * as core from "@actions/core"; | ||||
|  | ||||
| import { Events, Inputs, RefKey } from "../src/constants"; | ||||
| import run from "../src/restoreImpl"; | ||||
| import { restoreImpl } from "../src/restoreImpl"; | ||||
| import { StateProvider } from "../src/stateProvider"; | ||||
| import * as actionUtils from "../src/utils/actionUtils"; | ||||
| import * as testUtils from "../src/utils/testUtils"; | ||||
| @ -60,7 +60,7 @@ test("restore with invalid event outputs warning", async () => { | ||||
|     const invalidEvent = "commit_comment"; | ||||
|     process.env[Events.Key] = invalidEvent; | ||||
|     delete process.env[RefKey]; | ||||
|     await run(new StateProvider()); | ||||
|     await restoreImpl(new StateProvider()); | ||||
|     expect(logWarningMock).toHaveBeenCalledWith( | ||||
|         `Event Validation Error: The event type ${invalidEvent} is not supported because it's not tied to a branch or tag ref.` | ||||
|     ); | ||||
| @ -76,7 +76,7 @@ test("restore without AC available should no-op", async () => { | ||||
|     const restoreCacheMock = jest.spyOn(cache, "restoreCache"); | ||||
|     const setCacheHitOutputMock = jest.spyOn(core, "setOutput"); | ||||
|  | ||||
|     await run(new StateProvider()); | ||||
|     await restoreImpl(new StateProvider()); | ||||
|  | ||||
|     expect(restoreCacheMock).toHaveBeenCalledTimes(0); | ||||
|     expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1); | ||||
| @ -92,7 +92,7 @@ test("restore on GHES without AC available should no-op", async () => { | ||||
|     const restoreCacheMock = jest.spyOn(cache, "restoreCache"); | ||||
|     const setCacheHitOutputMock = jest.spyOn(core, "setOutput"); | ||||
|  | ||||
|     await run(new StateProvider()); | ||||
|     await restoreImpl(new StateProvider()); | ||||
|  | ||||
|     expect(restoreCacheMock).toHaveBeenCalledTimes(0); | ||||
|     expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1); | ||||
| @ -119,7 +119,7 @@ test("restore on GHES with AC available ", async () => { | ||||
|             return Promise.resolve(key); | ||||
|         }); | ||||
|  | ||||
|     await run(new StateProvider()); | ||||
|     await restoreImpl(new StateProvider()); | ||||
|  | ||||
|     expect(restoreCacheMock).toHaveBeenCalledTimes(1); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith( | ||||
| @ -143,7 +143,7 @@ test("restore on GHES with AC available ", async () => { | ||||
| test("restore with no path should fail", async () => { | ||||
|     const failedMock = jest.spyOn(core, "setFailed"); | ||||
|     const restoreCacheMock = jest.spyOn(cache, "restoreCache"); | ||||
|     await run(new StateProvider()); | ||||
|     await restoreImpl(new StateProvider()); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledTimes(0); | ||||
|     // this input isn't necessary for restore b/c tarball contains entries relative to workspace | ||||
|     expect(failedMock).not.toHaveBeenCalledWith( | ||||
| @ -155,7 +155,7 @@ test("restore with no key", async () => { | ||||
|     testUtils.setInput(Inputs.Path, "node_modules"); | ||||
|     const failedMock = jest.spyOn(core, "setFailed"); | ||||
|     const restoreCacheMock = jest.spyOn(cache, "restoreCache"); | ||||
|     await run(new StateProvider()); | ||||
|     await restoreImpl(new StateProvider()); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledTimes(0); | ||||
|     expect(failedMock).toHaveBeenCalledWith( | ||||
|         "Input required and not supplied: key" | ||||
| @ -174,7 +174,7 @@ test("restore with too many keys should fail", async () => { | ||||
|     }); | ||||
|     const failedMock = jest.spyOn(core, "setFailed"); | ||||
|     const restoreCacheMock = jest.spyOn(cache, "restoreCache"); | ||||
|     await run(new StateProvider()); | ||||
|     await restoreImpl(new StateProvider()); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledTimes(1); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith( | ||||
|         [path], | ||||
| @ -200,7 +200,7 @@ test("restore with large key should fail", async () => { | ||||
|     }); | ||||
|     const failedMock = jest.spyOn(core, "setFailed"); | ||||
|     const restoreCacheMock = jest.spyOn(cache, "restoreCache"); | ||||
|     await run(new StateProvider()); | ||||
|     await restoreImpl(new StateProvider()); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledTimes(1); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith( | ||||
|         [path], | ||||
| @ -226,7 +226,7 @@ test("restore with invalid key should fail", async () => { | ||||
|     }); | ||||
|     const failedMock = jest.spyOn(core, "setFailed"); | ||||
|     const restoreCacheMock = jest.spyOn(cache, "restoreCache"); | ||||
|     await run(new StateProvider()); | ||||
|     await restoreImpl(new StateProvider()); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledTimes(1); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith( | ||||
|         [path], | ||||
| @ -260,7 +260,7 @@ test("restore with no cache found", async () => { | ||||
|             return Promise.resolve(undefined); | ||||
|         }); | ||||
|  | ||||
|     await run(new StateProvider()); | ||||
|     await restoreImpl(new StateProvider()); | ||||
|  | ||||
|     expect(restoreCacheMock).toHaveBeenCalledTimes(1); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith( | ||||
| @ -301,7 +301,7 @@ test("restore with restore keys and no cache found", async () => { | ||||
|             return Promise.resolve(undefined); | ||||
|         }); | ||||
|  | ||||
|     await run(new StateProvider()); | ||||
|     await restoreImpl(new StateProvider()); | ||||
|  | ||||
|     expect(restoreCacheMock).toHaveBeenCalledTimes(1); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith( | ||||
| @ -341,7 +341,7 @@ test("restore with cache found for key", async () => { | ||||
|             return Promise.resolve(key); | ||||
|         }); | ||||
|  | ||||
|     await run(new StateProvider()); | ||||
|     await restoreImpl(new StateProvider()); | ||||
|  | ||||
|     expect(restoreCacheMock).toHaveBeenCalledTimes(1); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith( | ||||
| @ -383,7 +383,7 @@ test("restore with cache found for restore key", async () => { | ||||
|             return Promise.resolve(restoreKey); | ||||
|         }); | ||||
|  | ||||
|     await run(new StateProvider()); | ||||
|     await restoreImpl(new StateProvider()); | ||||
|  | ||||
|     expect(restoreCacheMock).toHaveBeenCalledTimes(1); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith( | ||||
| @ -424,7 +424,7 @@ test("restore with lookup-only set", async () => { | ||||
|             return Promise.resolve(key); | ||||
|         }); | ||||
|  | ||||
|     await run(new StateProvider()); | ||||
|     await restoreImpl(new StateProvider()); | ||||
|  | ||||
|     expect(restoreCacheMock).toHaveBeenCalledTimes(1); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith( | ||||
|  | ||||
| @ -2,7 +2,7 @@ import * as cache from "@actions/cache"; | ||||
| import * as core from "@actions/core"; | ||||
|  | ||||
| import { Events, RefKey } from "../src/constants"; | ||||
| import run from "../src/restoreOnly"; | ||||
| import { restoreOnlyRun } from "../src/restoreImpl"; | ||||
| import * as actionUtils from "../src/utils/actionUtils"; | ||||
| import * as testUtils from "../src/utils/testUtils"; | ||||
|  | ||||
| @ -72,7 +72,7 @@ test("restore with no cache found", async () => { | ||||
|             return Promise.resolve(undefined); | ||||
|         }); | ||||
|  | ||||
|     await run(); | ||||
|     await restoreOnlyRun(); | ||||
|  | ||||
|     expect(restoreCacheMock).toHaveBeenCalledTimes(1); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith( | ||||
| @ -114,7 +114,7 @@ test("restore with restore keys and no cache found", async () => { | ||||
|             return Promise.resolve(undefined); | ||||
|         }); | ||||
|  | ||||
|     await run(); | ||||
|     await restoreOnlyRun(); | ||||
|  | ||||
|     expect(restoreCacheMock).toHaveBeenCalledTimes(1); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith( | ||||
| @ -153,7 +153,7 @@ test("restore with cache found for key", async () => { | ||||
|             return Promise.resolve(key); | ||||
|         }); | ||||
|  | ||||
|     await run(); | ||||
|     await restoreOnlyRun(); | ||||
|  | ||||
|     expect(restoreCacheMock).toHaveBeenCalledTimes(1); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith( | ||||
| @ -196,7 +196,7 @@ test("restore with cache found for restore key", async () => { | ||||
|             return Promise.resolve(restoreKey); | ||||
|         }); | ||||
|  | ||||
|     await run(); | ||||
|     await restoreOnlyRun(); | ||||
|  | ||||
|     expect(restoreCacheMock).toHaveBeenCalledTimes(1); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith( | ||||
|  | ||||
| @ -2,7 +2,7 @@ import * as cache from "@actions/cache"; | ||||
| import * as core from "@actions/core"; | ||||
|  | ||||
| import { Events, Inputs, RefKey } from "../src/constants"; | ||||
| import run from "../src/save"; | ||||
| import { saveRun } from "../src/saveImpl"; | ||||
| import * as actionUtils from "../src/utils/actionUtils"; | ||||
| import * as testUtils from "../src/utils/testUtils"; | ||||
|  | ||||
| @ -100,7 +100,7 @@ test("save with valid inputs uploads a cache", async () => { | ||||
|             return Promise.resolve(cacheId); | ||||
|         }); | ||||
|  | ||||
|     await run(); | ||||
|     await saveRun(); | ||||
|  | ||||
|     expect(saveCacheMock).toHaveBeenCalledTimes(1); | ||||
|     expect(saveCacheMock).toHaveBeenCalledWith( | ||||
|  | ||||
| @ -2,7 +2,7 @@ import * as cache from "@actions/cache"; | ||||
| import * as core from "@actions/core"; | ||||
|  | ||||
| import { Events, Inputs, RefKey } from "../src/constants"; | ||||
| import run from "../src/saveImpl"; | ||||
| import { saveImpl } from "../src/saveImpl"; | ||||
| import { StateProvider } from "../src/stateProvider"; | ||||
| import * as actionUtils from "../src/utils/actionUtils"; | ||||
| import * as testUtils from "../src/utils/testUtils"; | ||||
| @ -77,7 +77,7 @@ test("save with invalid event outputs warning", async () => { | ||||
|     const invalidEvent = "commit_comment"; | ||||
|     process.env[Events.Key] = invalidEvent; | ||||
|     delete process.env[RefKey]; | ||||
|     await run(new StateProvider()); | ||||
|     await saveImpl(new StateProvider()); | ||||
|     expect(logWarningMock).toHaveBeenCalledWith( | ||||
|         `Event Validation Error: The event type ${invalidEvent} is not supported because it's not tied to a branch or tag ref.` | ||||
|     ); | ||||
| @ -100,7 +100,7 @@ test("save with no primary key in state outputs warning", async () => { | ||||
|         }); | ||||
|     const saveCacheMock = jest.spyOn(cache, "saveCache"); | ||||
|  | ||||
|     await run(new StateProvider()); | ||||
|     await saveImpl(new StateProvider()); | ||||
|  | ||||
|     expect(saveCacheMock).toHaveBeenCalledTimes(0); | ||||
|     expect(logWarningMock).toHaveBeenCalledWith(`Key is not specified.`); | ||||
| @ -115,7 +115,7 @@ test("save without AC available should no-op", async () => { | ||||
|  | ||||
|     const saveCacheMock = jest.spyOn(cache, "saveCache"); | ||||
|  | ||||
|     await run(new StateProvider()); | ||||
|     await saveImpl(new StateProvider()); | ||||
|  | ||||
|     expect(saveCacheMock).toHaveBeenCalledTimes(0); | ||||
| }); | ||||
| @ -128,7 +128,7 @@ test("save on ghes without AC available should no-op", async () => { | ||||
|  | ||||
|     const saveCacheMock = jest.spyOn(cache, "saveCache"); | ||||
|  | ||||
|     await run(new StateProvider()); | ||||
|     await saveImpl(new StateProvider()); | ||||
|  | ||||
|     expect(saveCacheMock).toHaveBeenCalledTimes(0); | ||||
| }); | ||||
| @ -161,7 +161,7 @@ test("save on GHES with AC available", async () => { | ||||
|             return Promise.resolve(cacheId); | ||||
|         }); | ||||
|  | ||||
|     await run(new StateProvider()); | ||||
|     await saveImpl(new StateProvider()); | ||||
|  | ||||
|     expect(saveCacheMock).toHaveBeenCalledTimes(1); | ||||
|     expect(saveCacheMock).toHaveBeenCalledWith( | ||||
| @ -194,7 +194,7 @@ test("save with exact match returns early", async () => { | ||||
|         }); | ||||
|     const saveCacheMock = jest.spyOn(cache, "saveCache"); | ||||
|  | ||||
|     await run(new StateProvider()); | ||||
|     await saveImpl(new StateProvider()); | ||||
|  | ||||
|     expect(saveCacheMock).toHaveBeenCalledTimes(0); | ||||
|     expect(infoMock).toHaveBeenCalledWith( | ||||
| @ -221,7 +221,7 @@ test("save with missing input outputs warning", async () => { | ||||
|         }); | ||||
|     const saveCacheMock = jest.spyOn(cache, "saveCache"); | ||||
|  | ||||
|     await run(new StateProvider()); | ||||
|     await saveImpl(new StateProvider()); | ||||
|  | ||||
|     expect(saveCacheMock).toHaveBeenCalledTimes(0); | ||||
|     expect(logWarningMock).toHaveBeenCalledWith( | ||||
| @ -259,7 +259,7 @@ test("save with large cache outputs warning", async () => { | ||||
|             ); | ||||
|         }); | ||||
|  | ||||
|     await run(new StateProvider()); | ||||
|     await saveImpl(new StateProvider()); | ||||
|  | ||||
|     expect(saveCacheMock).toHaveBeenCalledTimes(1); | ||||
|     expect(saveCacheMock).toHaveBeenCalledWith( | ||||
| @ -306,7 +306,7 @@ test("save with reserve cache failure outputs warning", async () => { | ||||
|             throw error; | ||||
|         }); | ||||
|  | ||||
|     await run(new StateProvider()); | ||||
|     await saveImpl(new StateProvider()); | ||||
|  | ||||
|     expect(saveCacheMock).toHaveBeenCalledTimes(1); | ||||
|     expect(saveCacheMock).toHaveBeenCalledWith( | ||||
| @ -349,7 +349,7 @@ test("save with server error outputs warning", async () => { | ||||
|             throw new Error("HTTP Error Occurred"); | ||||
|         }); | ||||
|  | ||||
|     await run(new StateProvider()); | ||||
|     await saveImpl(new StateProvider()); | ||||
|  | ||||
|     expect(saveCacheMock).toHaveBeenCalledTimes(1); | ||||
|     expect(saveCacheMock).toHaveBeenCalledWith( | ||||
| @ -392,7 +392,7 @@ test("save with valid inputs uploads a cache", async () => { | ||||
|             return Promise.resolve(cacheId); | ||||
|         }); | ||||
|  | ||||
|     await run(new StateProvider()); | ||||
|     await saveImpl(new StateProvider()); | ||||
|  | ||||
|     expect(saveCacheMock).toHaveBeenCalledTimes(1); | ||||
|     expect(saveCacheMock).toHaveBeenCalledWith( | ||||
|  | ||||
| @ -2,7 +2,7 @@ import * as cache from "@actions/cache"; | ||||
| import * as core from "@actions/core"; | ||||
|  | ||||
| import { Events, Inputs, RefKey } from "../src/constants"; | ||||
| import run from "../src/saveOnly"; | ||||
| import { saveOnlyRun } from "../src/saveImpl"; | ||||
| import * as actionUtils from "../src/utils/actionUtils"; | ||||
| import * as testUtils from "../src/utils/testUtils"; | ||||
|  | ||||
| @ -90,7 +90,7 @@ test("save with valid inputs uploads a cache", async () => { | ||||
|             return Promise.resolve(cacheId); | ||||
|         }); | ||||
|  | ||||
|     await run(); | ||||
|     await saveOnlyRun(); | ||||
|  | ||||
|     expect(saveCacheMock).toHaveBeenCalledTimes(1); | ||||
|     expect(saveCacheMock).toHaveBeenCalledWith( | ||||
| @ -122,7 +122,7 @@ test("save failing logs the warning message", async () => { | ||||
|             return Promise.resolve(cacheId); | ||||
|         }); | ||||
|  | ||||
|     await run(); | ||||
|     await saveOnlyRun(); | ||||
|  | ||||
|     expect(saveCacheMock).toHaveBeenCalledTimes(1); | ||||
|     expect(saveCacheMock).toHaveBeenCalledWith( | ||||
|  | ||||
| @ -26,14 +26,18 @@ inputs: | ||||
|     description: 'Check if a cache entry exists for the given input(s) (key, restore-keys) without downloading the cache' | ||||
|     default: 'false' | ||||
|     required: false | ||||
|   save-always: | ||||
|     description: 'Run the post step to save the cache even if another step before fails' | ||||
|     default: 'false' | ||||
|     required: false     | ||||
| outputs: | ||||
|   cache-hit: | ||||
|     description: 'A boolean value to indicate an exact match was found for the primary key' | ||||
| runs: | ||||
|   using: 'node16' | ||||
|   using: 'node20' | ||||
|   main: 'dist/restore/index.js' | ||||
|   post: 'dist/save/index.js' | ||||
|   post-if: success() | ||||
|   post-if: "success() || github.event.inputs.save-always" | ||||
| branding: | ||||
|   icon: 'archive' | ||||
|   color: 'gray-dark' | ||||
|  | ||||
							
								
								
									
										56563
									
								
								dist/restore-only/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										56563
									
								
								dist/restore-only/index.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										56584
									
								
								dist/restore/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										56584
									
								
								dist/restore/index.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										56524
									
								
								dist/save-only/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										56524
									
								
								dist/save-only/index.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										56497
									
								
								dist/save/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										56497
									
								
								dist/save/index.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										1189
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										1189
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @ -1,6 +1,6 @@ | ||||
| { | ||||
|   "name": "cache", | ||||
|   "version": "3.3.1", | ||||
|   "version": "4.0.0", | ||||
|   "private": true, | ||||
|   "description": "Cache dependencies and build outputs", | ||||
|   "main": "dist/restore/index.js", | ||||
| @ -23,7 +23,7 @@ | ||||
|   "author": "GitHub", | ||||
|   "license": "MIT", | ||||
|   "dependencies": { | ||||
|     "@actions/cache": "^3.2.1", | ||||
|     "@actions/cache": "^3.2.3", | ||||
|     "@actions/core": "^1.10.0", | ||||
|     "@actions/exec": "^1.1.1", | ||||
|     "@actions/io": "^1.1.2" | ||||
| @ -34,7 +34,7 @@ | ||||
|     "@types/node": "^16.18.3", | ||||
|     "@typescript-eslint/eslint-plugin": "^5.45.0", | ||||
|     "@typescript-eslint/parser": "^5.45.0", | ||||
|     "@zeit/ncc": "^0.20.5", | ||||
|     "@vercel/ncc": "^0.38.1", | ||||
|     "eslint": "^8.28.0", | ||||
|     "eslint-config-prettier": "^8.5.0", | ||||
|     "eslint-plugin-import": "^2.26.0", | ||||
|  | ||||
| @ -31,7 +31,7 @@ outputs: | ||||
|   cache-matched-key: | ||||
|     description: 'Key of the cache that was restored, it could either be the primary key on cache-hit or a partial/complete match of one of the restore keys' | ||||
| runs: | ||||
|   using: 'node16' | ||||
|   using: 'node20' | ||||
|   main: '../dist/restore-only/index.js' | ||||
| branding: | ||||
|   icon: 'archive' | ||||
|  | ||||
| @ -16,7 +16,7 @@ inputs: | ||||
|     default: 'false' | ||||
|     required: false | ||||
| runs: | ||||
|   using: 'node16' | ||||
|   using: 'node20' | ||||
|   main: '../dist/save-only/index.js' | ||||
| branding: | ||||
|   icon: 'archive' | ||||
|  | ||||
| @ -1,10 +1,3 @@ | ||||
| import restoreImpl from "./restoreImpl"; | ||||
| import { StateProvider } from "./stateProvider"; | ||||
| import { restoreRun } from "./restoreImpl"; | ||||
|  | ||||
| async function run(): Promise<void> { | ||||
|     await restoreImpl(new StateProvider()); | ||||
| } | ||||
|  | ||||
| run(); | ||||
|  | ||||
| export default run; | ||||
| restoreRun(true); | ||||
|  | ||||
| @ -2,10 +2,14 @@ import * as cache from "@actions/cache"; | ||||
| import * as core from "@actions/core"; | ||||
|  | ||||
| import { Events, Inputs, Outputs, State } from "./constants"; | ||||
| import { IStateProvider } from "./stateProvider"; | ||||
| import { | ||||
|     IStateProvider, | ||||
|     NullStateProvider, | ||||
|     StateProvider | ||||
| } from "./stateProvider"; | ||||
| import * as utils from "./utils/actionUtils"; | ||||
|  | ||||
| async function restoreImpl( | ||||
| export async function restoreImpl( | ||||
|     stateProvider: IStateProvider | ||||
| ): Promise<string | undefined> { | ||||
|     try { | ||||
| @ -82,4 +86,37 @@ async function restoreImpl( | ||||
|     } | ||||
| } | ||||
|  | ||||
| export default restoreImpl; | ||||
| async function run( | ||||
|     stateProvider: IStateProvider, | ||||
|     earlyExit: boolean | undefined | ||||
| ): Promise<void> { | ||||
|     try { | ||||
|         await restoreImpl(stateProvider); | ||||
|     } catch (err) { | ||||
|         console.error(err); | ||||
|         if (earlyExit) { | ||||
|             process.exit(1); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     // node will stay alive if any promises are not resolved, | ||||
|     // which is a possibility if HTTP requests are dangling | ||||
|     // due to retries or timeouts. We know that if we got here | ||||
|     // that all promises that we care about have successfully | ||||
|     // resolved, so simply exit with success. | ||||
|     if (earlyExit) { | ||||
|         process.exit(0); | ||||
|     } | ||||
| } | ||||
|  | ||||
| export async function restoreOnlyRun( | ||||
|     earlyExit?: boolean | undefined | ||||
| ): Promise<void> { | ||||
|     await run(new NullStateProvider(), earlyExit); | ||||
| } | ||||
|  | ||||
| export async function restoreRun( | ||||
|     earlyExit?: boolean | undefined | ||||
| ): Promise<void> { | ||||
|     await run(new StateProvider(), earlyExit); | ||||
| } | ||||
|  | ||||
| @ -1,10 +1,3 @@ | ||||
| import restoreImpl from "./restoreImpl"; | ||||
| import { NullStateProvider } from "./stateProvider"; | ||||
| import { restoreOnlyRun } from "./restoreImpl"; | ||||
|  | ||||
| async function run(): Promise<void> { | ||||
|     await restoreImpl(new NullStateProvider()); | ||||
| } | ||||
|  | ||||
| run(); | ||||
|  | ||||
| export default run; | ||||
| restoreOnlyRun(true); | ||||
|  | ||||
							
								
								
									
										11
									
								
								src/save.ts
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								src/save.ts
									
									
									
									
									
								
							| @ -1,10 +1,3 @@ | ||||
| import saveImpl from "./saveImpl"; | ||||
| import { StateProvider } from "./stateProvider"; | ||||
| import { saveRun } from "./saveImpl"; | ||||
|  | ||||
| async function run(): Promise<void> { | ||||
|     await saveImpl(new StateProvider()); | ||||
| } | ||||
|  | ||||
| run(); | ||||
|  | ||||
| export default run; | ||||
| saveRun(true); | ||||
|  | ||||
| @ -2,7 +2,11 @@ import * as cache from "@actions/cache"; | ||||
| import * as core from "@actions/core"; | ||||
|  | ||||
| import { Events, Inputs, State } from "./constants"; | ||||
| import { IStateProvider } from "./stateProvider"; | ||||
| import { | ||||
|     IStateProvider, | ||||
|     NullStateProvider, | ||||
|     StateProvider | ||||
| } from "./stateProvider"; | ||||
| import * as utils from "./utils/actionUtils"; | ||||
|  | ||||
| // Catch and log any unhandled exceptions.  These exceptions can leak out of the uploadChunk method in | ||||
| @ -10,7 +14,9 @@ import * as utils from "./utils/actionUtils"; | ||||
| // throw an uncaught exception.  Instead of failing this action, just warn. | ||||
| process.on("uncaughtException", e => utils.logWarning(e.message)); | ||||
|  | ||||
| async function saveImpl(stateProvider: IStateProvider): Promise<number | void> { | ||||
| export async function saveImpl( | ||||
|     stateProvider: IStateProvider | ||||
| ): Promise<number | void> { | ||||
|     let cacheId = -1; | ||||
|     try { | ||||
|         if (!utils.isCacheFeatureAvailable()) { | ||||
| @ -72,4 +78,47 @@ async function saveImpl(stateProvider: IStateProvider): Promise<number | void> { | ||||
|     return cacheId; | ||||
| } | ||||
|  | ||||
| export default saveImpl; | ||||
| export async function saveOnlyRun( | ||||
|     earlyExit?: boolean | undefined | ||||
| ): Promise<void> { | ||||
|     try { | ||||
|         const cacheId = await saveImpl(new NullStateProvider()); | ||||
|         if (cacheId === -1) { | ||||
|             core.warning(`Cache save failed.`); | ||||
|         } | ||||
|     } catch (err) { | ||||
|         console.error(err); | ||||
|         if (earlyExit) { | ||||
|             process.exit(1); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     // node will stay alive if any promises are not resolved, | ||||
|     // which is a possibility if HTTP requests are dangling | ||||
|     // due to retries or timeouts. We know that if we got here | ||||
|     // that all promises that we care about have successfully | ||||
|     // resolved, so simply exit with success. | ||||
|     if (earlyExit) { | ||||
|         process.exit(0); | ||||
|     } | ||||
| } | ||||
|  | ||||
| export async function saveRun(earlyExit?: boolean | undefined): Promise<void> { | ||||
|     try { | ||||
|         await saveImpl(new StateProvider()); | ||||
|     } catch (err) { | ||||
|         console.error(err); | ||||
|         if (earlyExit) { | ||||
|             process.exit(1); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     // node will stay alive if any promises are not resolved, | ||||
|     // which is a possibility if HTTP requests are dangling | ||||
|     // due to retries or timeouts. We know that if we got here | ||||
|     // that all promises that we care about have successfully | ||||
|     // resolved, so simply exit with success. | ||||
|     if (earlyExit) { | ||||
|         process.exit(0); | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -1,15 +1,3 @@ | ||||
| import * as core from "@actions/core"; | ||||
| import { saveOnlyRun } from "./saveImpl"; | ||||
|  | ||||
| import saveImpl from "./saveImpl"; | ||||
| import { NullStateProvider } from "./stateProvider"; | ||||
|  | ||||
| async function run(): Promise<void> { | ||||
|     const cacheId = await saveImpl(new NullStateProvider()); | ||||
|     if (cacheId === -1) { | ||||
|         core.warning(`Cache save failed.`); | ||||
|     } | ||||
| } | ||||
|  | ||||
| run(); | ||||
|  | ||||
| export default run; | ||||
| saveOnlyRun(true); | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	