diff --git a/.github/actions/test-get-status.yml b/.github/actions/test-get-status.yml new file mode 100644 index 00000000..893a6deb --- /dev/null +++ b/.github/actions/test-get-status.yml @@ -0,0 +1,39 @@ +name: 'Test get status' +description: 'Get status of e2e workflow' + +inputs: + job_results: + description: 'JSON string of job results from needs context' + required: true + +outputs: + github_state: + description: 'GitHub API compatible state (success/failure/error/pending)' + value: ${{ steps.calculate.outputs.github_state }} + test_status: + description: 'Human-readable status (passed/failed/cancelled)' + value: ${{ steps.calculate.outputs.test_status }} + +runs: + using: 'composite' + steps: + - name: Calculate overall status + id: calculate + shell: bash + run: | + echo "Analyzing job results..." + echo "Job results JSON: ${{ inputs.job_results }}" + # Check if any job failed + if [[ "${{ contains(inputs.job_results, 'failure') }}" == "true" ]]; then + echo "github_state=failure" >> $GITHUB_OUTPUT + echo "test_status=failed" >> $GITHUB_OUTPUT + echo "Found at least one failure" + elif [[ "${{ contains(inputs.job_results, 'cancelled') }}" == "true" ]]; then + echo "github_state=error" >> $GITHUB_OUTPUT + echo "test_status=cancelled" >> $GITHUB_OUTPUT + echo "Found at least one cancelled job" + else + echo "github_state=success" >> $GITHUB_OUTPUT + echo "test_status=passed" >> $GITHUB_OUTPUT + echo "No failures found" + fi diff --git a/.github/workflows/set_status.yml b/.github/workflows/set_status.yml index 96e09ece..05594c67 100644 --- a/.github/workflows/set_status.yml +++ b/.github/workflows/set_status.yml @@ -16,7 +16,7 @@ on: type: string required: false state: - description: Check state to set + description: "Check state to set. Can be one of: error, failure, pending, success" type: string required: false default: "" @@ -33,6 +33,7 @@ jobs: if: ${{ inputs.state != '' }} run: | echo "WORKFLOW_CONCLUSION=${{ inputs.state }}" >> $GITHUB_ENV + echo "Workflow status is '${{ inputs.state }}'" - name: Set commit status in the GitHub API run: | curl -X POST \