Skip to content

Commit

Permalink
Fix "last step wins" error (#132)
Browse files Browse the repository at this point in the history
* Add a test case that has a pinned action after an un-pinned one

Whether the job fails or not was being overwritten by the last step in
the job. If the last step is pinned, this would cause the check to
pass, even if an earlier step was unpinned. Now we have a test case that
exercises this functionality.

* Fail the job if any steps have errors

Previously this logic only failed the job if the last step had an error.

* Run npm prepare

---------

Co-authored-by: Zennon Gosalvez <1798166+zgosalvez@users.noreply.github.com>
  • Loading branch information
wadells and zgosalvez committed Dec 3, 2023
1 parent 0cee947 commit b1b635d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ async function run() {
jobHasError = runAssertions(uses, allowlist, isDryRun);
} else if (steps !== undefined) {
for (const step of steps) {
jobHasError = runAssertions(step['uses'], allowlist, isDryRun);
jobHasError ||= runAssertions(step['uses'], allowlist, isDryRun);
}
} else {
core.warning(`The "${job}" job of the "${basename}" workflow does not contain uses or steps.`);
Expand Down
5 changes: 5 additions & 0 deletions test/stub/unpinned/file.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,8 @@ jobs:
steps:
- uses: docker://rhysd/actionlint:latest
- uses: docker://rhysd/actionlint:1.6.22
mixedstub:
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f

0 comments on commit b1b635d

Please sign in to comment.