-
Notifications
You must be signed in to change notification settings - Fork 451
Add expect-error input to force PR check green on expected failure
#1177
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
Changes from 8 commits
b7d4497
4fb1cdc
c756bae
59d39e3
f5a4ea9
14763b6
e31c33d
46f3540
3606edb
334b121
65fcacd
3d8828a
6be3892
0736537
1e1da28
66bfa45
70d3299
41f86d9
5aec66f
98d4d17
f8f36a7
b67600f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -83,9 +83,11 @@ export async function sendStatusReport( | |
| } | ||
| } | ||
|
|
||
| // REVIEW: Instead of returning the boolean and calling the method twice | ||
| // I could also update a top level variable in this file. Which is preferable? | ||
| function hasBadExpectErrorInput(): boolean { | ||
| return ( | ||
| actionsUtil.getOptionalInput("expect-error") === "true" && | ||
| actionsUtil.getOptionalInput("expect-error") !== "false" && | ||
| !actionsUtil.isAnalyzingCodeQLActionRepoOrFork() | ||
| ); | ||
| } | ||
|
|
@@ -220,11 +222,17 @@ async function run() { | |
| getActionsLogger() | ||
| ); | ||
| } | ||
| // If we did not throw an error yet here, but we expect one, throw it. | ||
| if (actionsUtil.getOptionalInput("expect-error") === "true") { | ||
| core.setFailed( | ||
| `expect-error input was set to true but no error was thrown.` | ||
| ); | ||
| } | ||
| } catch (origError) { | ||
|
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. Note that if an error isn't thrown, we need to set the job to a failure if this input is set to true. It's a little more complicated than that since I see there are two places where
Contributor
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.
I'm a little confused: if an error isn't thrown, then why do we need to set the job to a failure? In that case, the job should succeed and we want that, right? Or do you mean that if we
I'm not sure either. I can play around with it.
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.
That's what I mean. If we expect an error and there is none, then that's an error. :)
Contributor
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. I've added this logic at the end of the outer
Contributor
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. Interestingly, I found that the outer |
||
| const error = | ||
| origError instanceof Error ? origError : new Error(String(origError)); | ||
| if ( | ||
| actionsUtil.getOptionalInput("expect-error") === "false" || | ||
| actionsUtil.getOptionalInput("expect-error") !== "true" || | ||
|
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. Maybe a bad merge here?
Contributor
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. I think the failures are expected — I removed the I'll put the line back now that I have that run 👍 |
||
| hasBadExpectErrorInput() | ||
| ) { | ||
| core.setFailed(error.message); | ||
|
|
@@ -300,12 +308,7 @@ async function runWrapper() { | |
| try { | ||
| await runPromise; | ||
| } catch (error) { | ||
| if ( | ||
| actionsUtil.getOptionalInput("expect-error") === "false" || | ||
| hasBadExpectErrorInput() | ||
| ) { | ||
| core.setFailed(`analyze action failed: ${error}`); | ||
| } | ||
| core.setFailed(`analyze action failed: ${error}`); | ||
| console.log(error); | ||
| } | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.