-
Notifications
You must be signed in to change notification settings - Fork 329
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
Add expect-error
input to force PR check green on expected failure
#1177
Changes from 2 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 |
---|---|---|
|
@@ -183,7 +183,10 @@ async function run() { | |
} catch (origError) { | ||
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 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. 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. :) 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 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)); | ||
core.setFailed(error.message); | ||
if (!actionsUtil.getOptionalInput("expect-error")) { | ||
core.setFailed(error.message); | ||
} | ||
|
||
console.log(error); | ||
|
||
if (error instanceof CodeQLAnalysisError) { | ||
|
@@ -214,7 +217,9 @@ async function runWrapper() { | |
try { | ||
await runPromise; | ||
} catch (error) { | ||
core.setFailed(`analyze action failed: ${error}`); | ||
if (!actionsUtil.getOptionalInput("expect-error")) { | ||
core.setFailed(`analyze action failed: ${error}`); | ||
} | ||
console.log(error); | ||
} | ||
} | ||
|
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.
May need to make this more descriptive so that our users don't set this to
true
when they don't mean to? I don't think I see ahidden
option for input parameters.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.
How about this?
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.
Hm, this caused some failures — I wonder if the bracket symbols aren't able to be parsed correctly.
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 adding double quotes around it resolved it.
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.
Consider throwing an error inside the code if this is set but the repo is not
github/codeql-action
or a fork. (You should be able to get that information from the Actions event context.)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've added this code — still doing a final test of: