diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 1734e2a..b3e8273 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -260,6 +260,23 @@ jobs: test "${{ steps.bad.outcome }}" = failure test -z "${{ steps.bad.outputs.verdict }}" + # -version exits 0 before the outputs are opened, so no report is written. + # The step must still fail rather than pass on the previous use's outputs (#407). + - name: Use the action with -version + id: version + continue-on-error: true + uses: ./ + with: + version: source + domain: lab.example + args: -version + + - name: Check it failed without a report + shell: bash + run: | + test "${{ steps.version.outcome }}" = failure + test -z "${{ steps.version.outputs.verdict }}" + # found counts the -permute hits too (#363). - name: Scan with -permute id: permute diff --git a/action.yml b/action.yml index e13d2ba..21f2b0e 100644 --- a/action.yml +++ b/action.yml @@ -171,7 +171,10 @@ runs: echo "Using the baseline an earlier step in this job saved." exit 0 fi - run=$(gh api "repos/$GITHUB_REPOSITORY/actions/artifacts?name=$NAME&per_page=1" \ + # upload-artifact allows &, +, # and % in names. Encode the name so the + # query string cannot truncate or reinterpret it (#407). + encoded=$(jq -rn --arg n "$NAME" '$n|@uri') + run=$(gh api "repos/$GITHUB_REPOSITORY/actions/artifacts?name=$encoded&per_page=1" \ --jq '.artifacts[0] | select(.expired == false) | .workflow_run.id // empty') if [ -n "$run" ]; then gh run download "$run" --repo "$GITHUB_REPOSITORY" --name "$NAME" --dir "$dir" @@ -240,7 +243,13 @@ runs: if [ "$resumed" = false ]; then subenum "${flags[@]}" "${extra[@]}" "${target[@]}" > "$out/changes.jsonl" || code=$? fi - if [ ! -s "$out/run.json" ]; then echo "::error::subenum exited $code without a report"; exit "$code"; fi + if [ ! -s "$out/run.json" ]; then + echo "::error::subenum exited $code without a report" + # -dry-run and -version exit 0 without writing a report; the step + # must still fail rather than pass on the previous use's outputs (#407). + [ "$code" -ne 0 ] || code=1 + exit "$code" + fi verdict=$(jq -r .verdict "$out/run.json") reason=$(jq -r .reason "$out/run.json")