Skip to content

Commit 77b81c4

Browse files
committed
Add status page diagnostic when overlay skipped
1 parent a2a8674 commit 77b81c4

8 files changed

Lines changed: 95 additions & 21 deletions

lib/analyze-action.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/init-action-post.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/init-action.js

Lines changed: 34 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/upload-lib.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/upload-sarif-action.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/config-utils.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1015,6 +1015,7 @@ const getOverlayDatabaseModeMacro = test.macro({
10151015
expected: {
10161016
overlayDatabaseMode: OverlayDatabaseMode;
10171017
useOverlayDatabaseCaching: boolean;
1018+
skippedDueToCachedStatus?: boolean;
10181019
},
10191020
) => {
10201021
return await withTmpDir(async (tempDir) => {
@@ -1085,7 +1086,10 @@ const getOverlayDatabaseModeMacro = test.macro({
10851086
logger,
10861087
);
10871088

1088-
t.deepEqual(result, expected);
1089+
t.deepEqual(result, {
1090+
skippedDueToCachedStatus: false,
1091+
...expected,
1092+
});
10891093
} finally {
10901094
// Restore the original environment
10911095
process.env = originalEnv;
@@ -1318,6 +1322,7 @@ test(
13181322
{
13191323
overlayDatabaseMode: OverlayDatabaseMode.None,
13201324
useOverlayDatabaseCaching: false,
1325+
skippedDueToCachedStatus: true,
13211326
},
13221327
);
13231328

@@ -1337,6 +1342,7 @@ test(
13371342
{
13381343
overlayDatabaseMode: OverlayDatabaseMode.None,
13391344
useOverlayDatabaseCaching: false,
1345+
skippedDueToCachedStatus: true,
13401346
},
13411347
);
13421348

src/config-utils.ts

Lines changed: 48 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@ import {
2828
} from "./config/db-config";
2929
import {
3030
addNoLanguageDiagnostic,
31+
makeDiagnostic,
3132
makeTelemetryDiagnostic,
3233
} from "./diagnostics";
3334
import { shouldPerformDiffInformedAnalysis } from "./diff-informed-analysis-utils";
35+
import { DocUrl } from "./doc-url";
3436
import { EnvVar } from "./environment";
3537
import * as errorMessages from "./error-messages";
3638
import { Feature, FeatureEnablement } from "./feature-flags";
@@ -740,9 +742,11 @@ export async function getOverlayDatabaseMode(
740742
): Promise<{
741743
overlayDatabaseMode: OverlayDatabaseMode;
742744
useOverlayDatabaseCaching: boolean;
745+
skippedDueToCachedStatus: boolean;
743746
}> {
744747
let overlayDatabaseMode = OverlayDatabaseMode.None;
745748
let useOverlayDatabaseCaching = false;
749+
let skippedDueToCachedStatus = false;
746750

747751
const modeEnv = process.env.CODEQL_OVERLAY_DATABASE_MODE;
748752
// Any unrecognized CODEQL_OVERLAY_DATABASE_MODE value will be ignored and
@@ -782,6 +786,7 @@ export async function getOverlayDatabaseMode(
782786
"Consider running CodeQL analysis on a larger runner.",
783787
);
784788
overlayDatabaseMode = OverlayDatabaseMode.None;
789+
skippedDueToCachedStatus = true;
785790
} else if (
786791
performResourceChecks &&
787792
!(await runnerSupportsOverlayAnalysis(diskUsage, ramInput, logger))
@@ -807,6 +812,7 @@ export async function getOverlayDatabaseMode(
807812
const nonOverlayAnalysis = {
808813
overlayDatabaseMode: OverlayDatabaseMode.None,
809814
useOverlayDatabaseCaching: false,
815+
skippedDueToCachedStatus,
810816
};
811817

812818
if (overlayDatabaseMode === OverlayDatabaseMode.None) {
@@ -871,6 +877,7 @@ export async function getOverlayDatabaseMode(
871877
return {
872878
overlayDatabaseMode,
873879
useOverlayDatabaseCaching,
880+
skippedDueToCachedStatus,
874881
};
875882
}
876883

@@ -1014,25 +1021,54 @@ export async function initConfig(
10141021
// and queries, which in turn depends on the user config and the augmentation
10151022
// properties. So we need to calculate the overlay database mode after the
10161023
// rest of the config has been populated.
1017-
const { overlayDatabaseMode, useOverlayDatabaseCaching } =
1018-
await getOverlayDatabaseMode(
1019-
inputs.codeql,
1020-
inputs.features,
1021-
config.languages,
1022-
inputs.sourceRoot,
1023-
config.buildMode,
1024-
inputs.ramInput,
1025-
config.computedConfig,
1026-
gitVersion,
1027-
logger,
1028-
);
1024+
const {
1025+
overlayDatabaseMode,
1026+
useOverlayDatabaseCaching,
1027+
skippedDueToCachedStatus: overlaySkippedDueToCachedStatus,
1028+
} = await getOverlayDatabaseMode(
1029+
inputs.codeql,
1030+
inputs.features,
1031+
config.languages,
1032+
inputs.sourceRoot,
1033+
config.buildMode,
1034+
inputs.ramInput,
1035+
config.computedConfig,
1036+
gitVersion,
1037+
logger,
1038+
);
10291039
logger.info(
10301040
`Using overlay database mode: ${overlayDatabaseMode} ` +
10311041
`${useOverlayDatabaseCaching ? "with" : "without"} caching.`,
10321042
);
10331043
config.overlayDatabaseMode = overlayDatabaseMode;
10341044
config.useOverlayDatabaseCaching = useOverlayDatabaseCaching;
10351045

1046+
if (overlaySkippedDueToCachedStatus) {
1047+
addNoLanguageDiagnostic(
1048+
config,
1049+
makeDiagnostic(
1050+
"codeql-action/overlay-skipped-due-to-cached-status",
1051+
"Overlay analysis skipped due to cached status",
1052+
{
1053+
attributes: {
1054+
languages: config.languages,
1055+
},
1056+
markdownMessage:
1057+
`Overlay analysis was skipped because it failed previously on this runner. ` +
1058+
"Running CodeQL analysis on a larger runner may allow overlay analysis to run successfully.\n\n" +
1059+
"Overlay analysis will be automatically retried when the next version of CodeQL is released. " +
1060+
`You can also manually trigger a retry by [removing](${DocUrl.DELETE_ACTIONS_CACHE_ENTRIES}) \`codeql-overlay-status-*\` entries from the Actions cache.`,
1061+
severity: "note",
1062+
visibility: {
1063+
cliSummaryTable: true,
1064+
statusPage: true,
1065+
telemetry: true,
1066+
},
1067+
},
1068+
),
1069+
);
1070+
}
1071+
10361072
if (
10371073
overlayDatabaseMode === OverlayDatabaseMode.Overlay ||
10381074
(await shouldPerformDiffInformedAnalysis(

src/doc-url.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ export enum DocUrl {
77
AUTOMATIC_BUILD_FAILED = "https://docs.github.com/en/code-security/code-scanning/troubleshooting-code-scanning/automatic-build-failed",
88
CODEQL_BUILD_MODES = "https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages#codeql-build-modes",
99
DEFINE_ENV_VARIABLES = "https://docs.github.com/en/actions/learn-github-actions/variables#defining-environment-variables-for-a-single-workflow",
10+
DELETE_ACTIONS_CACHE_ENTRIES = "https://docs.github.com/en/actions/how-tos/manage-workflow-runs/manage-caches#deleting-cache-entries",
1011
SCANNING_ON_PUSH = "https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning#scanning-on-push",
1112
SPECIFY_BUILD_STEPS_MANUALLY = "https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages#about-specifying-build-steps-manually",
1213
SYSTEM_REQUIREMENTS = "https://codeql.github.com/docs/codeql-overview/system-requirements/",
13-
TRACK_CODE_SCANNING_ALERTS_ACROSS_RUNS = "https://docs.github.com/en/enterprise-cloud@latest/code-security/code-scanning/integrating-with-code-scanning/sarif-support-for-code-scanning#providing-data-to-track-code-scanning-alerts-across-runs",
14+
TRACK_CODE_SCANNING_ALERTS_ACROSS_RUNS = "https://docs.github.com/en/code-security/reference/code-scanning/sarif-support-for-code-scanning#data-for-preventing-duplicated-alerts",
1415
}

0 commit comments

Comments
 (0)