Default to os.arch when no arch provided

This commit is contained in:
panticmilos 2022-08-08 12:57:22 +02:00
parent 2f5755bd36
commit c5cf47b1d5
3 changed files with 23 additions and 23 deletions

View file

@ -132,7 +132,7 @@ describe('setup-go', () => {
it('can find 1.9.7 from manifest on osx', async () => { it('can find 1.9.7 from manifest on osx', async () => {
os.platform = 'darwin'; os.platform = 'darwin';
sysGetArchSpy.mockImplementationOnce(() => 'x64'); os.arch = 'x64';
let match = await im.getInfoFromManifest('1.9.7', true, 'mocktoken'); let match = await im.getInfoFromManifest('1.9.7', true, 'mocktoken');
expect(match).toBeDefined(); expect(match).toBeDefined();
@ -145,7 +145,7 @@ describe('setup-go', () => {
it('can find 1.9 from manifest on linux', async () => { it('can find 1.9 from manifest on linux', async () => {
os.platform = 'linux'; os.platform = 'linux';
sysGetArchSpy.mockImplementationOnce(() => 'x64'); os.arch = 'x64';
let match = await im.getInfoFromManifest('1.9.7', true, 'mocktoken'); let match = await im.getInfoFromManifest('1.9.7', true, 'mocktoken');
expect(match).toBeDefined(); expect(match).toBeDefined();
@ -158,7 +158,7 @@ describe('setup-go', () => {
it('can find 1.9 from manifest on windows', async () => { it('can find 1.9 from manifest on windows', async () => {
os.platform = 'win32'; os.platform = 'win32';
sysGetArchSpy.mockImplementationOnce(() => 'x64'); os.arch = 'x64';
let match = await im.getInfoFromManifest('1.9.7', true, 'mocktoken'); let match = await im.getInfoFromManifest('1.9.7', true, 'mocktoken');
expect(match).toBeDefined(); expect(match).toBeDefined();
@ -325,13 +325,13 @@ describe('setup-go', () => {
it('downloads a version not in the cache', async () => { it('downloads a version not in the cache', async () => {
os.platform = 'linux'; os.platform = 'linux';
os.arch = 'x64'; sysGetArchSpy.mockImplementationOnce(() => 'amd64');
inputs['go-version'] = '1.13.1'; inputs['go-version'] = '1.13.1';
findSpy.mockImplementation(() => ''); findSpy.mockImplementation(() => '');
dlSpy.mockImplementation(() => '/some/temp/path'); dlSpy.mockImplementation(() => '/some/temp/path');
let toolPath = path.normalize('/cache/go/1.13.0/x64'); let toolPath = path.normalize('/cache/go/1.13.0/amd64');
extractTarSpy.mockImplementation(() => '/some/other/temp/path'); extractTarSpy.mockImplementation(() => '/some/other/temp/path');
cacheSpy.mockImplementation(() => toolPath); cacheSpy.mockImplementation(() => toolPath);
await main.run(); await main.run();
@ -345,7 +345,7 @@ describe('setup-go', () => {
it('downloads a version not in the cache (windows)', async () => { it('downloads a version not in the cache (windows)', async () => {
os.platform = 'win32'; os.platform = 'win32';
os.arch = 'x64'; sysGetArchSpy.mockImplementationOnce(() => 'amd64');
inputs['go-version'] = '1.13.1'; inputs['go-version'] = '1.13.1';
process.env['RUNNER_TEMP'] = 'C:\\temp\\'; process.env['RUNNER_TEMP'] = 'C:\\temp\\';
@ -354,7 +354,7 @@ describe('setup-go', () => {
dlSpy.mockImplementation(() => 'C:\\temp\\some\\path'); dlSpy.mockImplementation(() => 'C:\\temp\\some\\path');
extractZipSpy.mockImplementation(() => 'C:\\temp\\some\\other\\path'); extractZipSpy.mockImplementation(() => 'C:\\temp\\some\\other\\path');
let toolPath = path.normalize('C:\\cache\\go\\1.13.0\\x64'); let toolPath = path.normalize('C:\\cache\\go\\1.13.0\\amd64');
cacheSpy.mockImplementation(() => toolPath); cacheSpy.mockImplementation(() => toolPath);
await main.run(); await main.run();
@ -370,7 +370,7 @@ describe('setup-go', () => {
it('does not find a version that does not exist', async () => { it('does not find a version that does not exist', async () => {
os.platform = 'linux'; os.platform = 'linux';
sysGetArchSpy.mockImplementationOnce(() => 'x64'); os.arch = 'x64';
inputs['go-version'] = '9.99.9'; inputs['go-version'] = '9.99.9';
@ -384,7 +384,7 @@ describe('setup-go', () => {
it('downloads a version from a manifest match', async () => { it('downloads a version from a manifest match', async () => {
os.platform = 'linux'; os.platform = 'linux';
sysGetArchSpy.mockImplementationOnce(() => 'x64'); os.arch = 'x64';
let versionSpec = '1.12.16'; let versionSpec = '1.12.16';
@ -421,7 +421,7 @@ describe('setup-go', () => {
it('downloads a major and minor from a manifest match', async () => { it('downloads a major and minor from a manifest match', async () => {
os.platform = 'linux'; os.platform = 'linux';
sysGetArchSpy.mockImplementationOnce(() => 'x64'); os.arch = 'x64';
let versionSpec = '1.12'; let versionSpec = '1.12';
@ -458,7 +458,7 @@ describe('setup-go', () => {
it('falls back to a version from go dist', async () => { it('falls back to a version from go dist', async () => {
os.platform = 'linux'; os.platform = 'linux';
os.arch = 'x64'; sysGetArchSpy.mockImplementationOnce(() => 'amd64');
let versionSpec = '1.12.14'; let versionSpec = '1.12.14';
@ -466,13 +466,13 @@ describe('setup-go', () => {
inputs['token'] = 'faketoken'; inputs['token'] = 'faketoken';
let expectedUrl = let expectedUrl =
'https://github.com/actions/go-versions/releases/download/1.12.14-20200616.18/go-1.12.14-linux-x64.tar.gz'; 'https://github.com/actions/go-versions/releases/download/1.12.14-20200616.18/go-1.12.14-linux-amd64.tar.gz';
// ... but not in the local cache // ... but not in the local cache
findSpy.mockImplementation(() => ''); findSpy.mockImplementation(() => '');
dlSpy.mockImplementation(async () => '/some/temp/path'); dlSpy.mockImplementation(async () => '/some/temp/path');
let toolPath = path.normalize('/cache/go/1.12.14/x64'); let toolPath = path.normalize('/cache/go/1.12.14/amd64');
extractTarSpy.mockImplementation(async () => '/some/other/temp/path'); extractTarSpy.mockImplementation(async () => '/some/other/temp/path');
cacheSpy.mockImplementation(async () => toolPath); cacheSpy.mockImplementation(async () => toolPath);
@ -496,7 +496,7 @@ describe('setup-go', () => {
it('reports a failed download', async () => { it('reports a failed download', async () => {
let errMsg = 'unhandled download message'; let errMsg = 'unhandled download message';
os.platform = 'linux'; os.platform = 'linux';
os.arch = 'x64'; sysGetArchSpy.mockImplementationOnce(() => 'amd64');
inputs['go-version'] = '1.13.1'; inputs['go-version'] = '1.13.1';
@ -697,7 +697,7 @@ describe('setup-go', () => {
it('check latest version and install it from manifest', async () => { it('check latest version and install it from manifest', async () => {
os.platform = 'linux'; os.platform = 'linux';
sysGetArchSpy.mockImplementationOnce(() => 'x64'); os.arch = 'x64';
const versionSpec = '1.17'; const versionSpec = '1.17';
const patchVersion = '1.17.6'; const patchVersion = '1.17.6';
@ -735,7 +735,7 @@ describe('setup-go', () => {
it('fallback to dist if version is not found in manifest', async () => { it('fallback to dist if version is not found in manifest', async () => {
os.platform = 'linux'; os.platform = 'linux';
os.arch = 'x64'; sysGetArchSpy.mockImplementationOnce(() => 'amd64');
let versionSpec = '1.13'; let versionSpec = '1.13';
@ -748,7 +748,7 @@ describe('setup-go', () => {
findSpy.mockImplementation(() => ''); findSpy.mockImplementation(() => '');
dlSpy.mockImplementation(async () => '/some/temp/path'); dlSpy.mockImplementation(async () => '/some/temp/path');
let toolPath = path.normalize('/cache/go/1.13.7/x64'); let toolPath = path.normalize('/cache/go/1.13.7/amd64');
extractTarSpy.mockImplementation(async () => '/some/other/temp/path'); extractTarSpy.mockImplementation(async () => '/some/other/temp/path');
cacheSpy.mockImplementation(async () => toolPath); cacheSpy.mockImplementation(async () => toolPath);
@ -772,7 +772,7 @@ describe('setup-go', () => {
it('fallback to dist if manifest is not available', async () => { it('fallback to dist if manifest is not available', async () => {
os.platform = 'linux'; os.platform = 'linux';
os.arch = 'x64'; sysGetArchSpy.mockImplementationOnce(() => 'amd64');
let versionSpec = '1.13'; let versionSpec = '1.13';
@ -790,7 +790,7 @@ describe('setup-go', () => {
}); });
dlSpy.mockImplementation(async () => '/some/temp/path'); dlSpy.mockImplementation(async () => '/some/temp/path');
let toolPath = path.normalize('/cache/go/1.13.7/x64'); let toolPath = path.normalize('/cache/go/1.13.7/amd64');
extractTarSpy.mockImplementation(async () => '/some/other/temp/path'); extractTarSpy.mockImplementation(async () => '/some/other/temp/path');
cacheSpy.mockImplementation(async () => toolPath); cacheSpy.mockImplementation(async () => toolPath);

4
dist/setup/index.js vendored
View file

@ -62858,7 +62858,7 @@ const httpm = __importStar(__nccwpck_require__(6255));
const sys = __importStar(__nccwpck_require__(4300)); const sys = __importStar(__nccwpck_require__(4300));
const fs_1 = __importDefault(__nccwpck_require__(7147)); const fs_1 = __importDefault(__nccwpck_require__(7147));
const os_1 = __importDefault(__nccwpck_require__(2037)); const os_1 = __importDefault(__nccwpck_require__(2037));
function getGo(versionSpec, checkLatest, auth, arch = sys.getArch()) { function getGo(versionSpec, checkLatest, auth, arch = os_1.default.arch()) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
let osPlat = os_1.default.platform(); let osPlat = os_1.default.platform();
if (checkLatest) { if (checkLatest) {
@ -62972,7 +62972,7 @@ function extractGoArchive(archivePath) {
}); });
} }
exports.extractGoArchive = extractGoArchive; exports.extractGoArchive = extractGoArchive;
function getInfoFromManifest(versionSpec, stable, auth, arch = sys.getArch()) { function getInfoFromManifest(versionSpec, stable, auth, arch = os_1.default.arch()) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
let info = null; let info = null;
const releases = yield tc.getManifestFromRepo('actions', 'go-versions', auth, 'main'); const releases = yield tc.getManifestFromRepo('actions', 'go-versions', auth, 'main');

View file

@ -33,7 +33,7 @@ export async function getGo(
versionSpec: string, versionSpec: string,
checkLatest: boolean, checkLatest: boolean,
auth: string | undefined, auth: string | undefined,
arch = sys.getArch() arch = os.arch()
) { ) {
let osPlat: string = os.platform(); let osPlat: string = os.platform();
@ -178,7 +178,7 @@ export async function getInfoFromManifest(
versionSpec: string, versionSpec: string,
stable: boolean, stable: boolean,
auth: string | undefined, auth: string | undefined,
arch = sys.getArch() arch = os.arch()
): Promise<IGoVersionInfo | null> { ): Promise<IGoVersionInfo | null> {
let info: IGoVersionInfo | null = null; let info: IGoVersionInfo | null = null;
const releases = await tc.getManifestFromRepo( const releases = await tc.getManifestFromRepo(