Compare commits

...

17 Commits

Author SHA1 Message Date
Angela P Wen aca0f6dc5d Log disk info before/after setup-swift 2023-08-03 11:50:54 +02:00
Florin Coada 2192e3432b Merge pull request #1809 from github/igfoo/code_scanning_codeql_java_lombok
Add support for the code_scanning_codeql_java_lombok feature flag
2023-08-02 12:47:52 +01:00
Angela P Wen 1b6e91df31 Autogenerate source map 2023-08-02 11:54:32 +02:00
Angela P Wen c32aadf8fd Merge branch 'main' into igfoo/code_scanning_codeql_java_lombok 2023-08-02 02:44:05 -07:00
Angela P Wen 7d646d3301 Empty commit 2023-08-02 11:40:37 +02:00
Henry Mercer 7b79062de0 Merge pull request #1820 from github/henrymercer/delete-bundle-archive
Clean up the bundle archive after extracting it
2023-08-01 20:16:50 +01:00
Henry Mercer 61cdd2503b Factor out common code for cleaning up bundle artifacts 2023-08-01 19:47:57 +01:00
Henry Mercer 92c848eb82 Improve variable naming 2023-08-01 19:21:17 +01:00
Henry Mercer f93fb8df6e Clean up non-toolcached bundle 2023-08-01 18:50:45 +01:00
Ian Lynagh eea148f0e6 Run "npm run build" 2023-07-28 14:56:05 +01:00
Ian Lynagh 34090feb56 Lombok: Only do anything if Java is being analysed 2023-07-28 14:55:23 +01:00
Ian Lynagh 976ada262f Regen 2023-07-27 12:45:19 +01:00
Ian Lynagh c946707707 Pass codeql in to check 2023-07-27 12:45:08 +01:00
Ian Lynagh 4f6104c444 Run "npm run build" 2023-07-27 12:37:40 +01:00
Ian Lynagh a27d3e9355 Fix lint suggestions 2023-07-27 12:36:57 +01:00
Ian Lynagh cae6b78afc Be more consistent 2023-07-27 12:30:08 +01:00
Ian Lynagh 097823f389 Add support for the code_scanning_codeql_java_lombok feature flag 2023-07-27 12:19:38 +01:00
10 changed files with 134 additions and 35 deletions
+12 -1
View File
@@ -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'
+6
View File
@@ -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
+10
View File
@@ -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
+34 -13
View File
@@ -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
+6
View File
@@ -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,
+16
View File
@@ -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
View File
@@ -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}.`);
}
}