compiled js
This commit is contained in:
parent
3f2a60be8a
commit
ff8fe44e0c
6 changed files with 147 additions and 7 deletions
28
lib/setup-tools.js
generated
28
lib/setup-tools.js
generated
|
|
@ -9,7 +9,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const core = __importStar(require("@actions/core"));
|
||||
const toolcache = __importStar(require("@actions/tool-cache"));
|
||||
const crypto = __importStar(require("crypto"));
|
||||
const semver = __importStar(require("semver"));
|
||||
const path = __importStar(require("path"));
|
||||
class CodeQLSetup {
|
||||
constructor(codeqlDist) {
|
||||
|
|
@ -36,18 +36,17 @@ class CodeQLSetup {
|
|||
}
|
||||
exports.CodeQLSetup = CodeQLSetup;
|
||||
async function setupCodeQL() {
|
||||
const hash = crypto.createHash('sha256');
|
||||
const codeqlURL = core.getInput('tools', { required: true });
|
||||
const codeqlURLHash = hash.update(codeqlURL).digest('hex');
|
||||
try {
|
||||
let codeqlFolder = toolcache.find('CodeQL', codeqlURLHash);
|
||||
const codeqlURL = core.getInput('tools', { required: true });
|
||||
const codeqlURLVersion = getCodeQLURLVersion(codeqlURL);
|
||||
let codeqlFolder = toolcache.find('CodeQL', codeqlURLVersion);
|
||||
if (codeqlFolder) {
|
||||
core.debug(`CodeQL found in cache ${codeqlFolder}`);
|
||||
}
|
||||
else {
|
||||
const codeqlPath = await toolcache.downloadTool(codeqlURL);
|
||||
const codeqlExtracted = await toolcache.extractTar(codeqlPath);
|
||||
codeqlFolder = await toolcache.cacheDir(codeqlExtracted, 'CodeQL', codeqlURLHash);
|
||||
codeqlFolder = await toolcache.cacheDir(codeqlExtracted, 'CodeQL', codeqlURLVersion);
|
||||
}
|
||||
return new CodeQLSetup(path.join(codeqlFolder, 'codeql'));
|
||||
}
|
||||
|
|
@ -57,4 +56,21 @@ async function setupCodeQL() {
|
|||
}
|
||||
}
|
||||
exports.setupCodeQL = setupCodeQL;
|
||||
function getCodeQLURLVersion(url) {
|
||||
const match = url.match(/codeql-bundle-([\d+(\.\d+)]+)/);
|
||||
if (match === null || match.length < 2) {
|
||||
throw new Error(`Malformed tools url: ${url}. Version could not be inferred`);
|
||||
}
|
||||
let version = match[1];
|
||||
if (!semver.valid(version)) {
|
||||
core.debug(`Bundle version ${version} is not in SemVer format. Will treat it as pre-release 0.0.0-${version}.`);
|
||||
version = '0.0.0-' + version;
|
||||
}
|
||||
const s = semver.clean(version);
|
||||
if (!s) {
|
||||
throw new Error(`Malformed tools url ${url}. Version should be in SemVer format but have ${version} instead`);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
exports.getCodeQLURLVersion = getCodeQLURLVersion;
|
||||
//# sourceMappingURL=setup-tools.js.map
|
||||
Loading…
Add table
Add a link
Reference in a new issue