mirror of
https://github.com/github/codeql-action.git
synced 2026-05-07 22:30:44 +00:00
# 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 simple fallback logic for download # The commit message #3 will be skipped: # wip linter # The commit message #4 will be skipped: # linter
This commit is contained in:
Generated
+31
-8
@@ -48,7 +48,7 @@ function getCodeQLActionRepository(mode) {
|
||||
const relativeScriptPathParts = relativeScriptPath.split(path.sep);
|
||||
return relativeScriptPathParts[0] + "/" + relativeScriptPathParts[1];
|
||||
}
|
||||
async function getCodeQLBundleDownloadURL(bundleName, githubAuth, githubUrl, mode, logger) {
|
||||
async function getCodeQLBundleDownloadURL(bundleNames, githubAuth, githubUrl, mode, logger) {
|
||||
const codeQLActionRepository = getCodeQLActionRepository(mode);
|
||||
const potentialDownloadSources = [
|
||||
// This GitHub instance, and this Action.
|
||||
@@ -74,10 +74,13 @@ async function getCodeQLBundleDownloadURL(bundleName, githubAuth, githubUrl, mod
|
||||
repo: repositoryName,
|
||||
tag: CODEQL_BUNDLE_VERSION
|
||||
});
|
||||
for (let asset of release.data.assets) {
|
||||
if (asset.name === bundleName) {
|
||||
logger.info(`Found CodeQL bundle in ${downloadSource[1]} on ${downloadSource[0]} with URL ${asset.url}.`);
|
||||
return asset.url;
|
||||
// See if any of the bundles appears in the assets list
|
||||
for (let bundleName of bundleNames) {
|
||||
for (let asset of release.data.assets) {
|
||||
if (asset.name === bundleName) {
|
||||
logger.info(`Found CodeQL bundle in ${downloadSource[1]} on ${downloadSource[0]} with URL ${asset.url}.`);
|
||||
return asset.url;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -102,12 +105,30 @@ async function toolcacheDownloadTool(url, headers, tempDir, logger) {
|
||||
await pipeline(response.message, fs.createWriteStream(dest));
|
||||
return dest;
|
||||
}
|
||||
async function setupCodeQL(codeqlURL, plVersion, githubAuth, githubUrl, tempDir, toolsDir, mode, logger) {
|
||||
async function setupCodeQL(codeqlURL, languages, githubAuth, githubUrl, tempDir, toolsDir, mode, logger) {
|
||||
// Setting these two env vars makes the toolcache code safe to use outside,
|
||||
// of actions but this is obviously not a great thing we're doing and it would
|
||||
// be better to write our own implementation to use outside of actions.
|
||||
process.env['RUNNER_TEMP'] = tempDir;
|
||||
process.env['RUNNER_TOOL_CACHE'] = toolsDir;
|
||||
// Compute package version
|
||||
let plVersion = undefined;
|
||||
let platform;
|
||||
if (process.platform === 'win32') {
|
||||
platform = "win64";
|
||||
}
|
||||
else if (process.platform == 'linux') {
|
||||
platform = "linux64";
|
||||
}
|
||||
else if (process.platform == 'darwin') {
|
||||
platform = "osx64";
|
||||
}
|
||||
else {
|
||||
throw new Error("Unsupported platform: " + process.platform);
|
||||
}
|
||||
if (languages.length == 1) {
|
||||
plVersion = `${platform}-${languages[0]}`;
|
||||
}
|
||||
try {
|
||||
// The URL identifies the release version. E.g., codeql-20200901 .
|
||||
// The plVersion identifies the platform-language combination of the package
|
||||
@@ -133,8 +154,10 @@ async function setupCodeQL(codeqlURL, plVersion, githubAuth, githubUrl, tempDir,
|
||||
const codeqlToolcacheVersion = plVersion ? `${codeqlURLVersion}-${plVersion}` : codeqlURLVersion;
|
||||
logger.debug(`CodeQL not found in cache`);
|
||||
if (!codeqlURL) {
|
||||
let pkgName = plVersion ? CODEQL_BUNDLE_NAME.replace("-bundle", `-${plVersion}`) : CODEQL_BUNDLE_NAME; // TODO : Maybe move template a constant?
|
||||
codeqlURL = await getCodeQLBundleDownloadURL(pkgName, githubAuth, githubUrl, mode, logger);
|
||||
const bundles = [CODEQL_BUNDLE_NAME.replace("-bundle", `-bundle-${plVersion}`),
|
||||
CODEQL_BUNDLE_NAME.replace("-bundle", `-bundle-${platform}`),
|
||||
CODEQL_BUNDLE_NAME];
|
||||
codeqlURL = await getCodeQLBundleDownloadURL(bundles, githubAuth, githubUrl, mode, logger);
|
||||
}
|
||||
else if (plVersion) {
|
||||
let pkgName = CODEQL_BUNDLE_NAME.replace("-bundle", `-${plVersion}`);
|
||||
|
||||
Reference in New Issue
Block a user