mirror of
				https://github.com/actions/setup-node.git
				synced 2025-11-04 05:19:11 +08:00 
			
		
		
		
	Merge pull request #526 from IvanZosimov/CacheVersionUpdate
Add support for the @actions/cache library 3.0.0
This commit is contained in:
		
							
								
								
									
										2
									
								
								.licenses/npm/@actions/cache.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										2
									
								
								.licenses/npm/@actions/cache.dep.yml
									
									
									
										generated
									
									
									
								
							@@ -1,6 +1,6 @@
 | 
			
		||||
---
 | 
			
		||||
name: "@actions/cache"
 | 
			
		||||
version: 2.0.2
 | 
			
		||||
version: 3.0.0
 | 
			
		||||
type: npm
 | 
			
		||||
summary: Actions cache lib
 | 
			
		||||
homepage: https://github.com/actions/toolkit/tree/main/packages/cache
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										32
									
								
								.licenses/npm/@actions/http-client-2.0.1.dep.yml
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								.licenses/npm/@actions/http-client-2.0.1.dep.yml
									
									
									
										generated
									
									
									
										Normal file
									
								
							@@ -0,0 +1,32 @@
 | 
			
		||||
---
 | 
			
		||||
name: "@actions/http-client"
 | 
			
		||||
version: 2.0.1
 | 
			
		||||
type: npm
 | 
			
		||||
summary: Actions Http Client
 | 
			
		||||
homepage: https://github.com/actions/toolkit/tree/main/packages/http-client
 | 
			
		||||
license: mit
 | 
			
		||||
licenses:
 | 
			
		||||
- sources: LICENSE
 | 
			
		||||
  text: |
 | 
			
		||||
    Actions Http Client for Node.js
 | 
			
		||||
 | 
			
		||||
    Copyright (c) GitHub, Inc.
 | 
			
		||||
 | 
			
		||||
    All rights reserved.
 | 
			
		||||
 | 
			
		||||
    MIT License
 | 
			
		||||
 | 
			
		||||
    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: []
 | 
			
		||||
@@ -294,6 +294,63 @@ describe('run', () => {
 | 
			
		||||
      );
 | 
			
		||||
      expect(setFailedSpy).not.toHaveBeenCalled();
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    it('save with -1 cacheId , should not fail workflow', async () => {
 | 
			
		||||
      inputs['cache'] = 'npm';
 | 
			
		||||
      getStateSpy.mockImplementation((name: string) => {
 | 
			
		||||
        if (name === State.CacheMatchedKey) {
 | 
			
		||||
          return npmFileHash;
 | 
			
		||||
        } else {
 | 
			
		||||
          return yarnFileHash;
 | 
			
		||||
        }
 | 
			
		||||
      });
 | 
			
		||||
      getCommandOutputSpy.mockImplementationOnce(() => `${commonPath}/npm`);
 | 
			
		||||
      saveCacheSpy.mockImplementation(() => {
 | 
			
		||||
        return -1;
 | 
			
		||||
      });
 | 
			
		||||
 | 
			
		||||
      await run();
 | 
			
		||||
 | 
			
		||||
      expect(getInputSpy).toHaveBeenCalled();
 | 
			
		||||
      expect(getStateSpy).toHaveBeenCalledTimes(2);
 | 
			
		||||
      expect(getCommandOutputSpy).toHaveBeenCalledTimes(1);
 | 
			
		||||
      expect(debugSpy).toHaveBeenCalledWith(`npm path is ${commonPath}/npm`);
 | 
			
		||||
      expect(infoSpy).not.toHaveBeenCalledWith(
 | 
			
		||||
        `Cache hit occurred on the primary key ${npmFileHash}, not saving cache.`
 | 
			
		||||
      );
 | 
			
		||||
      expect(saveCacheSpy).toHaveBeenCalled();
 | 
			
		||||
      expect(infoSpy).not.toHaveBeenLastCalledWith(
 | 
			
		||||
        `Cache saved with the key: ${yarnFileHash}`
 | 
			
		||||
      );
 | 
			
		||||
      expect(setFailedSpy).not.toHaveBeenCalled();
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    it('saves with error from toolkit, should fail workflow', async () => {
 | 
			
		||||
      inputs['cache'] = 'npm';
 | 
			
		||||
      getStateSpy.mockImplementation((name: string) => {
 | 
			
		||||
        if (name === State.CacheMatchedKey) {
 | 
			
		||||
          return npmFileHash;
 | 
			
		||||
        } else {
 | 
			
		||||
          return yarnFileHash;
 | 
			
		||||
        }
 | 
			
		||||
      });
 | 
			
		||||
      getCommandOutputSpy.mockImplementationOnce(() => `${commonPath}/npm`);
 | 
			
		||||
      saveCacheSpy.mockImplementation(() => {
 | 
			
		||||
        throw new cache.ValidationError('Validation failed');
 | 
			
		||||
      });
 | 
			
		||||
 | 
			
		||||
      await run();
 | 
			
		||||
 | 
			
		||||
      expect(getInputSpy).toHaveBeenCalled();
 | 
			
		||||
      expect(getStateSpy).toHaveBeenCalledTimes(2);
 | 
			
		||||
      expect(getCommandOutputSpy).toHaveBeenCalledTimes(1);
 | 
			
		||||
      expect(debugSpy).toHaveBeenCalledWith(`npm path is ${commonPath}/npm`);
 | 
			
		||||
      expect(infoSpy).not.toHaveBeenCalledWith(
 | 
			
		||||
        `Cache hit occurred on the primary key ${npmFileHash}, not saving cache.`
 | 
			
		||||
      );
 | 
			
		||||
      expect(saveCacheSpy).toHaveBeenCalled();
 | 
			
		||||
      expect(setFailedSpy).toHaveBeenCalled();
 | 
			
		||||
    });
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  afterEach(() => {
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										1217
									
								
								dist/cache-save/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1217
									
								
								dist/cache-save/index.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										2291
									
								
								dist/setup/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2291
									
								
								dist/setup/index.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										34
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										34
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							@@ -9,7 +9,7 @@
 | 
			
		||||
      "version": "3.1.1",
 | 
			
		||||
      "license": "MIT",
 | 
			
		||||
      "dependencies": {
 | 
			
		||||
        "@actions/cache": "^2.0.2",
 | 
			
		||||
        "@actions/cache": "^3.0.0",
 | 
			
		||||
        "@actions/core": "^1.6.0",
 | 
			
		||||
        "@actions/exec": "^1.1.0",
 | 
			
		||||
        "@actions/github": "^1.1.0",
 | 
			
		||||
@@ -32,14 +32,14 @@
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    "node_modules/@actions/cache": {
 | 
			
		||||
      "version": "2.0.2",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-2.0.2.tgz",
 | 
			
		||||
      "integrity": "sha512-K1DCaW/OtHj5mV7hI7HEXiceX3rM4Nc0iG2hfYsrkEy6GiOeqlCC/LyICrBZIRDM6+vSrS12tg1ORl4hghomBA==",
 | 
			
		||||
      "version": "3.0.0",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.0.0.tgz",
 | 
			
		||||
      "integrity": "sha512-GL9CT1Fnu+pqs8TTB621q8Xa8Cilw2n9MwvbgMedetH7L1q2n6jY61gzbwGbKgtVbp3gVJ12aNMi4osSGXx3KQ==",
 | 
			
		||||
      "dependencies": {
 | 
			
		||||
        "@actions/core": "^1.2.6",
 | 
			
		||||
        "@actions/exec": "^1.0.1",
 | 
			
		||||
        "@actions/glob": "^0.1.0",
 | 
			
		||||
        "@actions/http-client": "^1.0.9",
 | 
			
		||||
        "@actions/http-client": "^2.0.1",
 | 
			
		||||
        "@actions/io": "^1.0.1",
 | 
			
		||||
        "@azure/ms-rest-js": "^2.6.0",
 | 
			
		||||
        "@azure/storage-blob": "^12.8.0",
 | 
			
		||||
@@ -56,6 +56,14 @@
 | 
			
		||||
        "minimatch": "^3.0.4"
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    "node_modules/@actions/cache/node_modules/@actions/http-client": {
 | 
			
		||||
      "version": "2.0.1",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.0.1.tgz",
 | 
			
		||||
      "integrity": "sha512-PIXiMVtz6VvyaRsGY268qvj57hXQEpsYogYOu2nrQhlf+XCGmZstmuZBbAybUl1nQGnvS1k1eEsQ69ZoD7xlSw==",
 | 
			
		||||
      "dependencies": {
 | 
			
		||||
        "tunnel": "^0.0.6"
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    "node_modules/@actions/cache/node_modules/uuid": {
 | 
			
		||||
      "version": "3.4.0",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
 | 
			
		||||
@@ -5079,14 +5087,14 @@
 | 
			
		||||
  },
 | 
			
		||||
  "dependencies": {
 | 
			
		||||
    "@actions/cache": {
 | 
			
		||||
      "version": "2.0.2",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-2.0.2.tgz",
 | 
			
		||||
      "integrity": "sha512-K1DCaW/OtHj5mV7hI7HEXiceX3rM4Nc0iG2hfYsrkEy6GiOeqlCC/LyICrBZIRDM6+vSrS12tg1ORl4hghomBA==",
 | 
			
		||||
      "version": "3.0.0",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.0.0.tgz",
 | 
			
		||||
      "integrity": "sha512-GL9CT1Fnu+pqs8TTB621q8Xa8Cilw2n9MwvbgMedetH7L1q2n6jY61gzbwGbKgtVbp3gVJ12aNMi4osSGXx3KQ==",
 | 
			
		||||
      "requires": {
 | 
			
		||||
        "@actions/core": "^1.2.6",
 | 
			
		||||
        "@actions/exec": "^1.0.1",
 | 
			
		||||
        "@actions/glob": "^0.1.0",
 | 
			
		||||
        "@actions/http-client": "^1.0.9",
 | 
			
		||||
        "@actions/http-client": "^2.0.1",
 | 
			
		||||
        "@actions/io": "^1.0.1",
 | 
			
		||||
        "@azure/ms-rest-js": "^2.6.0",
 | 
			
		||||
        "@azure/storage-blob": "^12.8.0",
 | 
			
		||||
@@ -5103,6 +5111,14 @@
 | 
			
		||||
            "minimatch": "^3.0.4"
 | 
			
		||||
          }
 | 
			
		||||
        },
 | 
			
		||||
        "@actions/http-client": {
 | 
			
		||||
          "version": "2.0.1",
 | 
			
		||||
          "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.0.1.tgz",
 | 
			
		||||
          "integrity": "sha512-PIXiMVtz6VvyaRsGY268qvj57hXQEpsYogYOu2nrQhlf+XCGmZstmuZBbAybUl1nQGnvS1k1eEsQ69ZoD7xlSw==",
 | 
			
		||||
          "requires": {
 | 
			
		||||
            "tunnel": "^0.0.6"
 | 
			
		||||
          }
 | 
			
		||||
        },
 | 
			
		||||
        "uuid": {
 | 
			
		||||
          "version": "3.4.0",
 | 
			
		||||
          "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
 | 
			
		||||
 
 | 
			
		||||
@@ -8,7 +8,7 @@
 | 
			
		||||
    "build": "ncc build -o dist/setup src/setup-node.ts && ncc build -o dist/cache-save src/cache-save.ts",
 | 
			
		||||
    "format": "prettier --write **/*.ts",
 | 
			
		||||
    "format-check": "prettier --check **/*.ts",
 | 
			
		||||
    "test": "jest",
 | 
			
		||||
    "test": "jest --coverage",
 | 
			
		||||
    "pre-checkin": "npm run format && npm run build && npm test"
 | 
			
		||||
  },
 | 
			
		||||
  "repository": {
 | 
			
		||||
@@ -23,7 +23,7 @@
 | 
			
		||||
  "author": "GitHub",
 | 
			
		||||
  "license": "MIT",
 | 
			
		||||
  "dependencies": {
 | 
			
		||||
    "@actions/cache": "^2.0.2",
 | 
			
		||||
    "@actions/cache": "^3.0.0",
 | 
			
		||||
    "@actions/core": "^1.6.0",
 | 
			
		||||
    "@actions/exec": "^1.1.0",
 | 
			
		||||
    "@actions/github": "^1.1.0",
 | 
			
		||||
 
 | 
			
		||||
@@ -49,18 +49,12 @@ const cachePackages = async (packageManager: string) => {
 | 
			
		||||
    return;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  try {
 | 
			
		||||
    await cache.saveCache([cachePath], primaryKey);
 | 
			
		||||
    core.info(`Cache saved with the key: ${primaryKey}`);
 | 
			
		||||
  } catch (error) {
 | 
			
		||||
    if (error.name === cache.ValidationError.name) {
 | 
			
		||||
      throw error;
 | 
			
		||||
    } else if (error.name === cache.ReserveCacheError.name) {
 | 
			
		||||
      core.info(error.message);
 | 
			
		||||
    } else {
 | 
			
		||||
      core.warning(`${error.message}`);
 | 
			
		||||
    }
 | 
			
		||||
  const cacheId = await cache.saveCache([cachePath], primaryKey);
 | 
			
		||||
  if (cacheId == -1) {
 | 
			
		||||
    return;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  core.info(`Cache saved with the key: ${primaryKey}`);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
run();
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user