FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Do not warn users if a workflow cannot be read by simon-engledew · Pull Request #370 · github/codeql-action · GitHub

Do not warn users if a workflow cannot be read - #370

Merged
simon-engledew merged 6 commits into
mainfrom
simon-engledew/hide-workflow-not-found
Jan 25, 2021
Merged

simon-engledew merged 6 commits into
mainfrom
simon-engledew/hide-workflow-not-found

Conversation

Copy link
Copy Markdown

Hide these warnings:

This will still send a LintFailed message status report.

Copy link
Copy Markdown
Contributor

This will still send a LintFailed message status report.

I don't think this will send a LintFailed message status report. If getWorkflow returns undefined then it does nothing. You want to change getWorkflowErrors to do

if (workflow === undefined) {
  return [WorkflowErrors.LintFailed];
}

Ideally we'd also have different kinds of LintFailed so we can tell between errors in the workflow and failing to read the workflow.

Copy link
Copy Markdown
Contributor

I agree this will silence the error message. Up to you if you want to also upload the failure message in the status report or just leave it.

robertbrignull self-assigned this Jan 21, 2021
simon-engledew force-pushed the simon-engledew/hide-workflow-not-found branch 3 times, most recently from 6b04c71 to 483255c Compare January 22, 2021 09:22

Copy link
Copy Markdown
Author

I don't think this will send a LintFailed message status report. If getWorkflow returns undefined then it does nothing.

Ugh, sorry - quite right. I should have actually checked this. 🤦 🙇

I've had a bit of a refactor and tweaked the way we report errors to include the exception string if something failed during linting

robertbrignull left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

One suggestion about a try-catch but LGTM regardless

Comment thread src/actions-util.ts Outdated
}
} catch (e) {
return [WorkflowErrors.LintFailed];
return `error: getWorkflow() failed: ${e.toString()}`;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

To avoid this try-catch covering more than necessary you could do

let workflow: Workflow;
try {
  workflow = await getWorkflow();
} catch (e) {
  return `error: getWorkflow() failed: ${e.toString()}`;
}

and that way you can assign a variable to a non-nullable type but have the try-catch be more contained so it's easier to read and you won't unexpectedly catch something you didn't mean to.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Oh, it's nice that the type checker is sophisticated enough to realise that the variable is not nullable!

I've used that technique to add more fine grained handling over the whole function, thanks! 👍

simon-engledew force-pushed the simon-engledew/hide-workflow-not-found branch from d947456 to fed7a74 Compare January 22, 2021 10:59
simon-engledew force-pushed the simon-engledew/hide-workflow-not-found branch from b3f3e39 to 6be1f5c Compare January 22, 2021 13:52
simon-engledew force-pushed the simon-engledew/hide-workflow-not-found branch from 3c9fbc6 to ee4d067 Compare January 22, 2021 14:08
simon-engledew merged commit 7a340d3 into main Jan 25, 2021
simon-engledew deleted the simon-engledew/hide-workflow-not-found branch January 25, 2021 09:21
github-actions Bot mentioned this pull request Jan 25, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL