mirror of
				https://gitea.com/actions/cache.git
				synced 2025-11-04 07:47:08 +00:00 
			
		
		
		
	Compare commits
	
		
			39 Commits
		
	
	
		
			v3.1.0-bet
			...
			bishal/out
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					657c52f11e | ||
| 
						 | 
					34e917cb7d | ||
| 
						 | 
					ac8fc97c06 | ||
| 
						 | 
					86712a0733 | ||
| 
						 | 
					d6e98d9302 | ||
| 
						 | 
					a76826ef46 | ||
| 
						 | 
					e02e5113ed | ||
| 
						 | 
					85ae5bbcea | ||
| 
						 | 
					cce93fb2c7 | ||
| 
						 | 
					e3d8fb0b34 | ||
| 
						 | 
					d95c048983 | ||
| 
						 | 
					706c369cf1 | ||
| 
						 | 
					11ab7ccfa2 | ||
| 
						 | 
					4b5f33df54 | ||
| 
						 | 
					56a0133650 | ||
| 
						 | 
					19446b165a | ||
| 
						 | 
					8a88690a20 | ||
| 
						 | 
					6e2c6a5916 | ||
| 
						 | 
					2c9fb32186 | ||
| 
						 | 
					01d96636a0 | ||
| 
						 | 
					9c5a42a7c9 | ||
| 
						 | 
					a172494938 | ||
| 
						 | 
					f8717682fb | ||
| 
						 | 
					af1210e2a3 | ||
| 
						 | 
					ab0e7714ce | ||
| 
						 | 
					fb4a5dce60 | ||
| 
						 | 
					71334c58b2 | ||
| 
						 | 
					888d454557 | ||
| 
						 | 
					dddd7ce07c | ||
| 
						 | 
					abddc4dd44 | ||
| 
						 | 
					921c58ee44 | ||
| 
						 | 
					7f45813c72 | ||
| 
						 | 
					0769f2e443 | ||
| 
						 | 
					5fe0b944ef | ||
| 
						 | 
					69b8227b27 | ||
| 
						 | 
					515d10b4fd | ||
| 
						 | 
					669e7536d9 | ||
| 
						 | 
					29dbbce762 | ||
| 
						 | 
					ea5981db97 | 
							
								
								
									
										14
									
								
								.devcontainer/devcontainer.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								.devcontainer/devcontainer.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,14 @@
 | 
				
			|||||||
 | 
					{
 | 
				
			||||||
 | 
						"name": "Node.js & TypeScript",
 | 
				
			||||||
 | 
						"image": "mcr.microsoft.com/devcontainers/typescript-node:16-bullseye",
 | 
				
			||||||
 | 
						// Features to add to the dev container. More info: https://containers.dev/implementors/features.
 | 
				
			||||||
 | 
						// "features": {},
 | 
				
			||||||
 | 
						// Use 'forwardPorts' to make a list of ports inside the container available locally.
 | 
				
			||||||
 | 
						// "forwardPorts": [],
 | 
				
			||||||
 | 
						// Use 'postCreateCommand' to run commands after the container is created.
 | 
				
			||||||
 | 
						"postCreateCommand": "npm install && npm run build"
 | 
				
			||||||
 | 
						// Configure tool-specific properties.
 | 
				
			||||||
 | 
						// "customizations": {},
 | 
				
			||||||
 | 
						// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
 | 
				
			||||||
 | 
						// "remoteUser": "root"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -40,6 +40,3 @@
 | 
				
			|||||||
### 3.0.11
 | 
					### 3.0.11
 | 
				
			||||||
- Update toolkit version to 3.0.5 to include `@actions/core@^1.10.0`
 | 
					- Update toolkit version to 3.0.5 to include `@actions/core@^1.10.0`
 | 
				
			||||||
- Update `@actions/cache` to use updated `saveState` and `setOutput` functions from `@actions/core@^1.10.0`
 | 
					- Update `@actions/cache` to use updated `saveState` and `setOutput` functions from `@actions/core@^1.10.0`
 | 
				
			||||||
 | 
					 | 
				
			||||||
### 3.1.0-beta.1
 | 
					 | 
				
			||||||
- Update `@actions/cache` on windows to use gnu tar and zstd by default and fallback to bsdtar and zstd if gnu tar is not available. ([issue](https://github.com/actions/cache/issues/984))
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -102,7 +102,7 @@ test("restore on GHES with AC available ", async () => {
 | 
				
			|||||||
    const infoMock = jest.spyOn(core, "info");
 | 
					    const infoMock = jest.spyOn(core, "info");
 | 
				
			||||||
    const failedMock = jest.spyOn(core, "setFailed");
 | 
					    const failedMock = jest.spyOn(core, "setFailed");
 | 
				
			||||||
    const stateMock = jest.spyOn(core, "saveState");
 | 
					    const stateMock = jest.spyOn(core, "saveState");
 | 
				
			||||||
    const setCacheHitOutputMock = jest.spyOn(actionUtils, "setCacheHitOutput");
 | 
					    const setCacheHitOutputMock = jest.spyOn(core, "setOutput");
 | 
				
			||||||
    const restoreCacheMock = jest
 | 
					    const restoreCacheMock = jest
 | 
				
			||||||
        .spyOn(cache, "restoreCache")
 | 
					        .spyOn(cache, "restoreCache")
 | 
				
			||||||
        .mockImplementationOnce(() => {
 | 
					        .mockImplementationOnce(() => {
 | 
				
			||||||
@@ -116,7 +116,7 @@ test("restore on GHES with AC available ", async () => {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
 | 
					    expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
 | 
				
			||||||
    expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1);
 | 
					    expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1);
 | 
				
			||||||
    expect(setCacheHitOutputMock).toHaveBeenCalledWith(true);
 | 
					    expect(setCacheHitOutputMock).toHaveBeenCalledWith("cache-hit", "true");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    expect(infoMock).toHaveBeenCalledWith(`Cache restored from key: ${key}`);
 | 
					    expect(infoMock).toHaveBeenCalledWith(`Cache restored from key: ${key}`);
 | 
				
			||||||
    expect(failedMock).toHaveBeenCalledTimes(0);
 | 
					    expect(failedMock).toHaveBeenCalledTimes(0);
 | 
				
			||||||
@@ -270,7 +270,7 @@ test("restore with cache found for key", async () => {
 | 
				
			|||||||
    const infoMock = jest.spyOn(core, "info");
 | 
					    const infoMock = jest.spyOn(core, "info");
 | 
				
			||||||
    const failedMock = jest.spyOn(core, "setFailed");
 | 
					    const failedMock = jest.spyOn(core, "setFailed");
 | 
				
			||||||
    const stateMock = jest.spyOn(core, "saveState");
 | 
					    const stateMock = jest.spyOn(core, "saveState");
 | 
				
			||||||
    const setCacheHitOutputMock = jest.spyOn(actionUtils, "setCacheHitOutput");
 | 
					    const setCacheHitOutputMock = jest.spyOn(core, "setOutput");
 | 
				
			||||||
    const restoreCacheMock = jest
 | 
					    const restoreCacheMock = jest
 | 
				
			||||||
        .spyOn(cache, "restoreCache")
 | 
					        .spyOn(cache, "restoreCache")
 | 
				
			||||||
        .mockImplementationOnce(() => {
 | 
					        .mockImplementationOnce(() => {
 | 
				
			||||||
@@ -284,7 +284,7 @@ test("restore with cache found for key", async () => {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
 | 
					    expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
 | 
				
			||||||
    expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1);
 | 
					    expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1);
 | 
				
			||||||
    expect(setCacheHitOutputMock).toHaveBeenCalledWith(true);
 | 
					    expect(setCacheHitOutputMock).toHaveBeenCalledWith("cache-hit", "true");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    expect(infoMock).toHaveBeenCalledWith(`Cache restored from key: ${key}`);
 | 
					    expect(infoMock).toHaveBeenCalledWith(`Cache restored from key: ${key}`);
 | 
				
			||||||
    expect(failedMock).toHaveBeenCalledTimes(0);
 | 
					    expect(failedMock).toHaveBeenCalledTimes(0);
 | 
				
			||||||
@@ -303,7 +303,7 @@ test("restore with cache found for restore key", async () => {
 | 
				
			|||||||
    const infoMock = jest.spyOn(core, "info");
 | 
					    const infoMock = jest.spyOn(core, "info");
 | 
				
			||||||
    const failedMock = jest.spyOn(core, "setFailed");
 | 
					    const failedMock = jest.spyOn(core, "setFailed");
 | 
				
			||||||
    const stateMock = jest.spyOn(core, "saveState");
 | 
					    const stateMock = jest.spyOn(core, "saveState");
 | 
				
			||||||
    const setCacheHitOutputMock = jest.spyOn(actionUtils, "setCacheHitOutput");
 | 
					    const setCacheHitOutputMock = jest.spyOn(core, "setOutput");
 | 
				
			||||||
    const restoreCacheMock = jest
 | 
					    const restoreCacheMock = jest
 | 
				
			||||||
        .spyOn(cache, "restoreCache")
 | 
					        .spyOn(cache, "restoreCache")
 | 
				
			||||||
        .mockImplementationOnce(() => {
 | 
					        .mockImplementationOnce(() => {
 | 
				
			||||||
@@ -317,8 +317,7 @@ test("restore with cache found for restore key", async () => {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
 | 
					    expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
 | 
				
			||||||
    expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1);
 | 
					    expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1);
 | 
				
			||||||
    expect(setCacheHitOutputMock).toHaveBeenCalledWith(false);
 | 
					    expect(setCacheHitOutputMock).toHaveBeenCalledWith("cache-hit", "false");
 | 
				
			||||||
 | 
					 | 
				
			||||||
    expect(infoMock).toHaveBeenCalledWith(
 | 
					    expect(infoMock).toHaveBeenCalledWith(
 | 
				
			||||||
        `Cache restored from key: ${restoreKey}`
 | 
					        `Cache restored from key: ${restoreKey}`
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -21,7 +21,7 @@ runs:
 | 
				
			|||||||
  using: 'node16'
 | 
					  using: 'node16'
 | 
				
			||||||
  main: 'dist/restore/index.js'
 | 
					  main: 'dist/restore/index.js'
 | 
				
			||||||
  post: 'dist/save/index.js'
 | 
					  post: 'dist/save/index.js'
 | 
				
			||||||
  post-if: 'success()'
 | 
					  post-if: success()
 | 
				
			||||||
branding:
 | 
					branding:
 | 
				
			||||||
  icon: 'archive'
 | 
					  icon: 'archive'
 | 
				
			||||||
  color: 'gray-dark'
 | 
					  color: 'gray-dark'
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										5534
									
								
								dist/restore/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										5534
									
								
								dist/restore/index.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										991
									
								
								dist/save/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										991
									
								
								dist/save/index.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										38
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										38
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							@@ -1,15 +1,15 @@
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
  "name": "cache",
 | 
					  "name": "cache",
 | 
				
			||||||
  "version": "3.1.0-beta.1",
 | 
					  "version": "3.0.11",
 | 
				
			||||||
  "lockfileVersion": 2,
 | 
					  "lockfileVersion": 2,
 | 
				
			||||||
  "requires": true,
 | 
					  "requires": true,
 | 
				
			||||||
  "packages": {
 | 
					  "packages": {
 | 
				
			||||||
    "": {
 | 
					    "": {
 | 
				
			||||||
      "name": "cache",
 | 
					      "name": "cache",
 | 
				
			||||||
      "version": "3.1.0-beta.1",
 | 
					      "version": "3.0.11",
 | 
				
			||||||
      "license": "MIT",
 | 
					      "license": "MIT",
 | 
				
			||||||
      "dependencies": {
 | 
					      "dependencies": {
 | 
				
			||||||
        "@actions/cache": "3.1.0-beta.1",
 | 
					        "@actions/cache": "^3.0.5",
 | 
				
			||||||
        "@actions/core": "^1.10.0",
 | 
					        "@actions/core": "^1.10.0",
 | 
				
			||||||
        "@actions/exec": "^1.1.1",
 | 
					        "@actions/exec": "^1.1.1",
 | 
				
			||||||
        "@actions/io": "^1.1.2"
 | 
					        "@actions/io": "^1.1.2"
 | 
				
			||||||
@@ -36,16 +36,15 @@
 | 
				
			|||||||
      }
 | 
					      }
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    "node_modules/@actions/cache": {
 | 
					    "node_modules/@actions/cache": {
 | 
				
			||||||
      "version": "3.1.0-beta.1",
 | 
					      "version": "3.0.5",
 | 
				
			||||||
      "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.1.0-beta.1.tgz",
 | 
					      "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.0.5.tgz",
 | 
				
			||||||
      "integrity": "sha512-E+lNTJ4x1baOVHbhkkGK7JebxChMM/ogDSWIuDJsiPlpi7bzzL8RnKTk4zlZ3OYmWK8tF2/5QZMerg3rY4c/9A==",
 | 
					      "integrity": "sha512-0WpPmwnRPkn5k5ASmjoX8bY8NrZEPTwN+64nGYJmR/bHjEVgC8svdf5K956wi67tNJBGJky2+UfvNbUOtHmMHg==",
 | 
				
			||||||
      "dependencies": {
 | 
					      "dependencies": {
 | 
				
			||||||
        "@actions/core": "^1.10.0",
 | 
					        "@actions/core": "^1.10.0",
 | 
				
			||||||
        "@actions/exec": "^1.0.1",
 | 
					        "@actions/exec": "^1.0.1",
 | 
				
			||||||
        "@actions/glob": "^0.1.0",
 | 
					        "@actions/glob": "^0.1.0",
 | 
				
			||||||
        "@actions/http-client": "^2.0.1",
 | 
					        "@actions/http-client": "^2.0.1",
 | 
				
			||||||
        "@actions/io": "^1.0.1",
 | 
					        "@actions/io": "^1.0.1",
 | 
				
			||||||
        "@azure/abort-controller": "^1.1.0",
 | 
					 | 
				
			||||||
        "@azure/ms-rest-js": "^2.6.0",
 | 
					        "@azure/ms-rest-js": "^2.6.0",
 | 
				
			||||||
        "@azure/storage-blob": "^12.8.0",
 | 
					        "@azure/storage-blob": "^12.8.0",
 | 
				
			||||||
        "semver": "^6.1.0",
 | 
					        "semver": "^6.1.0",
 | 
				
			||||||
@@ -112,14 +111,14 @@
 | 
				
			|||||||
      }
 | 
					      }
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    "node_modules/@azure/abort-controller": {
 | 
					    "node_modules/@azure/abort-controller": {
 | 
				
			||||||
      "version": "1.1.0",
 | 
					      "version": "1.0.4",
 | 
				
			||||||
      "resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-1.1.0.tgz",
 | 
					      "resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-1.0.4.tgz",
 | 
				
			||||||
      "integrity": "sha512-TrRLIoSQVzfAJX9H1JeFjzAoDGcoK1IYX1UImfceTZpsyYfWr09Ss1aHW1y5TrrR3iq6RZLBwJ3E24uwPhwahw==",
 | 
					      "integrity": "sha512-lNUmDRVGpanCsiUN3NWxFTdwmdFI53xwhkTFfHDGTYk46ca7Ind3nanJc+U6Zj9Tv+9nTCWRBscWEW1DyKOpTw==",
 | 
				
			||||||
      "dependencies": {
 | 
					      "dependencies": {
 | 
				
			||||||
        "tslib": "^2.2.0"
 | 
					        "tslib": "^2.0.0"
 | 
				
			||||||
      },
 | 
					      },
 | 
				
			||||||
      "engines": {
 | 
					      "engines": {
 | 
				
			||||||
        "node": ">=12.0.0"
 | 
					        "node": ">=8.0.0"
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    "node_modules/@azure/abort-controller/node_modules/tslib": {
 | 
					    "node_modules/@azure/abort-controller/node_modules/tslib": {
 | 
				
			||||||
@@ -9722,16 +9721,15 @@
 | 
				
			|||||||
  },
 | 
					  },
 | 
				
			||||||
  "dependencies": {
 | 
					  "dependencies": {
 | 
				
			||||||
    "@actions/cache": {
 | 
					    "@actions/cache": {
 | 
				
			||||||
      "version": "3.1.0-beta.1",
 | 
					      "version": "3.0.5",
 | 
				
			||||||
      "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.1.0-beta.1.tgz",
 | 
					      "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.0.5.tgz",
 | 
				
			||||||
      "integrity": "sha512-E+lNTJ4x1baOVHbhkkGK7JebxChMM/ogDSWIuDJsiPlpi7bzzL8RnKTk4zlZ3OYmWK8tF2/5QZMerg3rY4c/9A==",
 | 
					      "integrity": "sha512-0WpPmwnRPkn5k5ASmjoX8bY8NrZEPTwN+64nGYJmR/bHjEVgC8svdf5K956wi67tNJBGJky2+UfvNbUOtHmMHg==",
 | 
				
			||||||
      "requires": {
 | 
					      "requires": {
 | 
				
			||||||
        "@actions/core": "^1.10.0",
 | 
					        "@actions/core": "^1.10.0",
 | 
				
			||||||
        "@actions/exec": "^1.0.1",
 | 
					        "@actions/exec": "^1.0.1",
 | 
				
			||||||
        "@actions/glob": "^0.1.0",
 | 
					        "@actions/glob": "^0.1.0",
 | 
				
			||||||
        "@actions/http-client": "^2.0.1",
 | 
					        "@actions/http-client": "^2.0.1",
 | 
				
			||||||
        "@actions/io": "^1.0.1",
 | 
					        "@actions/io": "^1.0.1",
 | 
				
			||||||
        "@azure/abort-controller": "^1.1.0",
 | 
					 | 
				
			||||||
        "@azure/ms-rest-js": "^2.6.0",
 | 
					        "@azure/ms-rest-js": "^2.6.0",
 | 
				
			||||||
        "@azure/storage-blob": "^12.8.0",
 | 
					        "@azure/storage-blob": "^12.8.0",
 | 
				
			||||||
        "semver": "^6.1.0",
 | 
					        "semver": "^6.1.0",
 | 
				
			||||||
@@ -9794,11 +9792,11 @@
 | 
				
			|||||||
      }
 | 
					      }
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    "@azure/abort-controller": {
 | 
					    "@azure/abort-controller": {
 | 
				
			||||||
      "version": "1.1.0",
 | 
					      "version": "1.0.4",
 | 
				
			||||||
      "resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-1.1.0.tgz",
 | 
					      "resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-1.0.4.tgz",
 | 
				
			||||||
      "integrity": "sha512-TrRLIoSQVzfAJX9H1JeFjzAoDGcoK1IYX1UImfceTZpsyYfWr09Ss1aHW1y5TrrR3iq6RZLBwJ3E24uwPhwahw==",
 | 
					      "integrity": "sha512-lNUmDRVGpanCsiUN3NWxFTdwmdFI53xwhkTFfHDGTYk46ca7Ind3nanJc+U6Zj9Tv+9nTCWRBscWEW1DyKOpTw==",
 | 
				
			||||||
      "requires": {
 | 
					      "requires": {
 | 
				
			||||||
        "tslib": "^2.2.0"
 | 
					        "tslib": "^2.0.0"
 | 
				
			||||||
      },
 | 
					      },
 | 
				
			||||||
      "dependencies": {
 | 
					      "dependencies": {
 | 
				
			||||||
        "tslib": {
 | 
					        "tslib": {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,6 @@
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
  "name": "cache",
 | 
					  "name": "cache",
 | 
				
			||||||
  "version": "3.1.0-beta.1",
 | 
					  "version": "3.0.11",
 | 
				
			||||||
  "private": true,
 | 
					  "private": true,
 | 
				
			||||||
  "description": "Cache dependencies and build outputs",
 | 
					  "description": "Cache dependencies and build outputs",
 | 
				
			||||||
  "main": "dist/restore/index.js",
 | 
					  "main": "dist/restore/index.js",
 | 
				
			||||||
@@ -23,7 +23,7 @@
 | 
				
			|||||||
  "author": "GitHub",
 | 
					  "author": "GitHub",
 | 
				
			||||||
  "license": "MIT",
 | 
					  "license": "MIT",
 | 
				
			||||||
  "dependencies": {
 | 
					  "dependencies": {
 | 
				
			||||||
    "@actions/cache": "3.1.0-beta.1",
 | 
					    "@actions/cache": "^3.0.5",
 | 
				
			||||||
    "@actions/core": "^1.10.0",
 | 
					    "@actions/core": "^1.10.0",
 | 
				
			||||||
    "@actions/exec": "^1.1.1",
 | 
					    "@actions/exec": "^1.1.1",
 | 
				
			||||||
    "@actions/io": "^1.1.2"
 | 
					    "@actions/io": "^1.1.2"
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										23
									
								
								restore/action.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								restore/action.yml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,23 @@
 | 
				
			|||||||
 | 
					name: 'Restore Cache'
 | 
				
			||||||
 | 
					description: 'Restore Cache artifacts like dependencies and build outputs to improve workflow execution time'
 | 
				
			||||||
 | 
					author: 'GitHub'
 | 
				
			||||||
 | 
					inputs:
 | 
				
			||||||
 | 
					  path:
 | 
				
			||||||
 | 
					    description: 'The same list of files, directories, and wildcard patterns to restore cache that were used while saving it'
 | 
				
			||||||
 | 
					    required: true
 | 
				
			||||||
 | 
					  key:
 | 
				
			||||||
 | 
					    description: 'An explicit key for restoring the cache'
 | 
				
			||||||
 | 
					    required: true
 | 
				
			||||||
 | 
					  restore-keys:
 | 
				
			||||||
 | 
					    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
 | 
				
			||||||
 | 
					outputs:
 | 
				
			||||||
 | 
					  cache-hit:
 | 
				
			||||||
 | 
					    description: 'A boolean value to indicate an exact match was found for the primary key'
 | 
				
			||||||
 | 
					runs:
 | 
				
			||||||
 | 
					  using: 'node16'
 | 
				
			||||||
 | 
					  main: '../dist/restore/index.js'
 | 
				
			||||||
 | 
					branding:
 | 
				
			||||||
 | 
					  icon: 'archive'
 | 
				
			||||||
 | 
					  color: 'gray-dark'
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
							
								
								
									
										19
									
								
								save/action.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								save/action.yml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,19 @@
 | 
				
			|||||||
 | 
					name: 'Save Cache'
 | 
				
			||||||
 | 
					description: 'Save Cache artifacts like dependencies and build outputs to improve workflow execution time'
 | 
				
			||||||
 | 
					author: 'GitHub'
 | 
				
			||||||
 | 
					inputs:
 | 
				
			||||||
 | 
					  path:
 | 
				
			||||||
 | 
					    description: 'A list of files, directories, and wildcard patterns to cache'
 | 
				
			||||||
 | 
					    required: true
 | 
				
			||||||
 | 
					  key:
 | 
				
			||||||
 | 
					    description: 'An explicit key for saving the cache'
 | 
				
			||||||
 | 
					    required: true
 | 
				
			||||||
 | 
					  upload-chunk-size:
 | 
				
			||||||
 | 
					    description: 'The chunk size used to split up large files during upload, in bytes'
 | 
				
			||||||
 | 
					    required: false
 | 
				
			||||||
 | 
					runs:
 | 
				
			||||||
 | 
					  using: 'node16'
 | 
				
			||||||
 | 
					  main: '../dist/save/index.js'
 | 
				
			||||||
 | 
					branding:
 | 
				
			||||||
 | 
					  icon: 'archive'
 | 
				
			||||||
 | 
					  color: 'gray-dark'
 | 
				
			||||||
@@ -1,60 +1,8 @@
 | 
				
			|||||||
import * as cache from "@actions/cache";
 | 
					import { StateProvider } from "./stateProvider";
 | 
				
			||||||
import * as core from "@actions/core";
 | 
					import restoreImpl from "./restoreImpl";
 | 
				
			||||||
 | 
					 | 
				
			||||||
import { Events, Inputs, State } from "./constants";
 | 
					 | 
				
			||||||
import * as utils from "./utils/actionUtils";
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
async function run(): Promise<void> {
 | 
					async function run(): Promise<void> {
 | 
				
			||||||
    try {
 | 
					    await restoreImpl(new StateProvider());
 | 
				
			||||||
        if (!utils.isCacheFeatureAvailable()) {
 | 
					 | 
				
			||||||
            utils.setCacheHitOutput(false);
 | 
					 | 
				
			||||||
            return;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // Validate inputs, this can cause task failure
 | 
					 | 
				
			||||||
        if (!utils.isValidEvent()) {
 | 
					 | 
				
			||||||
            utils.logWarning(
 | 
					 | 
				
			||||||
                `Event Validation Error: The event type ${
 | 
					 | 
				
			||||||
                    process.env[Events.Key]
 | 
					 | 
				
			||||||
                } is not supported because it's not tied to a branch or tag ref.`
 | 
					 | 
				
			||||||
            );
 | 
					 | 
				
			||||||
            return;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        const primaryKey = core.getInput(Inputs.Key, { required: true });
 | 
					 | 
				
			||||||
        core.saveState(State.CachePrimaryKey, primaryKey);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        const restoreKeys = utils.getInputAsArray(Inputs.RestoreKeys);
 | 
					 | 
				
			||||||
        const cachePaths = utils.getInputAsArray(Inputs.Path, {
 | 
					 | 
				
			||||||
            required: true
 | 
					 | 
				
			||||||
        });
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        const cacheKey = await cache.restoreCache(
 | 
					 | 
				
			||||||
            cachePaths,
 | 
					 | 
				
			||||||
            primaryKey,
 | 
					 | 
				
			||||||
            restoreKeys
 | 
					 | 
				
			||||||
        );
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        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: unknown) {
 | 
					 | 
				
			||||||
        core.setFailed((error as Error).message);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
run();
 | 
					run();
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										67
									
								
								src/restoreImpl.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										67
									
								
								src/restoreImpl.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,67 @@
 | 
				
			|||||||
 | 
					import * as cache from "@actions/cache";
 | 
				
			||||||
 | 
					import * as core from "@actions/core";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import { Events, Inputs, Outputs, State } from "./constants";
 | 
				
			||||||
 | 
					import { IStateProvider } from "./stateProvider";
 | 
				
			||||||
 | 
					import * as utils from "./utils/actionUtils";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					async function restoreImpl(stateProvider: IStateProvider): Promise<string | undefined> {
 | 
				
			||||||
 | 
					    try {
 | 
				
			||||||
 | 
					        if (!utils.isCacheFeatureAvailable()) {
 | 
				
			||||||
 | 
					            utils.setCacheHitOutput(false);
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Validate inputs, this can cause task failure
 | 
				
			||||||
 | 
					        if (!utils.isValidEvent()) {
 | 
				
			||||||
 | 
					            utils.logWarning(
 | 
				
			||||||
 | 
					                `Event Validation Error: The event type ${
 | 
				
			||||||
 | 
					                    process.env[Events.Key]
 | 
				
			||||||
 | 
					                } is not supported because it's not tied to a branch or tag ref.`
 | 
				
			||||||
 | 
					            );
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        const primaryKey = core.getInput(Inputs.Key, { required: true });
 | 
				
			||||||
 | 
					        stateProvider.setState(State.CachePrimaryKey, primaryKey);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        const restoreKeys = utils.getInputAsArray(Inputs.RestoreKeys);
 | 
				
			||||||
 | 
					        const cachePaths = utils.getInputAsArray(Inputs.Path, {
 | 
				
			||||||
 | 
					            required: true
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        const cacheKey = await cache.restoreCache(
 | 
				
			||||||
 | 
					            cachePaths,
 | 
				
			||||||
 | 
					            primaryKey,
 | 
				
			||||||
 | 
					            restoreKeys
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (!cacheKey) {
 | 
				
			||||||
 | 
					            core.info(
 | 
				
			||||||
 | 
					                `Cache not found for input keys: ${[
 | 
				
			||||||
 | 
					                    primaryKey,
 | 
				
			||||||
 | 
					                    ...restoreKeys
 | 
				
			||||||
 | 
					                ].join(", ")}`
 | 
				
			||||||
 | 
					            );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Store the matched cache key in states
 | 
				
			||||||
 | 
					        stateProvider.setState(State.CacheMatchedKey, cacheKey);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        const isExactKeyMatch = utils.isExactKeyMatch(
 | 
				
			||||||
 | 
					            core.getInput(Inputs.Key, { required: true }),
 | 
				
			||||||
 | 
					            cacheKey
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        core.setOutput(Outputs.CacheHit, isExactKeyMatch.toString());
 | 
				
			||||||
 | 
					        core.info(`Cache restored from key: ${cacheKey}`);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return cacheKey;
 | 
				
			||||||
 | 
					    } catch (error: unknown) {
 | 
				
			||||||
 | 
					        core.setFailed((error as Error).message);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export default restoreImpl;
 | 
				
			||||||
							
								
								
									
										10
									
								
								src/restoreOnly.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								src/restoreOnly.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,10 @@
 | 
				
			|||||||
 | 
					import restoreImpl from "./restoreImpl";
 | 
				
			||||||
 | 
					import { NullStateProvider } from "./stateProvider";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					async function run(): Promise<void> {
 | 
				
			||||||
 | 
					    await restoreImpl(new NullStateProvider());
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					run();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export default run;
 | 
				
			||||||
							
								
								
									
										57
									
								
								src/save.ts
									
									
									
									
									
								
							
							
						
						
									
										57
									
								
								src/save.ts
									
									
									
									
									
								
							@@ -1,59 +1,8 @@
 | 
				
			|||||||
import * as cache from "@actions/cache";
 | 
					import saveImpl from "./saveImpl";
 | 
				
			||||||
import * as core from "@actions/core";
 | 
					import { StateProvider } from "./stateProvider";
 | 
				
			||||||
 | 
					 | 
				
			||||||
import { Events, Inputs, State } from "./constants";
 | 
					 | 
				
			||||||
import * as utils from "./utils/actionUtils";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// Catch and log any unhandled exceptions.  These exceptions can leak out of the uploadChunk method in
 | 
					 | 
				
			||||||
// @actions/toolkit when a failed upload closes the file descriptor causing any in-process reads to
 | 
					 | 
				
			||||||
// throw an uncaught exception.  Instead of failing this action, just warn.
 | 
					 | 
				
			||||||
process.on("uncaughtException", e => utils.logWarning(e.message));
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
async function run(): Promise<void> {
 | 
					async function run(): Promise<void> {
 | 
				
			||||||
    try {
 | 
					    await saveImpl(new StateProvider());
 | 
				
			||||||
        if (!utils.isCacheFeatureAvailable()) {
 | 
					 | 
				
			||||||
            return;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (!utils.isValidEvent()) {
 | 
					 | 
				
			||||||
            utils.logWarning(
 | 
					 | 
				
			||||||
                `Event Validation Error: The event type ${
 | 
					 | 
				
			||||||
                    process.env[Events.Key]
 | 
					 | 
				
			||||||
                } is not supported because it's not tied to a branch or tag ref.`
 | 
					 | 
				
			||||||
            );
 | 
					 | 
				
			||||||
            return;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        const state = utils.getCacheState();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // Inputs are re-evaluted before the post action, so we want the original key used for restore
 | 
					 | 
				
			||||||
        const primaryKey = core.getState(State.CachePrimaryKey);
 | 
					 | 
				
			||||||
        if (!primaryKey) {
 | 
					 | 
				
			||||||
            utils.logWarning(`Error retrieving key from state.`);
 | 
					 | 
				
			||||||
            return;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (utils.isExactKeyMatch(primaryKey, state)) {
 | 
					 | 
				
			||||||
            core.info(
 | 
					 | 
				
			||||||
                `Cache hit occurred on the primary key ${primaryKey}, not saving cache.`
 | 
					 | 
				
			||||||
            );
 | 
					 | 
				
			||||||
            return;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        const cachePaths = utils.getInputAsArray(Inputs.Path, {
 | 
					 | 
				
			||||||
            required: true
 | 
					 | 
				
			||||||
        });
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        const cacheId = await cache.saveCache(cachePaths, primaryKey, {
 | 
					 | 
				
			||||||
            uploadChunkSize: utils.getInputAsInt(Inputs.UploadChunkSize)
 | 
					 | 
				
			||||||
        });
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (cacheId != -1) {
 | 
					 | 
				
			||||||
            core.info(`Cache saved with key: ${primaryKey}`);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    } catch (error: unknown) {
 | 
					 | 
				
			||||||
        utils.logWarning((error as Error).message);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
run();
 | 
					run();
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										65
									
								
								src/saveImpl.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										65
									
								
								src/saveImpl.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,65 @@
 | 
				
			|||||||
 | 
					import * as cache from "@actions/cache";
 | 
				
			||||||
 | 
					import * as core from "@actions/core";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import { Events, Inputs, State } from "./constants";
 | 
				
			||||||
 | 
					import { IStateProvider } from "./stateProvider";
 | 
				
			||||||
 | 
					import * as utils from "./utils/actionUtils";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Catch and log any unhandled exceptions.  These exceptions can leak out of the uploadChunk method in
 | 
				
			||||||
 | 
					// @actions/toolkit when a failed upload closes the file descriptor causing any in-process reads to
 | 
				
			||||||
 | 
					// 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<void> {
 | 
				
			||||||
 | 
					    try {
 | 
				
			||||||
 | 
					        if (!utils.isCacheFeatureAvailable()) {
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (!utils.isValidEvent()) {
 | 
				
			||||||
 | 
					            utils.logWarning(
 | 
				
			||||||
 | 
					                `Event Validation Error: The event type ${
 | 
				
			||||||
 | 
					                    process.env[Events.Key]
 | 
				
			||||||
 | 
					                } is not supported because it's not tied to a branch or tag ref.`
 | 
				
			||||||
 | 
					            );
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // If restore has stored a primary key in state, reuse that
 | 
				
			||||||
 | 
					        // Else re-evaluate from inputs
 | 
				
			||||||
 | 
					        const primaryKey =
 | 
				
			||||||
 | 
					            stateProvider.getState(State.CachePrimaryKey) ||
 | 
				
			||||||
 | 
					            core.getInput(Inputs.Key);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (!primaryKey) {
 | 
				
			||||||
 | 
					            utils.logWarning(`Error retrieving key from state.`);
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // If matched restore key is same as primary key, then do not save cache
 | 
				
			||||||
 | 
					        // NO-OP in case of SaveOnly action
 | 
				
			||||||
 | 
					        const state = stateProvider.getCacheState();
 | 
				
			||||||
 | 
					        if (utils.isExactKeyMatch(primaryKey, state)) {
 | 
				
			||||||
 | 
					            core.info(
 | 
				
			||||||
 | 
					                `Cache hit occurred on the primary key ${primaryKey}, not saving cache.`
 | 
				
			||||||
 | 
					            );
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        const cachePaths = utils.getInputAsArray(Inputs.Path, {
 | 
				
			||||||
 | 
					            required: true
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        const cacheId = await cache.saveCache(cachePaths, primaryKey, {
 | 
				
			||||||
 | 
					            uploadChunkSize: utils.getInputAsInt(Inputs.UploadChunkSize)
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (cacheId != -1) {
 | 
				
			||||||
 | 
					            core.info(`Cache saved with key: ${primaryKey}`);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    } catch (error: unknown) {
 | 
				
			||||||
 | 
					        utils.logWarning((error as Error).message);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export default saveImpl;
 | 
				
			||||||
							
								
								
									
										10
									
								
								src/saveOnly.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								src/saveOnly.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,10 @@
 | 
				
			|||||||
 | 
					import saveImpl from "./saveImpl";
 | 
				
			||||||
 | 
					import { NullStateProvider } from "./stateProvider";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					async function run(): Promise<void> {
 | 
				
			||||||
 | 
					    await saveImpl(new NullStateProvider());
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					run();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export default run;
 | 
				
			||||||
							
								
								
									
										42
									
								
								src/stateProvider.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								src/stateProvider.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,42 @@
 | 
				
			|||||||
 | 
					import * as core from "@actions/core";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import { State } from "./constants";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export interface IStateProvider {
 | 
				
			||||||
 | 
					    //setOutput(key: string, value: string): void;
 | 
				
			||||||
 | 
					    setState(key: string, value: string): void;
 | 
				
			||||||
 | 
					    getState(key: string): string;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    getCacheState(): string | undefined;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class StateProviderBase implements IStateProvider {
 | 
				
			||||||
 | 
					    getCacheState(): string | undefined {
 | 
				
			||||||
 | 
					        const cacheKey = this.getState(State.CacheMatchedKey);
 | 
				
			||||||
 | 
					        if (cacheKey) {
 | 
				
			||||||
 | 
					            core.debug(`Cache state/key: ${cacheKey}`);
 | 
				
			||||||
 | 
					            return cacheKey;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return undefined;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function
 | 
				
			||||||
 | 
					    setState = (key: string, value: string) => {};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // eslint-disable-next-line @typescript-eslint/no-unused-vars
 | 
				
			||||||
 | 
					    getState = (key: string) => "";
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export class StateProvider extends StateProviderBase {
 | 
				
			||||||
 | 
					    //setOutput = core.setOutput;
 | 
				
			||||||
 | 
					    setState = core.saveState;
 | 
				
			||||||
 | 
					    getState = core.getState;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export class NullStateProvider extends StateProviderBase {
 | 
				
			||||||
 | 
					    //setOutput = core.setOutput;
 | 
				
			||||||
 | 
					    setState = core.setOutput;
 | 
				
			||||||
 | 
					    // eslint-disable-next-line @typescript-eslint/no-unused-vars
 | 
				
			||||||
 | 
					    getState = (key: string) => "";
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -1,7 +1,7 @@
 | 
				
			|||||||
import * as cache from "@actions/cache";
 | 
					import * as cache from "@actions/cache";
 | 
				
			||||||
import * as core from "@actions/core";
 | 
					import * as core from "@actions/core";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import { Outputs, RefKey, State } from "../constants";
 | 
					import { Outputs, RefKey } from "../constants";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function isGhes(): boolean {
 | 
					export function isGhes(): boolean {
 | 
				
			||||||
    const ghUrl = new URL(
 | 
					    const ghUrl = new URL(
 | 
				
			||||||
@@ -19,30 +19,10 @@ export function isExactKeyMatch(key: string, cacheKey?: string): boolean {
 | 
				
			|||||||
    );
 | 
					    );
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function setCacheState(state: string): void {
 | 
					 | 
				
			||||||
    core.saveState(State.CacheMatchedKey, state);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
export function setCacheHitOutput(isCacheHit: boolean): void {
 | 
					export function setCacheHitOutput(isCacheHit: boolean): void {
 | 
				
			||||||
    core.setOutput(Outputs.CacheHit, isCacheHit.toString());
 | 
					    core.setOutput(Outputs.CacheHit, isCacheHit.toString());
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function setOutputAndState(key: string, cacheKey?: string): void {
 | 
					 | 
				
			||||||
    setCacheHitOutput(isExactKeyMatch(key, cacheKey));
 | 
					 | 
				
			||||||
    // Store the matched cache key if it exists
 | 
					 | 
				
			||||||
    cacheKey && setCacheState(cacheKey);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
export function getCacheState(): string | undefined {
 | 
					 | 
				
			||||||
    const cacheKey = core.getState(State.CacheMatchedKey);
 | 
					 | 
				
			||||||
    if (cacheKey) {
 | 
					 | 
				
			||||||
        core.debug(`Cache state/key: ${cacheKey}`);
 | 
					 | 
				
			||||||
        return cacheKey;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    return undefined;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
export function logWarning(message: string): void {
 | 
					export function logWarning(message: string): void {
 | 
				
			||||||
    const warningPrefix = "[warning]";
 | 
					    const warningPrefix = "[warning]";
 | 
				
			||||||
    core.info(`${warningPrefix}${message}`);
 | 
					    core.info(`${warningPrefix}${message}`);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user