Move condition to the installer

pull/299/head
panticmilos 2 years ago
parent 18c62c8dd3
commit 17fabf6bf1

@ -702,7 +702,7 @@ describe('setup-go', () => {
findSpy.mockImplementation(() => '');
dlSpy.mockImplementation(async () => '/some/temp/path');
const toolPath = path.normalize('/cache/go/1.17.5/x64');
const toolPath = path.normalize('/cache/go/1.17.6/x64');
extractTarSpy.mockImplementation(async () => '/some/other/temp/path');
cacheSpy.mockImplementation(async () => toolPath);
@ -722,7 +722,7 @@ describe('setup-go', () => {
expect(logSpy).toHaveBeenCalledWith('Adding to the cache ...');
expect(logSpy).toHaveBeenCalledWith('Added go to the path');
expect(logSpy).toHaveBeenCalledWith(
`Successfully set up Go version ${versionSpec}`
`Successfully set up Go version ${patchVersion}`
);
});

@ -63237,6 +63237,10 @@ function getGo(versionSpec, checkLatest, auth, arch = os_1.default.arch(), manif
core.info(`Failed to resolve version ${versionSpec} from manifest`);
}
}
if (versionSpec === utils_1.StableReleaseAlias.Stable ||
versionSpec === utils_1.StableReleaseAlias.OldStable) {
versionSpec = yield resolveStableVersionInput(versionSpec, auth, arch, manifest);
}
// check cache
let toolPath;
toolPath = tc.find('go', versionSpec, arch);
@ -63559,11 +63563,13 @@ function run() {
let auth = !token ? undefined : `token ${token}`;
const manifest = yield installer.getManifest(auth);
const checkLatest = core.getBooleanInput('check-latest');
if (versionSpec === utils_1.StableReleaseAlias.Stable ||
versionSpec === utils_1.StableReleaseAlias.OldStable) {
versionSpec = yield installer.resolveStableVersionInput(versionSpec, auth, arch, manifest);
}
const installDir = yield installer.getGo(versionSpec, checkLatest, auth, arch, manifest);
if (utils_1.IS_WINDOWS) {
versionSpec = installDir.split('\\').reverse()[1];
}
else {
versionSpec = installDir.split('/').reverse()[1];
}
core.addPath(path_1.default.join(installDir, 'bin'));
core.info('Added go to the path');
const version = installer.makeSemver(versionSpec);
@ -63727,12 +63733,13 @@ exports.getArch = getArch;
"use strict";
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.StableReleaseAlias = void 0;
exports.IS_WINDOWS = exports.StableReleaseAlias = void 0;
var StableReleaseAlias;
(function (StableReleaseAlias) {
StableReleaseAlias["Stable"] = "stable";
StableReleaseAlias["OldStable"] = "oldstable";
})(StableReleaseAlias = exports.StableReleaseAlias || (exports.StableReleaseAlias = {}));
exports.IS_WINDOWS = process.platform === 'win32';
/***/ }),

@ -5,7 +5,7 @@ import * as semver from 'semver';
import * as httpm from '@actions/http-client';
import * as sys from './system';
import fs from 'fs';
import os, {arch} from 'os';
import os from 'os';
import {StableReleaseAlias} from './utils';
type InstallationType = 'dist' | 'manifest';
@ -56,6 +56,18 @@ export async function getGo(
}
}
if (
versionSpec === StableReleaseAlias.Stable ||
versionSpec === StableReleaseAlias.OldStable
) {
versionSpec = await resolveStableVersionInput(
versionSpec,
auth,
arch,
manifest
);
}
// check cache
let toolPath: string;
toolPath = tc.find('go', versionSpec, arch);

@ -8,7 +8,7 @@ import {isCacheFeatureAvailable} from './cache-utils';
import cp from 'child_process';
import fs from 'fs';
import os from 'os';
import {StableReleaseAlias} from './utils';
import {IS_WINDOWS} from './utils';
export async function run() {
try {
@ -35,18 +35,6 @@ export async function run() {
const checkLatest = core.getBooleanInput('check-latest');
if (
versionSpec === StableReleaseAlias.Stable ||
versionSpec === StableReleaseAlias.OldStable
) {
versionSpec = await installer.resolveStableVersionInput(
versionSpec,
auth,
arch,
manifest
);
}
const installDir = await installer.getGo(
versionSpec,
checkLatest,
@ -55,6 +43,12 @@ export async function run() {
manifest
);
if (IS_WINDOWS) {
versionSpec = installDir.split('\\').reverse()[1];
} else {
versionSpec = installDir.split('/').reverse()[1];
}
core.addPath(path.join(installDir, 'bin'));
core.info('Added go to the path');

@ -2,3 +2,5 @@ export enum StableReleaseAlias {
Stable = 'stable',
OldStable = 'oldstable'
}
export const IS_WINDOWS = process.platform === 'win32';

Loading…
Cancel
Save