Make getInputOrThrow throw when it can't find any calls to the Action

This created unexpected behavior with a workflow calling
`codeql-action/analyze` locally.
Therefore, be more conservative with parsing inputs from workflows and
refuse to parse jobs that don't call the specified Action exactly once.
This commit is contained in:
Henry Mercer
2022-12-06 18:13:47 +00:00
parent 9085295c40
commit 4623c8edb6
6 changed files with 39 additions and 45 deletions

6
lib/workflow.test.js generated
View File

@@ -435,7 +435,7 @@ function errorCodes(actual, expected) {
"an unrecognized dynamic value.",
});
});
(0, ava_1.default)("getCategoryInputOrThrow throws error for workflow with multiple categories", (t) => {
(0, ava_1.default)("getCategoryInputOrThrow throws error for workflow with multiple calls to analyze", (t) => {
t.throws(() => (0, workflow_1.getCategoryInputOrThrow)(yaml.load(`
jobs:
analysis:
@@ -450,8 +450,8 @@ function errorCodes(actual, expected) {
with:
category: another-category
`), "analysis", {}), {
message: "Could not get category input to github/codeql-action/analyze since there were multiple steps " +
"calling github/codeql-action/analyze with different values for category.",
message: "Could not get category input to github/codeql-action/analyze since the analysis job " +
"calls github/codeql-action/analyze multiple times.",
});
});
//# sourceMappingURL=workflow.test.js.map