Solve conflicts

This commit is contained in:
CrazyMax 2020-02-11 16:33:09 +01:00
parent c837c2218b
commit 7fb5bea2dd
No known key found for this signature in database
GPG key ID: 3248E46B6BB8C7F7
3 changed files with 281 additions and 222 deletions

474
dist/index.js vendored
View file

@ -1246,10 +1246,10 @@ exports.debug = debug; // for test
/***/ (function(__unusedmodule, exports, __webpack_require__) { /***/ (function(__unusedmodule, exports, __webpack_require__) {
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const main_1 = __webpack_require__(198); const main_1 = __webpack_require__(198);
main_1.run(); main_1.run();
/***/ }), /***/ }),
@ -1258,65 +1258,76 @@ main_1.run();
/***/ (function(__unusedmodule, exports, __webpack_require__) { /***/ (function(__unusedmodule, exports, __webpack_require__) {
"use strict"; "use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) { return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next()); step((generator = generator.apply(thisArg, _arguments || [])).next());
}); });
}; };
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod; if (mod && mod.__esModule) return mod;
var result = {}; var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod; result["default"] = mod;
return result; return result;
}; };
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const core = __importStar(__webpack_require__(470)); const core = __importStar(__webpack_require__(470));
const tc = __importStar(__webpack_require__(533)); const tc = __importStar(__webpack_require__(533));
const installer = __importStar(__webpack_require__(749)); const installer = __importStar(__webpack_require__(749));
const path = __importStar(__webpack_require__(622)); const path = __importStar(__webpack_require__(622));
function run() { const system = __importStar(__webpack_require__(737));
return __awaiter(this, void 0, void 0, function* () { function run() {
try { return __awaiter(this, void 0, void 0, function* () {
// try {
// versionSpec is optional. If supplied, install / use from the tool cache //
// If not supplied then problem matchers will still be setup. Useful for self-hosted. // versionSpec is optional. If supplied, install / use from the tool cache
// // If not supplied then problem matchers will still be setup. Useful for self-hosted.
let versionSpec = core.getInput('go-version'); //
// stable will be true unless false is the exact input let versionSpec = core.getInput('go-version');
// since getting unstable versions should be explicit // stable will be true unless false is the exact input
let stable = (core.getInput('stable') || 'true').toUpperCase() === 'TRUE'; // since getting unstable versions should be explicit
console.log(`Setup go ${stable ? 'stable' : ''} version spec ${versionSpec}`); let stable = (core.getInput('stable') || 'true').toUpperCase() === 'TRUE';
if (versionSpec) { console.log(`Setup go ${stable ? 'stable' : ''} version spec ${versionSpec}`);
let installDir = tc.find('go', versionSpec); if (versionSpec) {
if (!installDir) { let installDir = tc.find('go', versionSpec);
console.log(`A version satisfying ${versionSpec} not found locally, attempting to download ...`); if (!installDir) {
installDir = yield installer.downloadGo(versionSpec, stable); console.log(`A version satisfying ${versionSpec} not found locally, attempting to download ...`);
console.log('Installed'); installDir = yield installer.downloadGo(versionSpec, stable);
} console.log('Installed');
if (installDir) { }
core.exportVariable('GOROOT', installDir); if (installDir) {
core.addPath(path.join(installDir, 'bin')); core.exportVariable('GOROOT', installDir);
console.log('Added go to the path'); core.addPath(path.join(installDir, 'bin'));
} console.log('Added go to the path');
else { // set GOPATH and GOBIN as user value
throw new Error(`Could not find a version that satisfied version spec: ${versionSpec}`); const goPath = system.getGoPath();
} if (goPath) {
} core.exportVariable('GOPATH', goPath);
// add problem matchers core.addPath(path.join(goPath, 'bin'));
const matchersPath = path.join(__dirname, '..', 'matchers.json'); }
console.log(`##[add-matcher]${matchersPath}`); const goBin = process.env['GOBIN'] || '';
} if (goBin) {
catch (error) { core.exportVariable('GOBIN', goBin);
core.setFailed(error.message); }
} }
}); else {
} throw new Error(`Could not find a version that satisfied version spec: ${versionSpec}`);
exports.run = run; }
}
// add problem matchers
const matchersPath = path.join(__dirname, '..', 'matchers.json');
console.log(`##[add-matcher]${matchersPath}`);
}
catch (error) {
core.setFailed(error.message);
}
});
}
exports.run = run;
/***/ }), /***/ }),
@ -4509,40 +4520,61 @@ module.exports = bytesToUuid;
/***/ (function(__unusedmodule, exports, __webpack_require__) { /***/ (function(__unusedmodule, exports, __webpack_require__) {
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true }); var __importStar = (this && this.__importStar) || function (mod) {
let os = __webpack_require__(87); if (mod && mod.__esModule) return mod;
function getPlatform() { var result = {};
// darwin and linux match already if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
// freebsd not supported yet but future proofed. result["default"] = mod;
// 'aix', 'darwin', 'freebsd', 'linux', 'openbsd', 'sunos', and 'win32' return result;
let plat = os.platform(); };
// wants 'darwin', 'freebsd', 'linux', 'windows' Object.defineProperty(exports, "__esModule", { value: true });
if (plat === 'win32') { const os = __importStar(__webpack_require__(87));
plat = 'windows'; const path = __importStar(__webpack_require__(622));
} function getPlatform() {
return plat; // darwin and linux match already
} // freebsd not supported yet but future proofed.
exports.getPlatform = getPlatform; // 'aix', 'darwin', 'freebsd', 'linux', 'openbsd', 'sunos', and 'win32'
function getArch() { let plat = os.platform();
// 'arm', 'arm64', 'ia32', 'mips', 'mipsel', 'ppc', 'ppc64', 's390', 's390x', 'x32', and 'x64'. // wants 'darwin', 'freebsd', 'linux', 'windows'
let arch = os.arch(); if (plat === 'win32') {
// wants amd64, 386, arm64, armv61, ppc641e, s390x plat = 'windows';
// currently not supported by runner but future proofed mapping }
switch (arch) { return plat;
case 'x64': }
arch = 'amd64'; exports.getPlatform = getPlatform;
break; function getArch() {
// case 'ppc': // 'arm', 'arm64', 'ia32', 'mips', 'mipsel', 'ppc', 'ppc64', 's390', 's390x', 'x32', and 'x64'.
// arch = 'ppc64'; let arch = os.arch();
// break; // wants amd64, 386, arm64, armv61, ppc641e, s390x
case 'x32': // currently not supported by runner but future proofed mapping
arch = '386'; switch (arch) {
break; case 'x64':
} arch = 'amd64';
return arch; break;
} // case 'ppc':
exports.getArch = getArch; // arch = 'ppc64';
// break;
case 'x32':
arch = '386';
break;
}
return arch;
}
exports.getArch = getArch;
// Get GOPATH as user value or as defined by https://golang.org/doc/code.html#GOPATH
function getGoPath() {
const home = process.env['HOME'] || '';
const goPath = process.env['GOPATH'] || '';
if (goPath) {
return goPath;
}
else if (home) {
return path.join(home, 'go');
}
return '';
}
exports.getGoPath = getGoPath;
/***/ }), /***/ }),
@ -4558,130 +4590,130 @@ module.exports = require("fs");
/***/ (function(module, exports, __webpack_require__) { /***/ (function(module, exports, __webpack_require__) {
"use strict"; "use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) { return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next()); step((generator = generator.apply(thisArg, _arguments || [])).next());
}); });
}; };
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod; if (mod && mod.__esModule) return mod;
var result = {}; var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod; result["default"] = mod;
return result; return result;
}; };
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const tc = __importStar(__webpack_require__(533)); const tc = __importStar(__webpack_require__(533));
const path = __importStar(__webpack_require__(622)); const path = __importStar(__webpack_require__(622));
const semver = __importStar(__webpack_require__(280)); const semver = __importStar(__webpack_require__(280));
const httpm = __importStar(__webpack_require__(539)); const httpm = __importStar(__webpack_require__(539));
const sys = __importStar(__webpack_require__(737)); const sys = __importStar(__webpack_require__(737));
const core_1 = __webpack_require__(470); const core_1 = __webpack_require__(470);
function downloadGo(versionSpec, stable) { function downloadGo(versionSpec, stable) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
let toolPath; let toolPath;
try { try {
let match = yield findMatch(versionSpec, stable); let match = yield findMatch(versionSpec, stable);
if (match) { if (match) {
// download // download
core_1.debug(`match ${match.version}`); core_1.debug(`match ${match.version}`);
let downloadUrl = `https://storage.googleapis.com/golang/${match.files[0].filename}`; let downloadUrl = `https://storage.googleapis.com/golang/${match.files[0].filename}`;
console.log(`Downloading from ${downloadUrl}`); console.log(`Downloading from ${downloadUrl}`);
let downloadPath = yield tc.downloadTool(downloadUrl); let downloadPath = yield tc.downloadTool(downloadUrl);
core_1.debug(`downloaded to ${downloadPath}`); core_1.debug(`downloaded to ${downloadPath}`);
// extract // extract
console.log('Extracting ...'); console.log('Extracting ...');
let extPath = sys.getPlatform() == 'windows' let extPath = sys.getPlatform() == 'windows'
? yield tc.extractZip(downloadPath) ? yield tc.extractZip(downloadPath)
: yield tc.extractTar(downloadPath); : yield tc.extractTar(downloadPath);
core_1.debug(`extracted to ${extPath}`); core_1.debug(`extracted to ${extPath}`);
// extracts with a root folder that matches the fileName downloaded // extracts with a root folder that matches the fileName downloaded
const toolRoot = path.join(extPath, 'go'); const toolRoot = path.join(extPath, 'go');
toolPath = yield tc.cacheDir(toolRoot, 'go', versionSpec); toolPath = yield tc.cacheDir(toolRoot, 'go', versionSpec);
} }
} }
catch (error) { catch (error) {
throw new Error(`Failed to download version ${versionSpec}: ${error}`); throw new Error(`Failed to download version ${versionSpec}: ${error}`);
} }
return toolPath; return toolPath;
}); });
} }
exports.downloadGo = downloadGo; exports.downloadGo = downloadGo;
function findMatch(versionSpec, stable) { function findMatch(versionSpec, stable) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
let archFilter = sys.getArch(); let archFilter = sys.getArch();
let platFilter = sys.getPlatform(); let platFilter = sys.getPlatform();
let result; let result;
let match; let match;
const dlUrl = 'https://golang.org/dl/?mode=json&include=all'; const dlUrl = 'https://golang.org/dl/?mode=json&include=all';
let candidates = yield module.exports.getVersions(dlUrl); let candidates = yield module.exports.getVersions(dlUrl);
if (!candidates) { if (!candidates) {
throw new Error(`golang download url did not return results`); throw new Error(`golang download url did not return results`);
} }
let goFile; let goFile;
for (let i = 0; i < candidates.length; i++) { for (let i = 0; i < candidates.length; i++) {
let candidate = candidates[i]; let candidate = candidates[i];
let version = makeSemver(candidate.version); let version = makeSemver(candidate.version);
// 1.13.0 is advertised as 1.13 preventing being able to match exactly 1.13.0 // 1.13.0 is advertised as 1.13 preventing being able to match exactly 1.13.0
// since a semver of 1.13 would match latest 1.13 // since a semver of 1.13 would match latest 1.13
let parts = version.split('.'); let parts = version.split('.');
if (parts.length == 2) { if (parts.length == 2) {
version = version + '.0'; version = version + '.0';
} }
core_1.debug(`check ${version} satisfies ${versionSpec}`); core_1.debug(`check ${version} satisfies ${versionSpec}`);
if (semver.satisfies(version, versionSpec) && if (semver.satisfies(version, versionSpec) &&
(!stable || candidate.stable === stable)) { (!stable || candidate.stable === stable)) {
goFile = candidate.files.find(file => { goFile = candidate.files.find(file => {
core_1.debug(`${file.arch}===${archFilter} && ${file.os}===${platFilter}`); core_1.debug(`${file.arch}===${archFilter} && ${file.os}===${platFilter}`);
return file.arch === archFilter && file.os === platFilter; return file.arch === archFilter && file.os === platFilter;
}); });
if (goFile) { if (goFile) {
core_1.debug(`matched ${candidate.version}`); core_1.debug(`matched ${candidate.version}`);
match = candidate; match = candidate;
break; break;
} }
} }
} }
if (match && goFile) { if (match && goFile) {
// clone since we're mutating the file list to be only the file that matches // clone since we're mutating the file list to be only the file that matches
result = Object.assign({}, match); result = Object.assign({}, match);
result.files = [goFile]; result.files = [goFile];
} }
return result; return result;
}); });
} }
exports.findMatch = findMatch; exports.findMatch = findMatch;
function getVersions(dlUrl) { function getVersions(dlUrl) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
// this returns versions descending so latest is first // this returns versions descending so latest is first
let http = new httpm.HttpClient('setup-go'); let http = new httpm.HttpClient('setup-go');
return (yield http.getJson(dlUrl)).result; return (yield http.getJson(dlUrl)).result;
}); });
} }
exports.getVersions = getVersions; exports.getVersions = getVersions;
// //
// Convert the go version syntax into semver for semver matching // Convert the go version syntax into semver for semver matching
// 1.13.1 => 1.13.1 // 1.13.1 => 1.13.1
// 1.13 => 1.13.0 // 1.13 => 1.13.0
// 1.10beta1 => 1.10.0-beta1, 1.10rc1 => 1.10.0-rc1 // 1.10beta1 => 1.10.0-beta1, 1.10rc1 => 1.10.0-rc1
// 1.8.5beta1 => 1.8.5-beta1, 1.8.5rc1 => 1.8.5-rc1 // 1.8.5beta1 => 1.8.5-beta1, 1.8.5rc1 => 1.8.5-rc1
function makeSemver(version) { function makeSemver(version) {
version = version.replace('go', ''); version = version.replace('go', '');
version = version.replace('beta', '-beta').replace('rc', '-rc'); version = version.replace('beta', '-beta').replace('rc', '-rc');
let parts = version.split('-'); let parts = version.split('-');
let verPart = parts[0]; let verPart = parts[0];
let prereleasePart = parts.length > 1 ? `-${parts[1]}` : ''; let prereleasePart = parts.length > 1 ? `-${parts[1]}` : '';
let verParts = verPart.split('.'); let verParts = verPart.split('.');
if (verParts.length == 2) { if (verParts.length == 2) {
verPart += '.0'; verPart += '.0';
} }
return `${verPart}${prereleasePart}`; return `${verPart}${prereleasePart}`;
} }
exports.makeSemver = makeSemver; exports.makeSemver = makeSemver;
/***/ }), /***/ }),

View file

@ -2,6 +2,7 @@ import * as core from '@actions/core';
import * as tc from '@actions/tool-cache'; import * as tc from '@actions/tool-cache';
import * as installer from './installer'; import * as installer from './installer';
import * as path from 'path'; import * as path from 'path';
import * as system from './system';
export async function run() { export async function run() {
try { try {
@ -34,6 +35,17 @@ export async function run() {
core.exportVariable('GOROOT', installDir); core.exportVariable('GOROOT', installDir);
core.addPath(path.join(installDir, 'bin')); core.addPath(path.join(installDir, 'bin'));
console.log('Added go to the path'); console.log('Added go to the path');
// set GOPATH and GOBIN as user value
const goPath: string = system.getGoPath();
if (goPath) {
core.exportVariable('GOPATH', goPath);
core.addPath(path.join(goPath, 'bin'));
}
const goBin: string = process.env['GOBIN'] || '';
if (goBin) {
core.exportVariable('GOBIN', goBin);
}
} else { } else {
throw new Error( throw new Error(
`Could not find a version that satisfied version spec: ${versionSpec}` `Could not find a version that satisfied version spec: ${versionSpec}`

View file

@ -1,4 +1,5 @@
let os = require('os'); import * as os from 'os';
import * as path from 'path';
export function getPlatform(): string { export function getPlatform(): string {
// darwin and linux match already // darwin and linux match already
@ -35,3 +36,17 @@ export function getArch(): string {
return arch; return arch;
} }
// Get GOPATH as user value or as defined by https://golang.org/doc/code.html#GOPATH
export function getGoPath(): string {
const home: string = process.env['HOME'] || '';
const goPath: string = process.env['GOPATH'] || '';
if (goPath) {
return goPath;
} else if (home) {
return path.join(home, 'go');
}
return '';
}