Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V dmshib/update for release comments #4

Open
wants to merge 4 commits into
base: v-dmshib/update-for-release
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
4 changes: 2 additions & 2 deletions __tests__/setup-go.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => <im.IGoVersion[] | null>goJsonData);
cnSpy.mockImplementation(line => {
Expand All @@ -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');
});
});

Expand Down
40 changes: 21 additions & 19 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
//
Expand All @@ -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
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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 = {};
Expand Down
31 changes: 19 additions & 12 deletions src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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'
);
}
Expand All @@ -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');
}

//
Expand All @@ -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}`);
Expand All @@ -101,17 +101,24 @@ async function installGoVersion(
info: IGoVersionInfo,
auth: string | undefined
): Promise<string> {
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<string> {
Expand All @@ -134,7 +141,7 @@ export async function getInfoFromManifest(
): Promise<IGoVersionInfo | null> {
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) {
Expand Down
15 changes: 6 additions & 9 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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);
Expand Down