-
Notifications
You must be signed in to change notification settings - Fork 451
Expand file tree
/
Copy pathdiagnostics.ts
More file actions
113 lines (109 loc) · 4.38 KB
/
diagnostics.ts
File metadata and controls
113 lines (109 loc) · 4.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import { type CodeQL } from "../codeql";
import { type Config } from "../config-utils";
import {
addNoLanguageDiagnostic,
makeDiagnostic,
makeTelemetryDiagnostic,
} from "../diagnostics";
import { DocUrl } from "../doc-url";
import { RepositoryPropertyName } from "../feature-flags/properties";
/** Reason why overlay analysis was disabled. */
export enum OverlayDisabledReason {
/** Overlay analysis was disabled by a repository property. */
DisabledByRepositoryProperty = "disabled-by-repository-property",
/** Overlay analysis feature was not enabled. */
FeatureNotEnabled = "feature-not-enabled",
/** The build mode is incompatible with overlay analysis. */
IncompatibleBuildMode = "incompatible-build-mode",
/** The CodeQL CLI version is too old to support overlay analysis. */
IncompatibleCodeQl = "incompatible-codeql",
/** The Git version could not be determined or is too old. */
IncompatibleGit = "incompatible-git",
/** The runner does not have enough disk space or memory. */
InsufficientResources = "insufficient-resources",
/** The source root is not inside a git repository. */
NoGitRoot = "no-git-root",
/** Overlay analysis was skipped because it previously failed with similar hardware resources. */
SkippedDueToCachedStatus = "skipped-due-to-cached-status",
/** Disk usage could not be determined during the overlay status check. */
UnableToDetermineDiskUsage = "unable-to-determine-disk-usage",
}
/**
* Add diagnostics related to why overlay was disabled. This includes:
*
* - A telemetry diagnostic that logs the disablement reason.
* - User-facing diagnostics for specific disablement reasons that are
* actionable by the user.
*/
export async function addOverlayDisablementDiagnostics(
config: Config,
codeql: CodeQL,
overlayDisabledReason: OverlayDisabledReason,
): Promise<void> {
addNoLanguageDiagnostic(
config,
makeTelemetryDiagnostic(
"codeql-action/overlay-disabled",
"Overlay analysis disabled",
{
reason: overlayDisabledReason,
},
),
);
if (
overlayDisabledReason === OverlayDisabledReason.SkippedDueToCachedStatus
) {
addNoLanguageDiagnostic(
config,
makeDiagnostic(
"codeql-action/overlay-disabled-due-to-cached-status",
"Skipped improved incremental analysis because it failed previously with similar hardware resources",
{
attributes: {
languages: config.languages,
},
markdownMessage:
`Improved incremental analysis was skipped because it previously failed for this repository ` +
`with CodeQL version ${(await codeql.getVersion()).version} on a runner with similar hardware resources. ` +
"One possible reason for this is that improved incremental analysis can require a significant amount of disk space for some repositories. " +
"If you want to try re-enabling improved incremental analysis, increase the disk space available " +
"to the runner. If that doesn't help, contact GitHub Support for further assistance.\n\n" +
"Improved incremental analysis will be automatically retried when the next version of CodeQL is released. " +
`You can also manually trigger a retry by [removing](${DocUrl.DELETE_ACTIONS_CACHE_ENTRIES}) \`codeql-overlay-status-*\` entries from the Actions cache.`,
severity: "note",
visibility: {
cliSummaryTable: true,
statusPage: true,
telemetry: false,
},
},
),
);
}
if (
overlayDisabledReason === OverlayDisabledReason.DisabledByRepositoryProperty
) {
addNoLanguageDiagnostic(
config,
makeDiagnostic(
"codeql-action/overlay-disabled-by-repository-property",
"Improved incremental analysis disabled by repository property",
{
attributes: {
languages: config.languages,
},
markdownMessage:
"Improved incremental analysis has been disabled because the " +
`\`${RepositoryPropertyName.DISABLE_OVERLAY}\` repository property is set to \`true\`. ` +
"To re-enable improved incremental analysis, set this property to `false` or remove it.",
severity: "note",
visibility: {
cliSummaryTable: true,
statusPage: true,
telemetry: false,
},
},
),
);
}
}