Skip to content

Commit 1ca8d14

Browse files
authored
[SDPTA-1431] Improve log for set status (#72)
* [SDPTA-1431] Improve log for set status * Add get status actions * Fix indentation in test-get-status.yml
1 parent cbf96d7 commit 1ca8d14

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: 'Test get status'
2+
description: 'Get status of e2e workflow'
3+
4+
inputs:
5+
job_results:
6+
description: 'JSON string of job results from needs context'
7+
required: true
8+
9+
outputs:
10+
github_state:
11+
description: 'GitHub API compatible state (success/failure/error/pending)'
12+
value: ${{ steps.calculate.outputs.github_state }}
13+
test_status:
14+
description: 'Human-readable status (passed/failed/cancelled)'
15+
value: ${{ steps.calculate.outputs.test_status }}
16+
17+
runs:
18+
using: 'composite'
19+
steps:
20+
- name: Calculate overall status
21+
id: calculate
22+
shell: bash
23+
run: |
24+
echo "Analyzing job results..."
25+
echo "Job results JSON: ${{ inputs.job_results }}"
26+
# Check if any job failed
27+
if [[ "${{ contains(inputs.job_results, 'failure') }}" == "true" ]]; then
28+
echo "github_state=failure" >> $GITHUB_OUTPUT
29+
echo "test_status=failed" >> $GITHUB_OUTPUT
30+
echo "Found at least one failure"
31+
elif [[ "${{ contains(inputs.job_results, 'cancelled') }}" == "true" ]]; then
32+
echo "github_state=error" >> $GITHUB_OUTPUT
33+
echo "test_status=cancelled" >> $GITHUB_OUTPUT
34+
echo "Found at least one cancelled job"
35+
else
36+
echo "github_state=success" >> $GITHUB_OUTPUT
37+
echo "test_status=passed" >> $GITHUB_OUTPUT
38+
echo "No failures found"
39+
fi

.github/workflows/set_status.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ on:
1616
type: string
1717
required: false
1818
state:
19-
description: Check state to set
19+
description: "Check state to set. Can be one of: error, failure, pending, success"
2020
type: string
2121
required: false
2222
default: ""
@@ -33,6 +33,7 @@ jobs:
3333
if: ${{ inputs.state != '' }}
3434
run: |
3535
echo "WORKFLOW_CONCLUSION=${{ inputs.state }}" >> $GITHUB_ENV
36+
echo "Workflow status is '${{ inputs.state }}'"
3637
- name: Set commit status in the GitHub API
3738
run: |
3839
curl -X POST \

0 commit comments

Comments
 (0)