|
|
|
@ -20,6 +20,7 @@ describe('setup-go', () => {
|
|
|
|
|
|
|
|
|
|
let inSpy: jest.SpyInstance;
|
|
|
|
|
let getBooleanInputSpy: jest.SpyInstance;
|
|
|
|
|
let exportVarSpy: jest.SpyInstance;
|
|
|
|
|
let findSpy: jest.SpyInstance;
|
|
|
|
|
let cnSpy: jest.SpyInstance;
|
|
|
|
|
let logSpy: jest.SpyInstance;
|
|
|
|
@ -27,7 +28,7 @@ describe('setup-go', () => {
|
|
|
|
|
let platSpy: jest.SpyInstance;
|
|
|
|
|
let archSpy: jest.SpyInstance;
|
|
|
|
|
let dlSpy: jest.SpyInstance;
|
|
|
|
|
let exSpy: jest.SpyInstance;
|
|
|
|
|
let extractTarSpy: jest.SpyInstance;
|
|
|
|
|
let cacheSpy: jest.SpyInstance;
|
|
|
|
|
let dbgSpy: jest.SpyInstance;
|
|
|
|
|
let whichSpy: jest.SpyInstance;
|
|
|
|
@ -49,7 +50,8 @@ describe('setup-go', () => {
|
|
|
|
|
inSpy.mockImplementation(name => inputs[name]);
|
|
|
|
|
getBooleanInputSpy = jest.spyOn(core, 'getBooleanInput');
|
|
|
|
|
getBooleanInputSpy.mockImplementation(name => inputs[name]);
|
|
|
|
|
exSpy = jest.spyOn(core, 'exportVariable');
|
|
|
|
|
exportVarSpy = jest.spyOn(core, 'exportVariable');
|
|
|
|
|
extractTarSpy = jest.spyOn(core, 'exportVariable');
|
|
|
|
|
|
|
|
|
|
// node
|
|
|
|
|
os = {};
|
|
|
|
@ -62,7 +64,7 @@ describe('setup-go', () => {
|
|
|
|
|
// @actions/tool-cache
|
|
|
|
|
findSpy = jest.spyOn(tc, 'find');
|
|
|
|
|
dlSpy = jest.spyOn(tc, 'downloadTool');
|
|
|
|
|
exSpy = jest.spyOn(tc, 'extractTar');
|
|
|
|
|
extractTarSpy = jest.spyOn(tc, 'extractTar');
|
|
|
|
|
cacheSpy = jest.spyOn(tc, 'cacheDir');
|
|
|
|
|
getSpy = jest.spyOn(im, 'getVersionsDist');
|
|
|
|
|
getManifestSpy = jest.spyOn(tc, 'getManifestFromRepo');
|
|
|
|
@ -231,15 +233,15 @@ describe('setup-go', () => {
|
|
|
|
|
expect(logSpy).toHaveBeenCalledWith(`Setup go version spec 1.13.0`);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('does not export any varibles', async () => {
|
|
|
|
|
it('does not export any variables for Go versions >=1.9', async () => {
|
|
|
|
|
inputs['go-version'] = '1.13.0';
|
|
|
|
|
inSpy.mockImplementation(name => inputs[name]);
|
|
|
|
|
|
|
|
|
|
let toolPath = path.normalize('/cache/go/1.13.0/x64');
|
|
|
|
|
findSpy.mockImplementation(() => toolPath);
|
|
|
|
|
|
|
|
|
|
let vars = {} as any;
|
|
|
|
|
exSpy.mockImplementation(async (name, val) => {
|
|
|
|
|
let vars: { [key: string]: string; } = {};
|
|
|
|
|
exportVarSpy.mockImplementation((name: string, val: string) => {
|
|
|
|
|
vars[name] = val;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@ -247,6 +249,25 @@ describe('setup-go', () => {
|
|
|
|
|
expect(vars).toStrictEqual({});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('exports GOROOT for Go versions <1.9', async () => {
|
|
|
|
|
inputs['go-version'] = '1.8';
|
|
|
|
|
inSpy.mockImplementation(name => inputs[name]);
|
|
|
|
|
|
|
|
|
|
let toolPath = path.normalize('/cache/go/1.8.0/x64');
|
|
|
|
|
findSpy.mockImplementation(() => toolPath);
|
|
|
|
|
|
|
|
|
|
let vars: { [key: string]: string; } = {};
|
|
|
|
|
exportVarSpy.mockImplementation((name: string, val: string) => {
|
|
|
|
|
vars[name] = val;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
await main.run();
|
|
|
|
|
expect(vars).toStrictEqual({
|
|
|
|
|
"GOROOT": toolPath
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it('finds a version of go already in the cache', async () => {
|
|
|
|
|
inputs['go-version'] = '1.13.0';
|
|
|
|
|
|
|
|
|
@ -288,14 +309,14 @@ describe('setup-go', () => {
|
|
|
|
|
findSpy.mockImplementation(() => '');
|
|
|
|
|
dlSpy.mockImplementation(() => '/some/temp/path');
|
|
|
|
|
let toolPath = path.normalize('/cache/go/1.13.0/x64');
|
|
|
|
|
exSpy.mockImplementation(() => '/some/other/temp/path');
|
|
|
|
|
extractTarSpy.mockImplementation(() => '/some/other/temp/path');
|
|
|
|
|
cacheSpy.mockImplementation(() => toolPath);
|
|
|
|
|
await main.run();
|
|
|
|
|
|
|
|
|
|
let expPath = path.join(toolPath, 'bin');
|
|
|
|
|
|
|
|
|
|
expect(dlSpy).toHaveBeenCalled();
|
|
|
|
|
expect(exSpy).toHaveBeenCalled();
|
|
|
|
|
expect(extractTarSpy).toHaveBeenCalled();
|
|
|
|
|
expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@ -330,7 +351,7 @@ describe('setup-go', () => {
|
|
|
|
|
|
|
|
|
|
dlSpy.mockImplementation(async () => '/some/temp/path');
|
|
|
|
|
let toolPath = path.normalize('/cache/go/1.12.16/x64');
|
|
|
|
|
exSpy.mockImplementation(async () => '/some/other/temp/path');
|
|
|
|
|
extractTarSpy.mockImplementation(async () => '/some/other/temp/path');
|
|
|
|
|
cacheSpy.mockImplementation(async () => toolPath);
|
|
|
|
|
|
|
|
|
|
await main.run();
|
|
|
|
@ -338,7 +359,7 @@ describe('setup-go', () => {
|
|
|
|
|
let expPath = path.join(toolPath, 'bin');
|
|
|
|
|
|
|
|
|
|
expect(dlSpy).toHaveBeenCalled();
|
|
|
|
|
expect(exSpy).toHaveBeenCalled();
|
|
|
|
|
expect(extractTarSpy).toHaveBeenCalled();
|
|
|
|
|
expect(logSpy).not.toHaveBeenCalledWith(
|
|
|
|
|
'Not found in manifest. Falling back to download directly from Go'
|
|
|
|
|
);
|
|
|
|
@ -367,7 +388,7 @@ describe('setup-go', () => {
|
|
|
|
|
|
|
|
|
|
dlSpy.mockImplementation(async () => '/some/temp/path');
|
|
|
|
|
let toolPath = path.normalize('/cache/go/1.12.17/x64');
|
|
|
|
|
exSpy.mockImplementation(async () => '/some/other/temp/path');
|
|
|
|
|
extractTarSpy.mockImplementation(async () => '/some/other/temp/path');
|
|
|
|
|
cacheSpy.mockImplementation(async () => toolPath);
|
|
|
|
|
|
|
|
|
|
await main.run();
|
|
|
|
@ -375,7 +396,7 @@ describe('setup-go', () => {
|
|
|
|
|
let expPath = path.join(toolPath, 'bin');
|
|
|
|
|
|
|
|
|
|
expect(dlSpy).toHaveBeenCalled();
|
|
|
|
|
expect(exSpy).toHaveBeenCalled();
|
|
|
|
|
expect(extractTarSpy).toHaveBeenCalled();
|
|
|
|
|
expect(logSpy).not.toHaveBeenCalledWith(
|
|
|
|
|
'Not found in manifest. Falling back to download directly from Go'
|
|
|
|
|
);
|
|
|
|
@ -404,7 +425,7 @@ describe('setup-go', () => {
|
|
|
|
|
|
|
|
|
|
dlSpy.mockImplementation(async () => '/some/temp/path');
|
|
|
|
|
let toolPath = path.normalize('/cache/go/1.12.14/x64');
|
|
|
|
|
exSpy.mockImplementation(async () => '/some/other/temp/path');
|
|
|
|
|
extractTarSpy.mockImplementation(async () => '/some/other/temp/path');
|
|
|
|
|
cacheSpy.mockImplementation(async () => toolPath);
|
|
|
|
|
|
|
|
|
|
await main.run();
|
|
|
|
@ -415,7 +436,7 @@ describe('setup-go', () => {
|
|
|
|
|
expect(logSpy).toHaveBeenCalledWith('Attempting to download 1.12.14...');
|
|
|
|
|
expect(dlSpy).toHaveBeenCalled();
|
|
|
|
|
expect(logSpy).toHaveBeenCalledWith('matching 1.12.14...');
|
|
|
|
|
expect(exSpy).toHaveBeenCalled();
|
|
|
|
|
expect(extractTarSpy).toHaveBeenCalled();
|
|
|
|
|
expect(logSpy).toHaveBeenCalledWith(
|
|
|
|
|
'Not found in manifest. Falling back to download directly from Go'
|
|
|
|
|
);
|
|
|
|
@ -617,7 +638,7 @@ describe('setup-go', () => {
|
|
|
|
|
const toolPath = path.normalize('/cache/go/1.16.1/x64');
|
|
|
|
|
findSpy.mockReturnValue(toolPath);
|
|
|
|
|
dlSpy.mockImplementation(async () => '/some/temp/path');
|
|
|
|
|
exSpy.mockImplementation(async () => '/some/other/temp/path');
|
|
|
|
|
extractTarSpy.mockImplementation(async () => '/some/other/temp/path');
|
|
|
|
|
cacheSpy.mockImplementation(async () => toolPath);
|
|
|
|
|
|
|
|
|
|
await main.run();
|
|
|
|
@ -639,7 +660,7 @@ describe('setup-go', () => {
|
|
|
|
|
findSpy.mockImplementation(() => '');
|
|
|
|
|
dlSpy.mockImplementation(async () => '/some/temp/path');
|
|
|
|
|
const toolPath = path.normalize('/cache/go/1.17.5/x64');
|
|
|
|
|
exSpy.mockImplementation(async () => '/some/other/temp/path');
|
|
|
|
|
extractTarSpy.mockImplementation(async () => '/some/other/temp/path');
|
|
|
|
|
cacheSpy.mockImplementation(async () => toolPath);
|
|
|
|
|
const expectedUrl =
|
|
|
|
|
'https://github.com/actions/go-versions/releases/download/1.17.6-1668090892/go-1.17.6-darwin-x64.tar.gz';
|
|
|
|
@ -680,7 +701,7 @@ describe('setup-go', () => {
|
|
|
|
|
|
|
|
|
|
dlSpy.mockImplementation(async () => '/some/temp/path');
|
|
|
|
|
let toolPath = path.normalize('/cache/go/1.13.7/x64');
|
|
|
|
|
exSpy.mockImplementation(async () => '/some/other/temp/path');
|
|
|
|
|
extractTarSpy.mockImplementation(async () => '/some/other/temp/path');
|
|
|
|
|
cacheSpy.mockImplementation(async () => toolPath);
|
|
|
|
|
|
|
|
|
|
await main.run();
|
|
|
|
@ -688,7 +709,7 @@ describe('setup-go', () => {
|
|
|
|
|
let expPath = path.join(toolPath, 'bin');
|
|
|
|
|
|
|
|
|
|
expect(dlSpy).toHaveBeenCalled();
|
|
|
|
|
expect(exSpy).toHaveBeenCalled();
|
|
|
|
|
expect(extractTarSpy).toHaveBeenCalled();
|
|
|
|
|
expect(logSpy).toHaveBeenCalledWith(
|
|
|
|
|
'Attempting to resolve the latest version from the manifest...'
|
|
|
|
|
);
|
|
|
|
@ -722,7 +743,7 @@ describe('setup-go', () => {
|
|
|
|
|
|
|
|
|
|
dlSpy.mockImplementation(async () => '/some/temp/path');
|
|
|
|
|
let toolPath = path.normalize('/cache/go/1.13.7/x64');
|
|
|
|
|
exSpy.mockImplementation(async () => '/some/other/temp/path');
|
|
|
|
|
extractTarSpy.mockImplementation(async () => '/some/other/temp/path');
|
|
|
|
|
cacheSpy.mockImplementation(async () => toolPath);
|
|
|
|
|
|
|
|
|
|
await main.run();
|
|
|
|
@ -733,7 +754,7 @@ describe('setup-go', () => {
|
|
|
|
|
`Failed to resolve version ${versionSpec} from manifest`
|
|
|
|
|
);
|
|
|
|
|
expect(dlSpy).toHaveBeenCalled();
|
|
|
|
|
expect(exSpy).toHaveBeenCalled();
|
|
|
|
|
expect(extractTarSpy).toHaveBeenCalled();
|
|
|
|
|
expect(logSpy).toHaveBeenCalledWith(
|
|
|
|
|
'Attempting to resolve the latest version from the manifest...'
|
|
|
|
|
);
|
|
|
|
|