diff --git a/.github/workflows/versions.yml b/.github/workflows/versions.yml index 14f72b16d..b5633adb5 100644 --- a/.github/workflows/versions.yml +++ b/.github/workflows/versions.yml @@ -21,7 +21,7 @@ jobs: os: [macos-latest, windows-latest, ubuntu-latest] go: [1.12, 1.13, 1.14] steps: - - name: Checkout + - name: Checkout uses: actions/checkout@v2 - name: setup-go ${{ matrix.go }} diff --git a/__tests__/setup-go.test.ts b/__tests__/setup-go.test.ts index 4817e7b1e..b5ac05e38 100644 --- a/__tests__/setup-go.test.ts +++ b/__tests__/setup-go.test.ts @@ -67,7 +67,7 @@ describe('setup-go', () => { // writes cnSpy = jest.spyOn(process.stdout, 'write'); - logSpy = jest.spyOn(console, 'log'); + logSpy = jest.spyOn(core, 'info'); dbgSpy = jest.spyOn(core, 'debug'); getSpy.mockImplementation(() => goJsonData); cnSpy.mockImplementation(line => { @@ -80,7 +80,7 @@ describe('setup-go', () => { }); dbgSpy.mockImplementation(msg => { // uncomment to see debug output - // process.stderr.write(msg + '\n'); + process.stderr.write(msg + '\n'); }); }); diff --git a/dist/index.js b/dist/index.js index 65c0f7729..1dfb2ff37 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1436,28 +1436,27 @@ function run() { // stable will be true unless false is the exact input // since getting unstable versions should be explicit let stable = (core.getInput('stable') || 'true').toUpperCase() === 'TRUE'; - console.log(`Setup go ${stable ? 'stable' : ''} version spec ${versionSpec}`); + core.info(`Setup go ${stable ? 'stable' : ''} version spec ${versionSpec}`); if (versionSpec) { let token = core.getInput('token'); let auth = !token || isGhes() ? undefined : `token ${token}`; const installDir = yield installer.getGo(versionSpec, stable, auth); core.exportVariable('GOROOT', installDir); core.addPath(path_1.default.join(installDir, 'bin')); - console.log('Added go to the path'); + core.info('Added go to the path'); let added = addBinToPath(); - core.debug(`add bin ${added}`); - console.log('Done'); + core.info(`Successfully setup go version ${versionSpec}`); } // add problem matchers const matchersPath = path_1.default.join(__dirname, '..', 'matchers.json'); - console.log(`##[add-matcher]${matchersPath}`); + core.info(`##[add-matcher]${matchersPath}`); // output the version actually being used let goPath = yield io.which('go'); let goVersion = (child_process_1.default.execSync(`${goPath} version`) || '').toString(); - console.log(goVersion); + core.info(goVersion); core.startGroup('go env'); let goEnv = (child_process_1.default.execSync(`${goPath} env`) || '').toString(); - console.log(goEnv); + core.info(goEnv); core.endGroup(); } catch (error) { @@ -4952,10 +4951,10 @@ function getGo(versionSpec, stable, auth) { toolPath = tc.find('go', versionSpec); // If not found in cache, download if (toolPath) { - console.log(`Found in cache @ ${toolPath}`); + core.info(`Found in cache @ ${toolPath}`); return toolPath; } - console.log(`Attempting to download ${versionSpec}...`); + core.info(`Attempting to download ${versionSpec}...`); let downloadPath = ''; let info = null; // @@ -4967,19 +4966,19 @@ function getGo(versionSpec, stable, auth) { downloadPath = yield installGoVersion(info, auth); } else { - console.log('Not found in manifest. Falling back to download directly from Go'); + core.info('Not found in manifest. Falling back to download directly from Go'); } } catch (err) { if (err instanceof tc.HTTPError && (err.httpStatusCode === 403 || err.httpStatusCode === 429)) { - console.log(`Received HTTP status code ${err.httpStatusCode}. This usually indicates the rate limit has been exceeded`); + core.info(`Received HTTP status code ${err.httpStatusCode}. This usually indicates the rate limit has been exceeded`); } else { - console.log(err.message); + core.info(err.message); } core.debug(err.stack); - console.log('Falling back to download directly from Go'); + core.info('Falling back to download directly from Go'); } // // Download from storage.googleapis.com @@ -4990,7 +4989,7 @@ function getGo(versionSpec, stable, auth) { throw new Error(`Unable to find Go version '${versionSpec}' for platform ${osPlat} and architecture ${osArch}.`); } try { - console.log("Install from dist"); + core.info('Install from dist'); downloadPath = yield installGoVersion(info, undefined); } catch (err) { @@ -5003,15 +5002,18 @@ function getGo(versionSpec, stable, auth) { exports.getGo = getGo; function installGoVersion(info, auth) { return __awaiter(this, void 0, void 0, function* () { - console.log(`Acquiring ${info.resolvedVersion} from ${info.downloadUrl}`); + core.info(`Acquiring ${info.resolvedVersion} from ${info.downloadUrl}`); const downloadPath = yield tc.downloadTool(info.downloadUrl, undefined, auth); - console.log('Extracting Go...'); + core.info('Extracting Go...'); let extPath = yield extractGoArchive(downloadPath); + core.info(`Successfully extracted go to ${extPath}`); if (info.type === 'dist') { extPath = path.join(extPath, 'go'); } - console.log('Adding to the cache ...'); - return yield tc.cacheDir(extPath, 'go', makeSemver(info.resolvedVersion)); + core.info('Adding to the cache ...'); + const cachedDir = yield tc.cacheDir(extPath, 'go', makeSemver(info.resolvedVersion)); + core.info(`Successfully cached go to ${cachedDir}`); + return cachedDir; }); } function extractGoArchive(archivePath) { @@ -5032,7 +5034,7 @@ function getInfoFromManifest(versionSpec, stable, auth) { return __awaiter(this, void 0, void 0, function* () { let info = null; const releases = yield tc.getManifestFromRepo('actions', 'go-versions', auth); - console.log(`matching ${versionSpec}...`); + core.info(`matching ${versionSpec}...`); const rel = yield tc.findFromManifest(versionSpec, stable, releases); if (rel && rel.files.length > 0) { info = {}; diff --git a/src/installer.ts b/src/installer.ts index b0dcd3a0a..08758a48c 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -41,10 +41,10 @@ export async function getGo( toolPath = tc.find('go', versionSpec); // If not found in cache, download if (toolPath) { - console.log(`Found in cache @ ${toolPath}`); + core.info(`Found in cache @ ${toolPath}`); return toolPath; } - console.log(`Attempting to download ${versionSpec}...`); + core.info(`Attempting to download ${versionSpec}...`); let downloadPath = ''; let info: IGoVersionInfo | null = null; @@ -56,7 +56,7 @@ export async function getGo( if (info) { downloadPath = await installGoVersion(info, auth); } else { - console.log( + core.info( 'Not found in manifest. Falling back to download directly from Go' ); } @@ -65,14 +65,14 @@ export async function getGo( err instanceof tc.HTTPError && (err.httpStatusCode === 403 || err.httpStatusCode === 429) ) { - console.log( + core.info( `Received HTTP status code ${err.httpStatusCode}. This usually indicates the rate limit has been exceeded` ); } else { - console.log(err.message); + core.info(err.message); } core.debug(err.stack); - console.log('Falling back to download directly from Go'); + core.info('Falling back to download directly from Go'); } // @@ -87,7 +87,7 @@ export async function getGo( } try { - console.log('Install from dist'); + core.info('Install from dist'); downloadPath = await installGoVersion(info, undefined); } catch (err) { throw new Error(`Failed to download version ${versionSpec}: ${err}`); @@ -101,17 +101,24 @@ async function installGoVersion( info: IGoVersionInfo, auth: string | undefined ): Promise { - console.log(`Acquiring ${info.resolvedVersion} from ${info.downloadUrl}`); + core.info(`Acquiring ${info.resolvedVersion} from ${info.downloadUrl}`); const downloadPath = await tc.downloadTool(info.downloadUrl, undefined, auth); - console.log('Extracting Go...'); + core.info('Extracting Go...'); let extPath = await extractGoArchive(downloadPath); + core.info(`Successfully extracted go to ${extPath}`); if (info.type === 'dist') { extPath = path.join(extPath, 'go'); } - console.log('Adding to the cache ...'); - return await tc.cacheDir(extPath, 'go', makeSemver(info.resolvedVersion)); + core.info('Adding to the cache ...'); + const cachedDir = await tc.cacheDir( + extPath, + 'go', + makeSemver(info.resolvedVersion) + ); + core.info(`Successfully cached go to ${cachedDir}`); + return cachedDir; } export async function extractGoArchive(archivePath: string): Promise { @@ -134,7 +141,7 @@ export async function getInfoFromManifest( ): Promise { let info: IGoVersionInfo | null = null; const releases = await tc.getManifestFromRepo('actions', 'go-versions', auth); - console.log(`matching ${versionSpec}...`); + core.info(`matching ${versionSpec}...`); const rel = await tc.findFromManifest(versionSpec, stable, releases); if (rel && rel.files.length > 0) { diff --git a/src/main.ts b/src/main.ts index 65496c35f..f68b77ebf 100644 --- a/src/main.ts +++ b/src/main.ts @@ -18,9 +18,7 @@ export async function run() { // since getting unstable versions should be explicit let stable = (core.getInput('stable') || 'true').toUpperCase() === 'TRUE'; - console.log( - `Setup go ${stable ? 'stable' : ''} version spec ${versionSpec}` - ); + core.info(`Setup go ${stable ? 'stable' : ''} version spec ${versionSpec}`); if (versionSpec) { let token = core.getInput('token'); @@ -30,25 +28,24 @@ export async function run() { core.exportVariable('GOROOT', installDir); core.addPath(path.join(installDir, 'bin')); - console.log('Added go to the path'); + core.info('Added go to the path'); let added = addBinToPath(); - core.debug(`add bin ${added}`); - console.log('Done'); + core.info(`Successfully setup go version ${versionSpec}`); } // add problem matchers const matchersPath = path.join(__dirname, '..', 'matchers.json'); - console.log(`##[add-matcher]${matchersPath}`); + core.info(`##[add-matcher]${matchersPath}`); // output the version actually being used let goPath = await io.which('go'); let goVersion = (cp.execSync(`${goPath} version`) || '').toString(); - console.log(goVersion); + core.info(goVersion); core.startGroup('go env'); let goEnv = (cp.execSync(`${goPath} env`) || '').toString(); - console.log(goEnv); + core.info(goEnv); core.endGroup(); } catch (error) { core.setFailed(error.message);