16

When running a GitHub Actions matrix workflow, how can we allow a job to fail, continue running all the other jobs, and also mark the workflow itself as failed?

Below in this image, you can see that the workflow passes even after a job failed. We need to mark the workflow as failed in this case.

Image of our workflow results

Here is the small portion of my workflow yaml file. continue-on-error line will continue the workflow even if a job fails but how do we get the whole workflow marked as failed?

   matrixed:
    runs-on: ubuntu-latest
    continue-on-error: true  
    timeout-minutes: 60
    defaults:
      run:
        shell: bash
        working-directory: myDir

    strategy:
      matrix:
        testgroups:
          [
            "bookingpage-docker-hub-parallel",
            "bookingpage-docker-hub-parallel-group-1",
            "bookingpage-payments",
          ]

I did find this unanswered question, but this is about steps and we need to know about jobs.

riQQ
  • 9,878
  • 7
  • 49
  • 66
Abilash CS
  • 163
  • 1
  • 5

1 Answers1

13

Use fail-fast: false for the strategy and don't set continue-on-error on the job.

  matrixed:
    runs-on: ubuntu-latest
    timeout-minutes: 60
    defaults:
      run:
        shell: bash
        working-directory: myDir

    strategy:
      fail-fast: false
      matrix:
        testgroups:
          [
            "bookingpage-docker-hub-parallel",
            "bookingpage-docker-hub-parallel-group-1",
            "bookingpage-payments",
          ]
riQQ
  • 9,878
  • 7
  • 49
  • 66
  • 1
    Thanks for your answer @riQQ . So, the problem is because of continue-on-error. This line is making the whole workflow as passed even if a single job passes. – Abilash CS Jan 25 '22 at 06:14