-
Notifications
You must be signed in to change notification settings - Fork 335
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
Warn when workflow analyzes the same language twice #1901
Conversation
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.
Good idea. A few minor questions.
if ( | ||
!(await sendStatusReport( | ||
await createStatusReportBase( | ||
"init", | ||
"starting", | ||
startedAt, | ||
await checkDiskUsage(logger), | ||
workflowErrors, |
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 change means all workflow errors will be reported as Actions errors, but not part of the starting
status report, right?
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.
That's right. This improves consistency since we're using the error
and cause
fields of the status report to indicate errors, rather than sometimes errors and sometimes warnings. I think if we want to collect workflow validation warnings, it would be more appropriate to add a new field.
src/workflow.ts
Outdated
const matrixLanguagesByExtractor: { | ||
[extractorName: string]: string[]; | ||
} = {}; | ||
for (const language of matrixLanguages) { | ||
const extractorName = aliases[language] || language; | ||
if (!matrixLanguagesByExtractor[extractorName]) { | ||
matrixLanguagesByExtractor[extractorName] = []; | ||
} | ||
matrixLanguagesByExtractor[extractorName].push(language); | ||
} |
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.
I think this could usefully be pulled out into a groupLanguagesByExtractorName
helper.
message: | ||
`CodeQL language '${extractor}' is referenced by more than one entry in the ` + | ||
`'language' matrix parameter for job '${jobName}'. This may result in duplicate alerts. ` + | ||
`Please edit the 'language' matrix parameter to keep only one of the following: ${languages | ||
.map((language) => `'${language}'`) | ||
.join(", ")}.`, |
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.
Perhaps add a phrase like "these language names are considered identical by CodeQL". Do we want to recommend they use the combined alias key in this situation?
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.
The tricky thing is that the CLI doesn't really have a notion of the combined alias as the preferred name, since to reduce risk we did not change the name
s of the CodeQL extractors. I think we're going to hit this warning rarely enough that it's not worth hardcoding the language-specific information into the Action, but I don't feel strongly about this — feel free to convince me otherwise!
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.
Makes sense. We can introduce later a concept of "recommended name" if we want to do this, agree it's not urgent.
src/workflow.test.ts
Outdated
|
||
t.deepEqual(...errorCodes(errors, [WorkflowErrors.CheckoutWrongHead])); | ||
}); | ||
|
||
test("getWorkflowErrors() for workflow with language name and its alias", async (t) => { |
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.
Just to be sure, have we got a test for two unrelated languages?
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.
Good idea, let's add one.
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.
Optionally consider a changenote.
With the introduction of new aliases for C/C++, Java/Kotlin, and JavaScript/TypeScript, we want to avoid customers analyzing the same language more than once. The most common case of this will likely be customers who have started with a starter workflow and have added a duplicate language to the
language
matrix parameter.This PR introduces workflow validation for this common case, so that customers who are analyzing the same language twice will get an Actions warning when they execute that workflow.
Merge / deployment checklist