# This is a combination of 4 commits.

# This is the 1st commit message:

Add logic to download codeql platform-language pkg

* Add `bundleName` argument to `getCodeQLBundleDownloadURL`
* Add `languages` argument to `setupCodeQL`.

The logic now tries to find the platform-language pkg before defaulting
to the full bundle. We keep the toolcache clean by adding the pl version
to the tool version.

# The commit message #2 will be skipped:

# add test

# The commit message #3 will be skipped:

# cleanup

# The commit message #4 will be skipped:

# linter
This commit is contained in:
Marco Gario
2020-09-09 13:52:28 +02:00
parent 3f5bb98d7e
commit d3d7dd4600
8 changed files with 160 additions and 49 deletions
Generated
+9 -9
View File
@@ -90,6 +90,7 @@ async function getCodeQLBundleDownloadURL(bundleNames, githubAuth, githubUrl, mo
}
return `https://github.com/${CODEQL_DEFAULT_ACTION_REPOSITORY}/releases/download/${CODEQL_BUNDLE_VERSION}/${CODEQL_BUNDLE_NAME}`;
}
exports.getCodeQLBundleDownloadURL = getCodeQLBundleDownloadURL;
// We have to download CodeQL manually because the toolcache doesn't support Accept headers.
// This can be removed once https://github.com/actions/toolkit/pull/530 is merged and released.
async function toolcacheDownloadTool(url, headers, tempDir, logger) {
@@ -117,16 +118,16 @@ async function setupCodeQL(codeqlURL, languages, githubAuth, githubUrl, tempDir,
if (process.platform === 'win32') {
platform = "win64";
}
else if (process.platform == 'linux') {
else if (process.platform === 'linux') {
platform = "linux64";
}
else if (process.platform == 'darwin') {
else if (process.platform === 'darwin') {
platform = "osx64";
}
else {
throw new Error("Unsupported platform: " + process.platform);
}
if (languages.length == 1) {
if (languages.length === 1) {
plVersion = `${platform}-${languages[0]}`;
}
try {
@@ -154,15 +155,14 @@ async function setupCodeQL(codeqlURL, languages, githubAuth, githubUrl, tempDir,
const codeqlToolcacheVersion = plVersion ? `${codeqlURLVersion}-${plVersion}` : codeqlURLVersion;
logger.debug(`CodeQL not found in cache`);
if (!codeqlURL) {
const bundles = [CODEQL_BUNDLE_NAME.replace("-bundle", `-bundle-${plVersion}`),
// Provide a few options, from smaller to bigger
const bundles = [
CODEQL_BUNDLE_NAME.replace("-bundle", `-bundle-${plVersion}`),
CODEQL_BUNDLE_NAME.replace("-bundle", `-bundle-${platform}`),
CODEQL_BUNDLE_NAME];
CODEQL_BUNDLE_NAME,
];
codeqlURL = await getCodeQLBundleDownloadURL(bundles, githubAuth, githubUrl, mode, logger);
}
else if (plVersion) {
let pkgName = CODEQL_BUNDLE_NAME.replace("-bundle", `-${plVersion}`);
codeqlURL = codeqlURL.replace(CODEQL_BUNDLE_NAME, pkgName);
}
logger.debug(`Using CodeQL URL: ${codeqlURL}`);
const headers = { accept: 'application/octet-stream' };
// We only want to provide an authorization header if we are downloading