Skip to content

Commit

Permalink
Coerce matrix.continue-on-error to bool in CI workflow
Browse files Browse the repository at this point in the history
Since the `matrix.continue-on-error` setting is only ever defined for
nightly Rust build jobs, all other jobs will trigger a CI error if they
fail:

```
Error: Process completed with exit code 101.
Error: .github/workflows/rust.yml (Line: 31, Col: 26): Unexpected value ''
Error: The step failed and an error occurred when attempting to determine whether to continue on error.
Error: The template is not valid. .github/workflows/rust.yml (Line: 31, Col: 26): Unexpected value ''
```

The output above indicates that `matrix.continue-on-error` defaults to
an empty string if it's not explicitly defined for the current job in
the matrix. The `continue-on-error: ${{ matrix.continue-on-error }}`
evaluation then fails due to expecting a `bool` value.

I've tried specifying a default value of `continue-on-error: [false]` in
the matrix, but attempting to override this default setting using
`include` just creates more build jobs with `continue-on-error: true`
instead of overriding the setting for the existing ones, which isn't
what we want.

The solution I found was to append `|| false` to the end, which coerces
the type to `false` if the setting is undefined for the current job.
This suppresses the error message and produces the original expected
behavior.
  • Loading branch information
ebkalderon committed Jun 12, 2021
1 parent 0c9fe15 commit 8f0e510
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ jobs:
rustup component add rustfmt
cargo fmt --all -- --check
- name: Build
continue-on-error: ${{ matrix.continue-on-error }}
continue-on-error: ${{ matrix.continue-on-error || false }}
run: cargo build --all --verbose
- name: Run tests
continue-on-error: ${{ matrix.continue-on-error }}
continue-on-error: ${{ matrix.continue-on-error || false }}
run: cargo test --all --verbose

0 comments on commit 8f0e510

Please sign in to comment.