- I want to run 3 steps, e.g. lint, type-check, unit tests.
- I want the unit tests to run even if the linting or type-checks fail, and I want the type-check to run even if the linting fails (e.g.
continue-on-error
). - If any step fails, I want the job to fail (e.g.
if: failure()
andrun: exit 1
).
The reason I want this is because I want to see a complete list of static code failures. I could separate them into individual jobs and a job dependent on their completions, but I don't need them run in parallel and it seems like a lot of wasteful repeated identical setups.
What I have so far is this:
jobs:
checks:
name: Run Checks
runs-on: ubuntu-22.04
steps:
# ... Various setup code...
- name: Lint
uses: borales/actions-yarn@v4
continue-on-error: true
with:
cmd: lint --max-warnings=0
- name: Run the type check
uses: borales/actions-yarn@v4
continue-on-error: true
with:
cmd: type-check
- name: Run the unit tests
uses: borales/actions-yarn@v4
continue-on-error: true
with:
cmd: test
- name: A step has failed
if: failure()
run: exit 1
As may be evident, this will not work. continue-on-error
means the step is never marked as a failure, and without it I never see what else is going to fail. This means I need a different approach to the pipeline configuration to achieve the outcome.
Does anyone have any recommendations?
- I want to run 3 steps, e.g. lint, type-check, unit tests.
- I want the unit tests to run even if the linting or type-checks fail, and I want the type-check to run even if the linting fails (e.g.
continue-on-error
). - If any step fails, I want the job to fail (e.g.
if: failure()
andrun: exit 1
).
The reason I want this is because I want to see a complete list of static code failures. I could separate them into individual jobs and a job dependent on their completions, but I don't need them run in parallel and it seems like a lot of wasteful repeated identical setups.
What I have so far is this:
jobs:
checks:
name: Run Checks
runs-on: ubuntu-22.04
steps:
# ... Various setup code...
- name: Lint
uses: borales/actions-yarn@v4
continue-on-error: true
with:
cmd: lint --max-warnings=0
- name: Run the type check
uses: borales/actions-yarn@v4
continue-on-error: true
with:
cmd: type-check
- name: Run the unit tests
uses: borales/actions-yarn@v4
continue-on-error: true
with:
cmd: test
- name: A step has failed
if: failure()
run: exit 1
As may be evident, this will not work. continue-on-error
means the step is never marked as a failure, and without it I never see what else is going to fail. This means I need a different approach to the pipeline configuration to achieve the outcome.
Does anyone have any recommendations?
Share Improve this question asked Mar 17 at 18:11 ShorelineShoreline 8141 gold badge11 silver badges28 bronze badges 1- 1 To rephrase, you want all steps to always run but the job only passes if all pass? – Schwern Commented Mar 17 at 18:24
1 Answer
Reset to default 2Make each check its own job, then write one job which needs
all the check jobs. All the jobs will execute in parallel (bonus, this will be faster), but the top level job will only succeed if they all succeed.
jobs:
checks:
name: Run Checks
needs: [lint, type-checks, test]
lint:
- name: Lint
uses: borales/actions-yarn@v4
with:
cmd: lint --max-warnings=0
type-checks:
- name: Run the type check
uses: borales/actions-yarn@v4
with:
cmd: type-check
test:
- name: Run the unit tests
uses: borales/actions-yarn@v4
with:
cmd: test