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 — Add functionality for parsing Action inputs from a workflow file by henrymercer · Pull Request #1392 · github/codeql-action

Conversation

@henrymercer

@henrymercer henrymercer commented Nov 23, 2022 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

In order to upload SARIF files for code scanning runs where the init step failed, we need to be able to handle the case where the analyze Action did not run. In this case, the post-analyze step will not be run, and therefore we don't know the inputs to analyze. (In particular, we care about category, upload, and checkout_path.)

This PR implements some functionality to make a best effort attempt to work out the value of an input to an Action given the workflow file and information that's available to the init step like matrix variables. I recommend reviewing the first commit separately since it separates out workflow-related code into a separate file workflow.ts.

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 added 5 commits November 23, 2022 19:27
@henrymercer
Refactoring: Separate out workflow related functionality
79f8286
No semantic changes.
@henrymercer
Fix a type error affecting later versions of TypeScript
996d04b
@henrymercer
Add function to read the analysis category from a workflow
e2d523c
@henrymercer
Substitute matrix variables into category input
daf4614
This is a common case, so we should handle it.
@henrymercer
Generalize getCategoryInputOrThrow to arbitrary inputs
bff0be7
@henrymercer
henrymercer marked this pull request as ready for review November 24, 2022 15:23
@henrymercer
henrymercer requested a review from a team as a code owner November 24, 2022 15:23
@henrymercer
Merge branch 'main' into henrymercer/parse-category
9f2aa7e
aeisenberg
aeisenberg reviewed Nov 25, 2022
View reviewed changes
Comment thread src/workflow.ts Resolved

Uh oh!

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

Comment thread src/workflow.ts Resolved

Uh oh!

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

@henrymercer
Filter set of possible Action inputs to those from a particular job
8f05fcd
This better handles cases where customers have a monorepo and have
separate jobs for different components.
@henrymercer
henrymercer requested a review from aeisenberg November 28, 2022 18:36
aeisenberg
aeisenberg reviewed Nov 28, 2022
View reviewed changes

@aeisenberg aeisenberg 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.

OK. This will now throw if we can't determine what the actual input value is. I don't actually see where getting the category is being used. Is that coming in a later PR? We should make sure that the action doesn't fail if it can't find the category (most likely, the action will already have failed for some other reason, so we need to at least make sure that this failure doesn't hide the original failure).

Sorry, something went wrong.

Uh oh!

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

All reactions
@henrymercer

henrymercer commented Nov 28, 2022

Copy link
Copy Markdown
Contributor Author

This functionality is just for #1393 — ideally we'd minimise the number of places where we need to do this hacky parsing of the workflow. We wrap it in a try-catch block there to avoid hiding the original failure as you mention. I think the tryOrThrow names should make it fairly obvious that these functions should generally be surrounded by try-catch blocks — is there anything else we should do to avoid future consumers creating bugs?

All reactions

Sorry, something went wrong.

Uh oh!

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

@aeisenberg

aeisenberg commented Nov 28, 2022

Copy link
Copy Markdown
Contributor

I think that all makes sense. I'll review #1393 later today. Maybe just adding a comment to the function suggesting that it should be wrapped in a try-catch.

All reactions

Sorry, something went wrong.

Uh oh!

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

aeisenberg
aeisenberg previously approved these changes Nov 28, 2022
View reviewed changes

@aeisenberg aeisenberg 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.

LGTM. Optionally, add a comment to the tryOrThrow... functions to suggest wrapping in try-catch.

Sorry, something went wrong.

Uh oh!

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

All reactions
@henrymercer
Explicitly suggest wrapping in a try/catch block
605b23d
@henrymercer
henrymercer dismissed aeisenberg’s stale review via 605b23d November 29, 2022 15:49
@henrymercer
henrymercer requested a review from aeisenberg November 29, 2022 15:49
@henrymercer henrymercer mentioned this pull request Dec 1, 2022
Submit SARIF for failed runs too #1393
Merged
3 tasks done
aeisenberg
aeisenberg approved these changes Dec 1, 2022
View reviewed changes
@henrymercer
henrymercer merged commit 0d9b15c into main Dec 1, 2022
@henrymercer
henrymercer deleted the henrymercer/parse-category branch December 1, 2022 18:26
This was referenced Dec 8, 2022
Merge main into releases/v2 #1428
Merged
Merge releases/v2 into releases/v1 #1430
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@aeisenberg aeisenberg aeisenberg 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 @aeisenberg
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.