-
Notifications
You must be signed in to change notification settings - Fork 430
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
isCCR helper, and update isDefaultSetup
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -5,6 +5,9 @@ import { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fixCodeQualityCategory, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| getPullRequestBranches, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| isAnalyzingPullRequest, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| isCCR, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| isDefaultSetup, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| isDynamicWorkflow, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } from "./actions-util"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { computeAutomationID } from "./api-client"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { EnvVar } from "./environment"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -246,3 +249,25 @@ test("fixCodeQualityCategory", (t) => { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| test("isDynamicWorkflow() returns true if event name is `dynamic`", (t) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| process.env.GITHUB_EVENT_NAME = "dynamic"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| t.assert(isDynamicWorkflow()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| process.env.GITHUB_EVENT_NAME = "push"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| t.false(isDynamicWorkflow()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| test("isCCR() returns true when expected", (t) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| process.env.GITHUB_EVENT_NAME = "dynamic"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| process.env.CODEQL_ACTION_ANALYSIS_KEY = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "dynamic/copilot-pull-request-reviewer"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| t.assert(isCCR()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| t.false(isDefaultSetup()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| test("isDefaultSetup() returns true when expected", (t) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| process.env.GITHUB_EVENT_NAME = "dynamic"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| process.env.CODEQL_ACTION_ANALYSIS_KEY = "dynamic/github-code-scanning"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| t.assert(isDefaultSetup()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| t.false(isCCR()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+254
to
+272
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| process.env.GITHUB_EVENT_NAME = "dynamic"; | |
| t.assert(isDynamicWorkflow()); | |
| process.env.GITHUB_EVENT_NAME = "push"; | |
| t.false(isDynamicWorkflow()); | |
| }); | |
| test("isCCR() returns true when expected", (t) => { | |
| process.env.GITHUB_EVENT_NAME = "dynamic"; | |
| process.env.CODEQL_ACTION_ANALYSIS_KEY = | |
| "dynamic/copilot-pull-request-reviewer"; | |
| t.assert(isCCR()); | |
| t.false(isDefaultSetup()); | |
| }); | |
| test("isDefaultSetup() returns true when expected", (t) => { | |
| process.env.GITHUB_EVENT_NAME = "dynamic"; | |
| process.env.CODEQL_ACTION_ANALYSIS_KEY = "dynamic/github-code-scanning"; | |
| t.assert(isDefaultSetup()); | |
| t.false(isCCR()); | |
| withMockedEnv( | |
| { GITHUB_EVENT_NAME: "dynamic" }, | |
| () => { | |
| t.assert(isDynamicWorkflow()); | |
| process.env.GITHUB_EVENT_NAME = "push"; | |
| t.false(isDynamicWorkflow()); | |
| }, | |
| ); | |
| }); | |
| test("isCCR() returns true when expected", (t) => { | |
| withMockedEnv( | |
| { | |
| GITHUB_EVENT_NAME: "dynamic", | |
| CODEQL_ACTION_ANALYSIS_KEY: "dynamic/copilot-pull-request-reviewer", | |
| }, | |
| () => { | |
| t.assert(isCCR()); | |
| t.false(isDefaultSetup()); | |
| }, | |
| ); | |
| }); | |
| test("isDefaultSetup() returns true when expected", (t) => { | |
| withMockedEnv( | |
| { | |
| GITHUB_EVENT_NAME: "dynamic", | |
| CODEQL_ACTION_ANALYSIS_KEY: "dynamic/github-code-scanning", | |
| }, | |
| () => { | |
| t.assert(isDefaultSetup()); | |
| t.false(isCCR()); | |
| }, | |
| ); |
Copilot
AI
Nov 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test directly modifies process.env without proper cleanup, which could cause test pollution. Consider using withMockedEnv (defined at line 30) to ensure environment variables are restored after the test, similar to how it's done in other tests in this file (e.g., lines 206-251).
| process.env.GITHUB_EVENT_NAME = "dynamic"; | |
| t.assert(isDynamicWorkflow()); | |
| process.env.GITHUB_EVENT_NAME = "push"; | |
| t.false(isDynamicWorkflow()); | |
| }); | |
| test("isCCR() returns true when expected", (t) => { | |
| process.env.GITHUB_EVENT_NAME = "dynamic"; | |
| process.env.CODEQL_ACTION_ANALYSIS_KEY = | |
| "dynamic/copilot-pull-request-reviewer"; | |
| t.assert(isCCR()); | |
| t.false(isDefaultSetup()); | |
| }); | |
| test("isDefaultSetup() returns true when expected", (t) => { | |
| process.env.GITHUB_EVENT_NAME = "dynamic"; | |
| process.env.CODEQL_ACTION_ANALYSIS_KEY = "dynamic/github-code-scanning"; | |
| t.assert(isDefaultSetup()); | |
| t.false(isCCR()); | |
| withMockedEnv( | |
| { GITHUB_EVENT_NAME: "dynamic" }, | |
| () => { | |
| t.assert(isDynamicWorkflow()); | |
| }, | |
| ); | |
| withMockedEnv( | |
| { GITHUB_EVENT_NAME: "push" }, | |
| () => { | |
| t.false(isDynamicWorkflow()); | |
| }, | |
| ); | |
| }); | |
| test("isCCR() returns true when expected", (t) => { | |
| withMockedEnv( | |
| { | |
| GITHUB_EVENT_NAME: "dynamic", | |
| CODEQL_ACTION_ANALYSIS_KEY: "dynamic/copilot-pull-request-reviewer", | |
| }, | |
| () => { | |
| t.assert(isCCR()); | |
| t.false(isDefaultSetup()); | |
| }, | |
| ); | |
| }); | |
| test("isDefaultSetup() returns true when expected", (t) => { | |
| withMockedEnv( | |
| { | |
| GITHUB_EVENT_NAME: "dynamic", | |
| CODEQL_ACTION_ANALYSIS_KEY: "dynamic/github-code-scanning", | |
| }, | |
| () => { | |
| t.assert(isDefaultSetup()); | |
| t.false(isCCR()); | |
| }, | |
| ); |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -254,7 +254,18 @@ export function isDynamicWorkflow(): boolean { | |||||||||||||||||||
|
|
||||||||||||||||||||
| /** Determines whether we are running in default setup. */ | ||||||||||||||||||||
| export function isDefaultSetup(): boolean { | ||||||||||||||||||||
| return isDynamicWorkflow(); | ||||||||||||||||||||
| return isDynamicWorkflow() && !isCCR(); | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| /** Determines whether we are running in CCR. */ | ||||||||||||||||||||
henrymercer marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||
| export function isCCR(): boolean { | ||||||||||||||||||||
|
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. What about introducing an environment variable we set in CCR, rather than relying on the analysis key?
Member
Author
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. As discussed elsewhere, that is sort of what we are doing here already (and we decide on whether are in CCR in other places in the same way currently). A better solution would be to add a new analysis kind (or similar) for CCR, but that would be more work and currently the same as I'd suggest we should stick with this for the moment (since we also use the same approach elsewhere) and look at improving it longer-term. |
||||||||||||||||||||
| return ( | ||||||||||||||||||||
| (isDynamicWorkflow() && | ||||||||||||||||||||
| process.env["CODEQL_ACTION_ANALYSIS_KEY"]?.startsWith( | ||||||||||||||||||||
| "dynamic/copilot-pull-request-reviewer", | ||||||||||||||||||||
| )) || | ||||||||||||||||||||
| false | ||||||||||||||||||||
| ); | ||||||||||||||||||||
|
Comment on lines
+262
to
+268
|
||||||||||||||||||||
| return ( | |
| (isDynamicWorkflow() && | |
| process.env["CODEQL_ACTION_ANALYSIS_KEY"]?.startsWith( | |
| "dynamic/copilot-pull-request-reviewer", | |
| )) || | |
| false | |
| ); | |
| return isDynamicWorkflow() && | |
| (process.env["CODEQL_ACTION_ANALYSIS_KEY"]?.startsWith("dynamic/copilot-pull-request-reviewer") ?? false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test directly modifies
process.envwithout proper cleanup, which could cause test pollution. Consider usingwithMockedEnv(defined at line 30) to ensure environment variables are restored after the test, similar to how it's done in other tests in this file (e.g., lines 206-251).