-
Notifications
You must be signed in to change notification settings - Fork 433
Support ignoring generated files #3318
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
1512f40
3eaf000
846f859
b4db382
1782089
02b2c55
644e2b9
055e6b6
c7d0b92
5f5c095
9c3f69d
546ea07
7beb642
4bd7556
417a8c2
d5b3d42
6a02be4
9e2fa74
cb2dd2e
dc2428c
bc75091
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,6 +60,7 @@ import { | |
| getCodeQLMemoryLimit, | ||
| getErrorMessage, | ||
| isInTestMode, | ||
| joinAtMost, | ||
| } from "./util"; | ||
|
|
||
| export * from "./config/db-config"; | ||
|
|
@@ -958,17 +959,27 @@ export async function initConfig( | |
| // the `paths-ignore` configuration. | ||
| if ((await features.getValue(Feature.IgnoreGeneratedFiles)) && isCCR()) { | ||
| try { | ||
| const generatedFilesCheckStartedAt = performance.now(); | ||
| const generatedFiles = await getGeneratedFiles(inputs.sourceRoot); | ||
| const generatedFilesDuration = Math.round( | ||
| performance.now() - generatedFilesCheckStartedAt, | ||
| ); | ||
|
|
||
| if (generatedFiles.length > 0) { | ||
| config.computedConfig["paths-ignore"] ??= []; | ||
| config.computedConfig["paths-ignore"].push(...generatedFiles); | ||
| logger.info( | ||
| `Detected ${generatedFiles.length} generated file(s), which will be excluded from analysis: ${generatedFiles.join(", ")}`, | ||
| `Detected ${generatedFiles.length} generated file(s), which will be excluded from analysis: ${joinAtMost(generatedFiles, ", ", 10)}`, | ||
| ); | ||
| } else { | ||
| logger.info(`Found no generated files.`); | ||
| } | ||
|
|
||
| await logGeneratedFilesTelemetry( | ||
| config, | ||
| generatedFilesDuration, | ||
| generatedFiles.length, | ||
| ); | ||
| } catch (error) { | ||
| logger.info(`Cannot ignore generated files: ${getErrorMessage(error)}`); | ||
| } | ||
|
|
@@ -1413,3 +1424,32 @@ async function logGitVersionTelemetry( | |
| ); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Logs the time it took to identify generated files and how many were discovered as | ||
| * a telemetry diagnostic. | ||
| * */ | ||
| async function logGeneratedFilesTelemetry( | ||
| config: Config, | ||
| duration: number, | ||
| generatedFilesCount: number, | ||
| ): Promise<void> { | ||
| if (config.languages.length < 1) { | ||
| return; | ||
| } | ||
|
|
||
| addDiagnostic( | ||
| config, | ||
| // Arbitrarily choose the first language. We could also choose all languages, but that | ||
| // increases the risk of misinterpreting the data. | ||
|
Comment on lines
+1443
to
+1444
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is no longer arbitrary ;) |
||
| config.languages[0], | ||
| makeTelemetryDiagnostic( | ||
| "codeql-action/generated-files-telemetry", | ||
| "Generated files telemetry", | ||
| { | ||
| duration, | ||
| generatedFilesCount, | ||
| }, | ||
| ), | ||
| ); | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.