Abilash CS
Abilash CS

Reputation: 193

Marking GitHub actions workflow as failed if a single job fails in matrix

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.

Upvotes: 19

Views: 9952

Answers (1)

riQQ
riQQ

Reputation: 12693

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",
          ]

Upvotes: 22

Related Questions