w3c / spec-prod

GitHub Action to build ReSpec/Bikeshed specs, validate output and publish to GitHub pages or W3C
https://w3c.github.io/spec-prod/
MIT License
34 stars 21 forks source link

Stop further execution on error #117

Closed sidvishnoi closed 2 years ago

sidvishnoi commented 3 years ago

When a step fails, the action still tries to run later steps. It should exit right away.

       [FATAL] Error: Errors found during processing.
          at run (/home/runner/work/_actions/w3c/spec-prod/v2/node_modules/respec/tools/respec2html.js:241:11)
          at processTicksAndRejections (node:internal/process/task_queues:96:5)
    Failed
  Error: Process completed with exit code 1.
  Error: w3c/spec-prod/v2/action.yml (Line: 107, Col: 24):
  Error: The template is not valid. w3c/spec-prod/v2/action.yml (Line: 107, Col: 24): Error reading JToken from JsonReader. Path '', line 0, position 0.
  Error: w3c/spec-prod/v2/action.yml (Line: 117, Col: 24):
  Error: The template is not valid. w3c/spec-prod/v2/action.yml (Line: 117, Col: 24): Error reading JToken from JsonReader. Path '', line 0, position 0.
  Error: w3c/spec-prod/v2/action.yml (Line: 127, Col: 24):
  Error: The template is not valid. w3c/spec-prod/v2/action.yml (Line: 127, Col: 24): Error reading JToken from JsonReader. Path '', line 0, position 0.
  Error: w3c/spec-prod/v2/action.yml (Line: 137, Col: 21):
  Error: The template is not valid. w3c/spec-prod/v2/action.yml (Line: 137, Col: 21): Error reading JToken from JsonReader. Path '', line 0, position 0.
  Error: w3c/spec-prod/v2/action.yml (Line: 147, Col: 24):
  Error: The template is not valid. w3c/spec-prod/v2/action.yml (Line: 147, Col: 24): Error reading JToken from JsonReader. Path '', line 0, position 0.

Ref: https://github.com/w3c/spec-prod/issues/116

jyasskin commented 2 years ago

https://docs.github.com/en/actions/creating-actions/setting-exit-codes-for-actions makes it sound like the script is returning 0 ... and since the last line of each runs step is an echo command, that seems right?

sidvishnoi commented 2 years ago

As per line 5 of output in description, the process exited with code 1. I think it might require manual use of if in each step to check previous step failure. IIRC, this started coming up when GitHub actions started supporting if in composite actions. I'll have to find some time to investigate.

Looking at sourcecode of setFailed, it's same as what we do but in different order.

sidvishnoi commented 2 years ago

since the last line of each runs step is an echo command, that seems right?

Hmm. Maybe. If yes, then a set -e in each step should stop step immediately.


Update: No. The action is running step with set -e already:

  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}