mirror of
https://github.com/github/codeql-action.git
synced 2026-05-11 16:20:35 +00:00
Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| aca0f6dc5d | |||
| 2192e3432b | |||
| 1b6e91df31 | |||
| c32aadf8fd | |||
| 7d646d3301 | |||
| 7b79062de0 | |||
| 61cdd2503b | |||
| 92c848eb82 | |||
| f93fb8df6e | |||
| eea148f0e6 | |||
| 34090feb56 | |||
| 976ada262f | |||
| c946707707 | |||
| 4f6104c444 | |||
| a27d3e9355 | |||
| cae6b78afc | |||
| 097823f389 |
@@ -35,8 +35,19 @@ runs:
|
||||
fi
|
||||
fi
|
||||
echo "version=$VERSION" | tee -a $GITHUB_OUTPUT
|
||||
|
||||
- name: Log disk info on Linux prior to setup-swift
|
||||
shell: bash
|
||||
run: |-
|
||||
if ! hash sudo &> /dev/null; then apt-get update -q=2 && apt-get install sudo -y -q=2; fi;
|
||||
sudo df -h
|
||||
if: runner.os == 'Linux'
|
||||
- uses: swift-actions/setup-swift@65540b95f51493d65f5e59e97dcef9629ddf11bf # Please update the corresponding SHA in the CLI's CodeQL Action Integration Test.
|
||||
if: runner.os != 'Windows' && steps.get_swift_version.outputs.version != 'null'
|
||||
with:
|
||||
swift-version: "${{ steps.get_swift_version.outputs.version }}"
|
||||
- name: Log disk info on Linux after setup-swift
|
||||
shell: bash
|
||||
run: |-
|
||||
if ! hash sudo &> /dev/null; then apt-get update -q=2 && apt-get install sudo -y -q=2; fi;
|
||||
sudo df -h
|
||||
if: runner.os == 'Linux'
|
||||
Generated
+6
@@ -52,6 +52,7 @@ exports.CODEQL_VERSION_INTRA_LAYER_PARALLELISM = "2.14.0";
|
||||
var Feature;
|
||||
(function (Feature) {
|
||||
Feature["CliConfigFileEnabled"] = "cli_config_file_enabled";
|
||||
Feature["CodeqlJavaLombokEnabled"] = "codeql_java_lombok_enabled";
|
||||
Feature["DisableKotlinAnalysisEnabled"] = "disable_kotlin_analysis_enabled";
|
||||
Feature["DisablePythonDependencyInstallationEnabled"] = "disable_python_dependency_installation_enabled";
|
||||
Feature["EvaluatorIntraLayerParallelismEnabled"] = "evaluator_intra_layer_parallelism_enabled";
|
||||
@@ -63,6 +64,11 @@ var Feature;
|
||||
Feature["UploadFailedSarifEnabled"] = "upload_failed_sarif_enabled";
|
||||
})(Feature || (exports.Feature = Feature = {}));
|
||||
exports.featureConfig = {
|
||||
[Feature.CodeqlJavaLombokEnabled]: {
|
||||
envVar: "CODEQL_JAVA_LOMBOK",
|
||||
minimumVersion: "2.14.0",
|
||||
defaultValue: false,
|
||||
},
|
||||
[Feature.DisableKotlinAnalysisEnabled]: {
|
||||
envVar: "CODEQL_DISABLE_KOTLIN_ANALYSIS",
|
||||
minimumVersion: undefined,
|
||||
|
||||
File diff suppressed because one or more lines are too long
Generated
+10
@@ -178,6 +178,16 @@ async function run() {
|
||||
if (await features.getValue(feature_flags_1.Feature.DisableKotlinAnalysisEnabled)) {
|
||||
core.exportVariable("CODEQL_EXTRACTOR_JAVA_AGENT_DISABLE_KOTLIN", "true");
|
||||
}
|
||||
if (config.languages.includes(languages_1.Language.java)) {
|
||||
if (await features.getValue(feature_flags_1.Feature.CodeqlJavaLombokEnabled, codeql)) {
|
||||
logger.info("Enabling CodeQL Java Lombok support");
|
||||
core.exportVariable("CODEQL_EXTRACTOR_JAVA_RUN_ANNOTATION_PROCESSORS", "true");
|
||||
}
|
||||
else {
|
||||
logger.info("Disabling CodeQL Java Lombok support");
|
||||
core.exportVariable("CODEQL_EXTRACTOR_JAVA_RUN_ANNOTATION_PROCESSORS", "false");
|
||||
}
|
||||
}
|
||||
// Disable Python dependency extraction if feature flag set
|
||||
if (await features.getValue(feature_flags_1.Feature.DisablePythonDependencyInstallationEnabled, codeql)) {
|
||||
core.exportVariable("CODEQL_EXTRACTOR_PYTHON_DISABLE_LIBRARY_EXTRACTION", "true");
|
||||
|
||||
File diff suppressed because one or more lines are too long
Generated
+34
-13
@@ -421,25 +421,22 @@ async function downloadCodeQL(codeqlURL, maybeBundleVersion, maybeCliVersion, ap
|
||||
const dest = path.join(tempDir, (0, uuid_1.v4)());
|
||||
const finalHeaders = Object.assign({ "User-Agent": "CodeQL Action" }, headers);
|
||||
const toolsDownloadStart = perf_hooks_1.performance.now();
|
||||
const codeqlPath = await toolcache.downloadTool(codeqlURL, dest, authorization, finalHeaders);
|
||||
const archivedBundlePath = await toolcache.downloadTool(codeqlURL, dest, authorization, finalHeaders);
|
||||
const toolsDownloadDurationMs = Math.round(perf_hooks_1.performance.now() - toolsDownloadStart);
|
||||
logger.debug(`Finished downloading CodeQL bundle to ${codeqlPath} (${toolsDownloadDurationMs} ms).`);
|
||||
const codeqlExtracted = await toolcache.extractTar(codeqlPath);
|
||||
logger.debug(`Finished extracting CodeQL bundle to ${codeqlExtracted}.`);
|
||||
try {
|
||||
await (0, del_1.default)(codeqlPath, { force: true });
|
||||
logger.debug("Deleted CodeQL bundle archive.");
|
||||
}
|
||||
catch (e) {
|
||||
logger.warning("Failed to delete CodeQL bundle archive.");
|
||||
}
|
||||
logger.debug(`Finished downloading CodeQL bundle to ${archivedBundlePath} (${toolsDownloadDurationMs} ms).`);
|
||||
logger.debug("Extracting CodeQL bundle.");
|
||||
const extractionStart = perf_hooks_1.performance.now();
|
||||
const extractedBundlePath = await toolcache.extractTar(archivedBundlePath);
|
||||
const extractionMs = Math.round(perf_hooks_1.performance.now() - extractionStart);
|
||||
logger.debug(`Finished extracting CodeQL bundle to ${extractedBundlePath} (${extractionMs} ms).`);
|
||||
await cleanUpGlob(archivedBundlePath, "CodeQL bundle archive", logger);
|
||||
const bundleVersion = maybeBundleVersion ?? tryGetBundleVersionFromUrl(codeqlURL, logger);
|
||||
if (bundleVersion === undefined) {
|
||||
logger.debug("Could not cache CodeQL tools because we could not determine the bundle version from the " +
|
||||
`URL ${codeqlURL}.`);
|
||||
return {
|
||||
toolsVersion: maybeCliVersion ?? "unknown",
|
||||
codeqlFolder: codeqlExtracted,
|
||||
codeqlFolder: extractedBundlePath,
|
||||
toolsDownloadDurationMs,
|
||||
};
|
||||
}
|
||||
@@ -461,9 +458,15 @@ async function downloadCodeQL(codeqlURL, maybeBundleVersion, maybeCliVersion, ap
|
||||
const toolcacheVersion = maybeCliVersion?.match(/^[0-9]+\.[0-9]+\.[0-9]+$/)
|
||||
? `${maybeCliVersion}-${bundleVersion}`
|
||||
: convertToSemVer(bundleVersion, logger);
|
||||
logger.debug("Caching CodeQL bundle.");
|
||||
const toolcachedBundlePath = await toolcache.cacheDir(extractedBundlePath, "CodeQL", toolcacheVersion);
|
||||
// Defensive check: we expect `cacheDir` to copy the bundle to a new location.
|
||||
if (toolcachedBundlePath !== extractedBundlePath) {
|
||||
await cleanUpGlob(extractedBundlePath, "CodeQL bundle from temporary directory", logger);
|
||||
}
|
||||
return {
|
||||
toolsVersion: maybeCliVersion ?? toolcacheVersion,
|
||||
codeqlFolder: await toolcache.cacheDir(codeqlExtracted, "CodeQL", toolcacheVersion),
|
||||
codeqlFolder: toolcachedBundlePath,
|
||||
toolsDownloadDurationMs,
|
||||
};
|
||||
}
|
||||
@@ -519,4 +522,22 @@ async function setupCodeQLBundle(toolsInput, apiDetails, tempDir, variant, defau
|
||||
return { codeqlFolder, toolsDownloadDurationMs, toolsSource, toolsVersion };
|
||||
}
|
||||
exports.setupCodeQLBundle = setupCodeQLBundle;
|
||||
async function cleanUpGlob(glob, name, logger) {
|
||||
logger.debug(`Cleaning up ${name}.`);
|
||||
try {
|
||||
const deletedPaths = await (0, del_1.default)(glob, { force: true });
|
||||
if (deletedPaths.length === 0) {
|
||||
logger.warning(`Failed to clean up ${name}: no files found matching ${glob}.`);
|
||||
}
|
||||
else if (deletedPaths.length === 1) {
|
||||
logger.debug(`Cleaned up ${name}.`);
|
||||
}
|
||||
else {
|
||||
logger.debug(`Cleaned up ${name} (${deletedPaths.length} files).`);
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
logger.warning(`Failed to clean up ${name}: ${e}.`);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=setup-codeql.js.map
|
||||
File diff suppressed because one or more lines are too long
@@ -49,6 +49,7 @@ export interface FeatureEnablement {
|
||||
*/
|
||||
export enum Feature {
|
||||
CliConfigFileEnabled = "cli_config_file_enabled",
|
||||
CodeqlJavaLombokEnabled = "codeql_java_lombok_enabled",
|
||||
DisableKotlinAnalysisEnabled = "disable_kotlin_analysis_enabled",
|
||||
DisablePythonDependencyInstallationEnabled = "disable_python_dependency_installation_enabled",
|
||||
EvaluatorIntraLayerParallelismEnabled = "evaluator_intra_layer_parallelism_enabled",
|
||||
@@ -64,6 +65,11 @@ export const featureConfig: Record<
|
||||
Feature,
|
||||
{ envVar: string; minimumVersion: string | undefined; defaultValue: boolean }
|
||||
> = {
|
||||
[Feature.CodeqlJavaLombokEnabled]: {
|
||||
envVar: "CODEQL_JAVA_LOMBOK",
|
||||
minimumVersion: "2.14.0",
|
||||
defaultValue: false,
|
||||
},
|
||||
[Feature.DisableKotlinAnalysisEnabled]: {
|
||||
envVar: "CODEQL_DISABLE_KOTLIN_ANALYSIS",
|
||||
minimumVersion: undefined,
|
||||
|
||||
@@ -342,6 +342,22 @@ async function run() {
|
||||
core.exportVariable("CODEQL_EXTRACTOR_JAVA_AGENT_DISABLE_KOTLIN", "true");
|
||||
}
|
||||
|
||||
if (config.languages.includes(Language.java)) {
|
||||
if (await features.getValue(Feature.CodeqlJavaLombokEnabled, codeql)) {
|
||||
logger.info("Enabling CodeQL Java Lombok support");
|
||||
core.exportVariable(
|
||||
"CODEQL_EXTRACTOR_JAVA_RUN_ANNOTATION_PROCESSORS",
|
||||
"true",
|
||||
);
|
||||
} else {
|
||||
logger.info("Disabling CodeQL Java Lombok support");
|
||||
core.exportVariable(
|
||||
"CODEQL_EXTRACTOR_JAVA_RUN_ANNOTATION_PROCESSORS",
|
||||
"false",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Disable Python dependency extraction if feature flag set
|
||||
if (
|
||||
await features.getValue(
|
||||
|
||||
+47
-18
@@ -560,7 +560,7 @@ export async function downloadCodeQL(
|
||||
);
|
||||
|
||||
const toolsDownloadStart = performance.now();
|
||||
const codeqlPath = await toolcache.downloadTool(
|
||||
const archivedBundlePath = await toolcache.downloadTool(
|
||||
codeqlURL,
|
||||
dest,
|
||||
authorization,
|
||||
@@ -571,19 +571,17 @@ export async function downloadCodeQL(
|
||||
);
|
||||
|
||||
logger.debug(
|
||||
`Finished downloading CodeQL bundle to ${codeqlPath} (${toolsDownloadDurationMs} ms).`,
|
||||
`Finished downloading CodeQL bundle to ${archivedBundlePath} (${toolsDownloadDurationMs} ms).`,
|
||||
);
|
||||
|
||||
const codeqlExtracted = await toolcache.extractTar(codeqlPath);
|
||||
|
||||
logger.debug(`Finished extracting CodeQL bundle to ${codeqlExtracted}.`);
|
||||
|
||||
try {
|
||||
await del(codeqlPath, { force: true });
|
||||
logger.debug("Deleted CodeQL bundle archive.");
|
||||
} catch (e) {
|
||||
logger.warning("Failed to delete CodeQL bundle archive.");
|
||||
}
|
||||
logger.debug("Extracting CodeQL bundle.");
|
||||
const extractionStart = performance.now();
|
||||
const extractedBundlePath = await toolcache.extractTar(archivedBundlePath);
|
||||
const extractionMs = Math.round(performance.now() - extractionStart);
|
||||
logger.debug(
|
||||
`Finished extracting CodeQL bundle to ${extractedBundlePath} (${extractionMs} ms).`,
|
||||
);
|
||||
await cleanUpGlob(archivedBundlePath, "CodeQL bundle archive", logger);
|
||||
|
||||
const bundleVersion =
|
||||
maybeBundleVersion ?? tryGetBundleVersionFromUrl(codeqlURL, logger);
|
||||
@@ -595,7 +593,7 @@ export async function downloadCodeQL(
|
||||
);
|
||||
return {
|
||||
toolsVersion: maybeCliVersion ?? "unknown",
|
||||
codeqlFolder: codeqlExtracted,
|
||||
codeqlFolder: extractedBundlePath,
|
||||
toolsDownloadDurationMs,
|
||||
};
|
||||
}
|
||||
@@ -624,13 +622,26 @@ export async function downloadCodeQL(
|
||||
const toolcacheVersion = maybeCliVersion?.match(/^[0-9]+\.[0-9]+\.[0-9]+$/)
|
||||
? `${maybeCliVersion}-${bundleVersion}`
|
||||
: convertToSemVer(bundleVersion, logger);
|
||||
|
||||
logger.debug("Caching CodeQL bundle.");
|
||||
const toolcachedBundlePath = await toolcache.cacheDir(
|
||||
extractedBundlePath,
|
||||
"CodeQL",
|
||||
toolcacheVersion,
|
||||
);
|
||||
|
||||
// Defensive check: we expect `cacheDir` to copy the bundle to a new location.
|
||||
if (toolcachedBundlePath !== extractedBundlePath) {
|
||||
await cleanUpGlob(
|
||||
extractedBundlePath,
|
||||
"CodeQL bundle from temporary directory",
|
||||
logger,
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
toolsVersion: maybeCliVersion ?? toolcacheVersion,
|
||||
codeqlFolder: await toolcache.cacheDir(
|
||||
codeqlExtracted,
|
||||
"CodeQL",
|
||||
toolcacheVersion,
|
||||
),
|
||||
codeqlFolder: toolcachedBundlePath,
|
||||
toolsDownloadDurationMs,
|
||||
};
|
||||
}
|
||||
@@ -714,3 +725,21 @@ export async function setupCodeQLBundle(
|
||||
}
|
||||
return { codeqlFolder, toolsDownloadDurationMs, toolsSource, toolsVersion };
|
||||
}
|
||||
|
||||
async function cleanUpGlob(glob: string, name: string, logger: Logger) {
|
||||
logger.debug(`Cleaning up ${name}.`);
|
||||
try {
|
||||
const deletedPaths = await del(glob, { force: true });
|
||||
if (deletedPaths.length === 0) {
|
||||
logger.warning(
|
||||
`Failed to clean up ${name}: no files found matching ${glob}.`,
|
||||
);
|
||||
} else if (deletedPaths.length === 1) {
|
||||
logger.debug(`Cleaned up ${name}.`);
|
||||
} else {
|
||||
logger.debug(`Cleaned up ${name} (${deletedPaths.length} files).`);
|
||||
}
|
||||
} catch (e) {
|
||||
logger.warning(`Failed to clean up ${name}: ${e}.`);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user