3535 TEST_DATA_PROD_VIRTUAL_DEVICE_2_AZURE_CONNECTION : ${{secrets.TEST_DATA_PROD_VIRTUAL_DEVICE_2_AZURE_CONNECTION}}
3636 TEST_DATA_PROD_VIRTUAL_DEVICE_2_PORT_CONNECTION : ${{secrets.TEST_DATA_PROD_VIRTUAL_DEVICE_2_PORT_CONNECTION}}
3737 TEST_DATA_PROD_VIRTUAL_DEVICE_2_AWS_CONNECTION : ${{secrets.TEST_DATA_PROD_VIRTUAL_DEVICE_2_AWS_CONNECTION}}
38+ outputs :
39+ message : ${{ steps.slack_message.outputs.message }}
3840
3941 steps :
4042 - name : Check out code into the Go module directory
6567 - name : Install jq
6668 run : |
6769 sudo apt-get install jq
70+ sudo apt-get install -y libxml2-utils
6871
6972 - name : Setup Variables Files
7073 run : |
@@ -120,6 +123,25 @@ jobs:
120123 run : |
121124 go-junit-report -parser gojson -in prod_suite_all.log > prod_suite_all.xml && python3 -m junit2htmlreport prod_suite_all.xml prod_suite_all.html
122125
126+ - name : Prepare slack message
127+ id : slack_message
128+ if : always()
129+ shell : bash
130+ run : |
131+ xml_file=$(find . -type f -name '*prod_suite.xml' | head -n 1)
132+
133+ if [[ -z "$xml_file" ]]; then
134+ echo "No file ending with prod_suite.xml found."
135+ exit 1
136+ fi
137+
138+ tests=$(xmllint --xpath 'string(//testsuite/@tests)' "$xml_file")
139+ errors=$(xmllint --xpath 'string(//testsuite/@failures)' "$xml_file")
140+ message="*Results:* $((tests-errors)) Passed, $errors Errors"
141+ echo "message<<EOF" >> $GITHUB_OUTPUT
142+ echo "$message" >> $GITHUB_OUTPUT
143+ echo "EOF" >> $GITHUB_OUTPUT
144+
123145 - name : Upload HTML Testing Report
124146 uses : actions/upload-artifact@v4
125147 with :
@@ -129,3 +151,21 @@ jobs:
129151
130152 - name : Check if Tests are passed
131153 run : sh scripts/check_tests.sh *suite_all.log
154+
155+ - name : Notify Slack
156+ uses : slackapi/slack-github-action@v2
157+ if : always()
158+ with :
159+ method : chat.postMessage
160+ token : ${{ secrets.SLACK_ACCESS_TOKEN }}
161+ payload : |
162+ channel: digin-panthers-gha-automation
163+
164+ attachments:
165+ - color: ${{ job.status == 'success' && 'good' || job.status == 'failure' && 'danger' || 'warning' }}
166+ text: |
167+ *Repository:* <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|${{ github.repository }}>
168+ *Workflow:* ${{ github.workflow }}
169+ *Status:* ${{ job.status }}
170+ *Results:* ${{ steps.slack_message.outputs.message }}
171+ *Triggered by:* <@${{ github.actor }}>
0 commit comments