GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Warn when workflow analyzes the same language twice by henrymercer · Pull Request #1901 · github/codeql-action

Conversation

@henrymercer

@henrymercer henrymercer commented Sep 22, 2023

Copy link
Copy Markdown
Contributor

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

  • Confirm this change is backwards compatible with existing workflows.
  • Confirm the readme has been updated if necessary.
  • Confirm the changelog has been updated if necessary.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@henrymercer
Warn when workflow analyzes the same language twice
d0c18ba
@henrymercer
henrymercer requested a review from a team as a code owner September 22, 2023 14:11
adityasharad
adityasharad reviewed Sep 22, 2023
View reviewed changes

@adityasharad adityasharad left a comment

Copy link
Copy Markdown
Contributor

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/init-action.ts
"starting",
startedAt,
await checkDiskUsage(logger),
workflowErrors,

@adityasharad adityasharad Sep 22, 2023

Copy link
Copy Markdown
Contributor

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?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@henrymercer henrymercer Sep 22, 2023

Copy link
Copy Markdown
Contributor Author

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

adityasharad reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread src/workflow.ts Outdated
Comment on lines +128 to +137
const matrixLanguagesByExtractor: {
[extractorName: string]: string[];
} = {};
for (const language of matrixLanguages) {
const extractorName = aliases[language] || language;
if (!matrixLanguagesByExtractor[extractorName]) {
matrixLanguagesByExtractor[extractorName] = [];
}
matrixLanguagesByExtractor[extractorName].push(language);
}

@adityasharad adityasharad Sep 22, 2023

Copy link
Copy Markdown
Contributor

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

henrymercer reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread src/workflow.ts
Comment on lines +145 to +150
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(", ")}.`,

@adityasharad adityasharad Sep 22, 2023

Copy link
Copy Markdown
Contributor

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?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@henrymercer henrymercer Sep 22, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

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 names 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!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@adityasharad adityasharad Sep 22, 2023

Copy link
Copy Markdown
Contributor

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/workflow.test.ts Outdated
t.deepEqual(...errorCodes(errors, [WorkflowErrors.CheckoutWrongHead]));
});

test("getWorkflowErrors() for workflow with language name and its alias", async (t) => {

@adityasharad adityasharad Sep 22, 2023

Copy link
Copy Markdown
Contributor

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?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@henrymercer henrymercer Sep 22, 2023

Copy link
Copy Markdown
Contributor Author

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
henrymercer added 2 commits September 22, 2023 18:55
@henrymercer
Factor out groupLanguagesByExtractor
431174f
@henrymercer
Test that workflow with two different languages doesn't produce an error
d1a917f
adityasharad
adityasharad previously approved these changes Sep 22, 2023
View reviewed changes

@adityasharad adityasharad left a comment

Copy link
Copy Markdown
Contributor

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@henrymercer
Add a changelog note
0dfaf4e
@henrymercer
henrymercer dismissed adityasharad’s stale review via 0dfaf4e September 22, 2023 18:14
@henrymercer
Merge branch 'main' into henrymercer/check-for-duplicated-languages
0de36d4
adityasharad
adityasharad approved these changes Sep 22, 2023
View reviewed changes
@henrymercer
henrymercer merged commit 650a85e into main Sep 25, 2023
@henrymercer
henrymercer deleted the henrymercer/check-for-duplicated-languages branch September 25, 2023 13:25
@github-actions github-actions Bot mentioned this pull request Sep 27, 2023
Merge main into releases/v2 #1905
Merged
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@adityasharad adityasharad adityasharad approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@henrymercer @adityasharad
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.