mirror of
https://github.com/actions/setup-go.git
synced 2026-06-25 23:17:41 +00:00
Compare commits
No commits in common. "main" and "v6.4.0" have entirely different histories.
BIN
.licenses/npm/@actions/cache.dep.yml
generated
BIN
.licenses/npm/@actions/cache.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@actions/core-1.11.1.dep.yml
generated
Normal file
BIN
.licenses/npm/@actions/core-1.11.1.dep.yml
generated
Normal file
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/@actions/exec-1.1.1.dep.yml
generated
Normal file
BIN
.licenses/npm/@actions/exec-1.1.1.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/@actions/glob.dep.yml
generated
BIN
.licenses/npm/@actions/glob.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@actions/http-client-2.2.3.dep.yml
generated
Normal file
BIN
.licenses/npm/@actions/http-client-2.2.3.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/@actions/io-1.1.3.dep.yml
generated
Normal file
BIN
.licenses/npm/@actions/io-1.1.3.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/@actions/tool-cache.dep.yml
generated
BIN
.licenses/npm/@actions/tool-cache.dep.yml
generated
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/@nodable/entities.dep.yml
generated
BIN
.licenses/npm/@nodable/entities.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/brace-expansion.dep.yml
generated
BIN
.licenses/npm/brace-expansion.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/fast-xml-builder.dep.yml
generated
BIN
.licenses/npm/fast-xml-builder.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/fast-xml-parser.dep.yml
generated
BIN
.licenses/npm/fast-xml-parser.dep.yml
generated
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/strnum.dep.yml
generated
BIN
.licenses/npm/strnum.dep.yml
generated
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/xml-naming.dep.yml
generated
BIN
.licenses/npm/xml-naming.dep.yml
generated
Binary file not shown.
@ -1,155 +0,0 @@
|
|||||||
import * as cache from '@actions/cache';
|
|
||||||
import * as core from '@actions/core';
|
|
||||||
import fs from 'fs';
|
|
||||||
|
|
||||||
import {run} from '../src/cache-save';
|
|
||||||
import * as cacheUtils from '../src/cache-utils';
|
|
||||||
import {State} from '../src/constants';
|
|
||||||
|
|
||||||
describe('cache-save', () => {
|
|
||||||
const primaryKey = 'primary-key';
|
|
||||||
|
|
||||||
let primaryKeyValue: string;
|
|
||||||
let matchedKeyValue: string;
|
|
||||||
|
|
||||||
let getBooleanInputSpy: jest.SpyInstance;
|
|
||||||
let getStateSpy: jest.SpyInstance;
|
|
||||||
let infoSpy: jest.SpyInstance;
|
|
||||||
let warningSpy: jest.SpyInstance;
|
|
||||||
let debugSpy: jest.SpyInstance;
|
|
||||||
let setFailedSpy: jest.SpyInstance;
|
|
||||||
let saveCacheSpy: jest.SpyInstance;
|
|
||||||
let getCacheDirectoryPathSpy: jest.SpyInstance;
|
|
||||||
let existsSpy: jest.SpyInstance;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
primaryKeyValue = primaryKey;
|
|
||||||
matchedKeyValue = 'matched-key';
|
|
||||||
|
|
||||||
getBooleanInputSpy = jest.spyOn(core, 'getBooleanInput');
|
|
||||||
getBooleanInputSpy.mockReturnValue(true);
|
|
||||||
|
|
||||||
getStateSpy = jest.spyOn(core, 'getState');
|
|
||||||
getStateSpy.mockImplementation((key: string) => {
|
|
||||||
if (key === State.CachePrimaryKey) {
|
|
||||||
return primaryKeyValue;
|
|
||||||
}
|
|
||||||
if (key === State.CacheMatchedKey) {
|
|
||||||
return matchedKeyValue;
|
|
||||||
}
|
|
||||||
return '';
|
|
||||||
});
|
|
||||||
|
|
||||||
infoSpy = jest.spyOn(core, 'info');
|
|
||||||
infoSpy.mockImplementation(() => undefined);
|
|
||||||
|
|
||||||
warningSpy = jest.spyOn(core, 'warning');
|
|
||||||
warningSpy.mockImplementation(() => undefined);
|
|
||||||
|
|
||||||
debugSpy = jest.spyOn(core, 'debug');
|
|
||||||
debugSpy.mockImplementation(() => undefined);
|
|
||||||
|
|
||||||
setFailedSpy = jest.spyOn(core, 'setFailed');
|
|
||||||
setFailedSpy.mockImplementation(() => undefined);
|
|
||||||
|
|
||||||
saveCacheSpy = jest.spyOn(cache, 'saveCache');
|
|
||||||
saveCacheSpy.mockImplementation(() => Promise.resolve(0));
|
|
||||||
|
|
||||||
getCacheDirectoryPathSpy = jest.spyOn(cacheUtils, 'getCacheDirectoryPath');
|
|
||||||
getCacheDirectoryPathSpy.mockImplementation(() =>
|
|
||||||
Promise.resolve(['cache_directory_path', 'cache_directory_path'])
|
|
||||||
);
|
|
||||||
|
|
||||||
existsSpy = jest.spyOn(fs, 'existsSync');
|
|
||||||
existsSpy.mockImplementation(() => true);
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
jest.restoreAllMocks();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('does not save cache when the cache input is false', async () => {
|
|
||||||
getBooleanInputSpy.mockReturnValue(false);
|
|
||||||
|
|
||||||
await run();
|
|
||||||
|
|
||||||
expect(saveCacheSpy).not.toHaveBeenCalled();
|
|
||||||
expect(warningSpy).not.toHaveBeenCalled();
|
|
||||||
expect(setFailedSpy).not.toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('does not save cache when there are no cache folders on the disk', async () => {
|
|
||||||
existsSpy.mockImplementation(() => false);
|
|
||||||
|
|
||||||
await run();
|
|
||||||
|
|
||||||
expect(warningSpy).toHaveBeenCalledWith(
|
|
||||||
'There are no cache folders on the disk'
|
|
||||||
);
|
|
||||||
expect(saveCacheSpy).not.toHaveBeenCalled();
|
|
||||||
expect(setFailedSpy).not.toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('does not save cache when the primary key was not generated', async () => {
|
|
||||||
primaryKeyValue = '';
|
|
||||||
|
|
||||||
await run();
|
|
||||||
|
|
||||||
expect(infoSpy).toHaveBeenCalledWith(
|
|
||||||
'Primary key was not generated. Please check the log messages above for more errors or information'
|
|
||||||
);
|
|
||||||
expect(saveCacheSpy).not.toHaveBeenCalled();
|
|
||||||
expect(setFailedSpy).not.toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('does not save cache when a cache hit occurred on the primary key', async () => {
|
|
||||||
matchedKeyValue = primaryKey;
|
|
||||||
|
|
||||||
await run();
|
|
||||||
|
|
||||||
expect(infoSpy).toHaveBeenCalledWith(
|
|
||||||
`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`
|
|
||||||
);
|
|
||||||
expect(saveCacheSpy).not.toHaveBeenCalled();
|
|
||||||
expect(setFailedSpy).not.toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('saves cache when the primary key differs from the matched key', async () => {
|
|
||||||
await run();
|
|
||||||
|
|
||||||
expect(saveCacheSpy).toHaveBeenCalled();
|
|
||||||
expect(infoSpy).toHaveBeenCalledWith(
|
|
||||||
`Cache saved with the key: ${primaryKey}`
|
|
||||||
);
|
|
||||||
expect(warningSpy).not.toHaveBeenCalled();
|
|
||||||
expect(setFailedSpy).not.toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('save with -1 cacheId , should not fail workflow', async () => {
|
|
||||||
saveCacheSpy.mockImplementation(() => Promise.resolve(-1));
|
|
||||||
|
|
||||||
await run();
|
|
||||||
|
|
||||||
expect(saveCacheSpy).toHaveBeenCalled();
|
|
||||||
expect(debugSpy).toHaveBeenCalledWith(
|
|
||||||
`Cache was not saved for the key: ${primaryKey}`
|
|
||||||
);
|
|
||||||
expect(infoSpy).not.toHaveBeenCalledWith(
|
|
||||||
`Cache saved with the key: ${primaryKey}`
|
|
||||||
);
|
|
||||||
expect(warningSpy).not.toHaveBeenCalled();
|
|
||||||
expect(setFailedSpy).not.toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('saves with error from toolkit, should not fail workflow', async () => {
|
|
||||||
saveCacheSpy.mockImplementation(() =>
|
|
||||||
Promise.reject(new Error('Unable to reach the service'))
|
|
||||||
);
|
|
||||||
|
|
||||||
await run();
|
|
||||||
|
|
||||||
expect(saveCacheSpy).toHaveBeenCalled();
|
|
||||||
expect(warningSpy).toHaveBeenCalledWith('Unable to reach the service');
|
|
||||||
expect(setFailedSpy).not.toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
58053
dist/cache-save/index.js
vendored
58053
dist/cache-save/index.js
vendored
File diff suppressed because one or more lines are too long
58277
dist/setup/index.js
vendored
58277
dist/setup/index.js
vendored
File diff suppressed because one or more lines are too long
762
package-lock.json
generated
762
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
22
package.json
22
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "setup-go",
|
"name": "setup-go",
|
||||||
"version": "6.5.0",
|
"version": "6.2.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "setup go action",
|
"description": "setup go action",
|
||||||
"main": "lib/setup-go.js",
|
"main": "lib/setup-go.js",
|
||||||
@ -28,21 +28,21 @@
|
|||||||
"author": "GitHub",
|
"author": "GitHub",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/cache": "^5.1.0",
|
"@actions/cache": "^5.0.1",
|
||||||
"@actions/core": "^2.0.3",
|
"@actions/core": "^1.11.1",
|
||||||
"@actions/exec": "^2.0.0",
|
"@actions/exec": "^1.1.1",
|
||||||
"@actions/glob": "^0.5.1",
|
"@actions/glob": "^0.5.0",
|
||||||
"@actions/http-client": "^3.0.2",
|
"@actions/http-client": "^2.2.1",
|
||||||
"@actions/io": "^2.0.0",
|
"@actions/io": "^1.0.2",
|
||||||
"@actions/tool-cache": "^3.0.1",
|
"@actions/tool-cache": "^2.0.2",
|
||||||
"semver": "^7.7.3"
|
"semver": "^7.7.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^29.5.14",
|
"@types/jest": "^29.5.14",
|
||||||
"@types/node": "^25.9.3",
|
"@types/node": "^24.1.0",
|
||||||
"@types/semver": "^7.7.1",
|
"@types/semver": "^7.7.1",
|
||||||
"@typescript-eslint/eslint-plugin": "^8.61.0",
|
"@typescript-eslint/eslint-plugin": "^8.31.1",
|
||||||
"@typescript-eslint/parser": "^8.61.0",
|
"@typescript-eslint/parser": "^8.35.1",
|
||||||
"@vercel/ncc": "^0.38.1",
|
"@vercel/ncc": "^0.38.1",
|
||||||
"eslint": "^8.57.0",
|
"eslint": "^8.57.0",
|
||||||
"eslint-config-prettier": "^10.1.8",
|
"eslint-config-prettier": "^10.1.8",
|
||||||
|
|||||||
@ -81,10 +81,6 @@ const cachePackages = async () => {
|
|||||||
|
|
||||||
const cacheId = await cache.saveCache(cachePaths, primaryKey);
|
const cacheId = await cache.saveCache(cachePaths, primaryKey);
|
||||||
if (cacheId === -1) {
|
if (cacheId === -1) {
|
||||||
// saveCache returns -1 without throwing when the cache was not saved, e.g.
|
|
||||||
// a reserve collision or a read-only token (fork PR). @actions/cache has
|
|
||||||
// already logged the reason at the appropriate severity, so just trace it.
|
|
||||||
core.debug(`Cache was not saved for the key: ${primaryKey}`);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
core.info(`Cache saved with the key: ${primaryKey}`);
|
core.info(`Cache saved with the key: ${primaryKey}`);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user