From cfca67da915bc70073a9fe67dac416839cb10e42 Mon Sep 17 00:00:00 2001 From: Tim Yao <31641325+tim-yao@users.noreply.github.com> Date: Mon, 8 Sep 2025 17:40:33 +1000 Subject: [PATCH 1/4] [SDPTA-1431] Improve log for set status --- .github/workflows/set_status.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 \ From 2092359956b9f1af4f712567cc7af692a83aeb26 Mon Sep 17 00:00:00 2001 From: Tim Yao <31641325+tim-yao@users.noreply.github.com> Date: Mon, 8 Sep 2025 20:12:26 +1000 Subject: [PATCH 2/4] Add get status actions --- .github/actions/test-get-status.yml | 39 +++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/actions/test-get-status.yml diff --git a/.github/actions/test-get-status.yml b/.github/actions/test-get-status.yml new file mode 100644 index 00000000..b41faa43 --- /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(toJSON(needs.*.result), 'failure') }}" == "true" ]]; then + echo "github_state=failure" >> $GITHUB_OUTPUT + echo "test_status=failed" >> $GITHUB_OUTPUT + echo "Found at least one failure" + elif [[ "${{ contains(toJSON(needs.*.result), '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 From a48d62bc9caa94a59767372a4d6966979daa7266 Mon Sep 17 00:00:00 2001 From: Tim Yao <31641325+tim-yao@users.noreply.github.com> Date: Tue, 9 Sep 2025 10:21:29 +1000 Subject: [PATCH 3/4] Fix indentation in test-get-status.yml --- .github/actions/test-get-status.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/test-get-status.yml b/.github/actions/test-get-status.yml index b41faa43..99a13e9d 100644 --- a/.github/actions/test-get-status.yml +++ b/.github/actions/test-get-status.yml @@ -32,7 +32,7 @@ runs: echo "github_state=error" >> $GITHUB_OUTPUT echo "test_status=cancelled" >> $GITHUB_OUTPUT echo "Found at least one cancelled job" - else + else echo "github_state=success" >> $GITHUB_OUTPUT echo "test_status=passed" >> $GITHUB_OUTPUT echo "No failures found" From 6ae5064929c440485fecf31080e0e74bba8e8e0c Mon Sep 17 00:00:00 2001 From: Tim Yao <31641325+tim-yao@users.noreply.github.com> Date: Tue, 9 Sep 2025 10:23:08 +1000 Subject: [PATCH 4/4] Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/actions/test-get-status.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/actions/test-get-status.yml b/.github/actions/test-get-status.yml index 99a13e9d..893a6deb 100644 --- a/.github/actions/test-get-status.yml +++ b/.github/actions/test-get-status.yml @@ -24,11 +24,11 @@ runs: echo "Analyzing job results..." echo "Job results JSON: ${{ inputs.job_results }}" # Check if any job failed - if [[ "${{ contains(toJSON(needs.*.result), 'failure') }}" == "true" ]]; then + 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(toJSON(needs.*.result), 'cancelled') }}" == "true" ]]; then + 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"