Repository navigation
Expand file tree
/
Copy pathaction.yaml
More file actions
233 lines (222 loc) · 7.67 KB
/
Copy pathaction.yaml
File metadata and controls
233 lines (222 loc) · 7.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
name: 'generate_report'
description: 'Appends data to the job_status'
inputs:
prefix:
type: string
required: true
description: 'Prefix for the testplan artifact name'
slack_webhook:
type: string
required: true
description: 'URL for the channel web hook, see https://api.slack.com/apps/A04CAPK58G0/incoming-webhooks?'
title:
type: string
required: false
description: 'Title of the job'
default: 'default'
compact:
type: boolean
required: false
description: 'Generate compact slack message'
default: false
debug:
type: boolean
description: 'Enable debugging'
default: false
required: false
outputs:
overall_status:
description: 'Overall status of the tests'
value: ${{ steps.process_slack.outputs.overall_status_plain }}
cache_objects:
description: 'List of cached objects collected by append_report'
value: ${{ steps.cache_list.outputs.cache_objects }}
runs:
using: "composite"
steps:
- name: 'Consolidate testplan artifacts'
uses: 'OXID-eSales/github-actions/consolidate_artifacts@v5'
with:
target: 'testplan-${{inputs.prefix}}'
pattern: 'testplan-${{inputs.prefix}}-[0-9]*'
- name: 'Process job results for slack'
id: process_slack
shell: bash
run: |
# generate_report: Process job results for slack
COMPACT_FILE="compact_slack_report.md"
SKIPPED_EMOJI=':white_circle:'
SUCCESS_EMOJI=':white_check_mark:'
CANCELLED_EMOJI=':black_circle:'
FAILURE_EMOJI=':x:'
STATUS=(skipped success cancelled failure)
CUMULATED=0
OVERALL=0
LAST_GROUP=''
TEST_FILES=$(find job_status/ -type f -iname "*.txt"|sort)
mkdir -p slack_reports compact_slack_reports
for FILE in ${TEST_FILES}; do
F=$(echo "${FILE}" | sed -e 's|^.*job_status/||' -e 's|\.txt$ ||')
IFS='-' read -r -a PARTS <<< "${F}"
PRIORITY="${PARTS[0]}"
PHASE="${PARTS[1]}"
JOB="${PARTS[2]}"
TITLE="${PARTS[3]}"
MATRIX="${PARTS[4]}"
if [ "${PRIORITY}-${PHASE}-${JOB}-${TITLE}" != "${LAST_GROUP}" ]; then
if [ -n "${LAST_GROUP}" ]; then
SLACK_FILE="slack_reports/${LAST_GROUP}.md"
SUMMARY_STATUS="${STATUS[CUMULATED]}"
SUMMARY_EMOJI="${SUMMARY_STATUS^^}_EMOJI"
echo -ne " :arrow_right: *${SUMMARY_STATUS}* ${!SUMMARY_EMOJI}\n" >>"${SLACK_FILE}"
CUMULATED=0
fi
LAST_GROUP="${PRIORITY}-${PHASE}-${JOB}-${TITLE}"
fi
VALUE=$(head -n 1 "${FILE}")
case ${VALUE} in
skipped) SNUM=0 ;;
success) SNUM=1 ;;
cancelled) SNUM=2 ;;
*) SNUM=3 ;;
esac
if [ ${SNUM} -gt ${CUMULATED} ]; then
CUMULATED=$SNUM
fi
if [ ${SNUM} -gt ${OVERALL} ]; then
OVERALL=$SNUM
fi
JOB_EMOJI="${VALUE^^}_EMOJI"
SLACK_FILE="slack_reports/${LAST_GROUP}.md"
if [ ! -f "${SLACK_FILE}" ]; then
echo -n "- ${PHASE}/${JOB}: ${TITLE} " >"${SLACK_FILE}"
fi
echo -n "${!JOB_EMOJI} " >>"${SLACK_FILE}"
echo -n "${!JOB_EMOJI}" >>"${COMPACT_FILE}"
done
SLACK_FILE="slack_reports/${PRIORITY}-${PHASE}-${JOB}.md"
SUMMARY_STATUS="${STATUS[CUMULATED]}"
SUMMARY_EMOJI="${SUMMARY_STATUS^^}_EMOJI"
echo -ne " :arrow_right: *${SUMMARY_STATUS}* ${!SUMMARY_EMOJI}\n" >>"${SLACK_FILE}"
OVERALL_STATUS="${STATUS[OVERALL]}"
OVERALL_EMOJI="${OVERALL_STATUS^^}_EMOJI"
echo "overall_status=${!OVERALL_EMOJI} ${OVERALL_STATUS}" >>"${GITHUB_OUTPUT}"
echo "overall_status_plain=${OVERALL_STATUS}" >>"${GITHUB_OUTPUT}"
- name: 'Output reports'
shell: bash
run: |
# generate_report: Output reports
for FILE in $(find reports -type f|sort); do
cat "${FILE}" >>github_report.md
done
cat github_report.md >>"${GITHUB_STEP_SUMMARY}"
GROUPLIST=""
for FILE in $(find slack_reports -type f|sort); do
GROUP=$(echo "${FILE}"|sed -e 's|\..*$||'|awk -F '-' '{print $2}')
if [[ "${GROUPLIST}" != *"${GROUP}"* ]]; then
GROUPLIST="${GROUPLIST} ${GROUP}"
fi
cat "${FILE}" >>"slack_report-${GROUP}.md"
done
TITLE='${{inputs.title}} ${{ steps.process_slack.outputs.overall_status}}'
if [ '${{ inputs.compact }}' == 'false' ]; then
cat >slack.json <<EOF
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"emoji": true,
"text": "${TITLE:0:150}"
}
}
EOF
for GROUP in ${GROUPLIST}; do
MARKDOWN=$(cat "slack_report-${GROUP}.md"|sed 's/$/\\n/g' | tr -d '\n')
cat >>slack.json <<EOF
,
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "${MARKDOWN}"
}
},
{
"type": "divider"
}
EOF
done
cat >>slack.json <<EOF
]
}
EOF
else
echo -n ':arrow_right:${{ steps.process_slack.outputs.overall_status}}' >>compact_slack_report.md
MARKDOWN=$(cat "compact_slack_report.md" | tr -d '\n')
cat >slack.json <<EOF
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "${MARKDOWN}"
}
},
{
"type": "divider"
}
]
}
EOF
fi
- name: 'Generate cache objects list'
id: cache_list
shell: bash
run: |
# generate_report: Generate cache list
FILES=$(find caches -iname '*.txt')
if [ -n "${FILES}" ]; then
echo "cache_objects<<EOF" | tee -a "${GITHUB_OUTPUT}"
cat caches/*.txt | tee -a "${GITHUB_OUTPUT}"
echo "EOF" | tee -a "${GITHUB_OUTPUT}"
else
echo "cache_objects=" | tee -a "${GITHUB_OUTPUT}"
fi
- name: 'Generate debug script'
if: ${{ inputs.debug == 'true' }}
shell: bash
run: |
MATRIX=$(find . -type d -iname 'debug-*')
for SCRIPT in ${MATRIX}; do
cp debug/000-start.sh "${SCRIPT}.sh"
cp debug/999-end.sh "${SCRIPT}.end"
FILES=$(find "${SCRIPT}" -type f -iname "*.sh"|sort)
for FILE in ${FILES}; do
JOBNAME=$(basename "${FILE}" '.sh')
sed -e 's|^[[:space:]]*EOF|EOF|' \
-e 's|###END_DEBUG||' \
-e 's|/home/runner/work/_temp/_runner_file_commands/set_env.*|${GITHUB_ENV}|g' \
-e 's|/home/runner/work/_temp/_runner_file_commands/set_output.*|${GITHUB_OUTPUT}|g' \
"${FILE}" >>"${SCRIPT}.sh"
echo "${JOBNAME}" >>"${SCRIPT}.end"
done
cat "${SCRIPT}.end" >>"${SCRIPT}.sh"
rm "${SCRIPT}.end"
chmod 0755 "${SCRIPT}.sh"
done
- name: 'Send custom JSON data to Slack workflow'
if: ${{ inputs.slack_webhook != '' }}
uses: 'slackapi/slack-github-action@v1'
with:
payload-file-path: 'slack.json'
env:
SLACK_WEBHOOK_URL: ${{ inputs.slack_webhook }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
- name: 'Update testplan artifacts'
uses: 'OXID-eSales/github-actions/consolidate_artifacts@v5'
with:
target: 'testplan-${{inputs.prefix}}'
pattern: 'testplan-${{inputs.prefix}}-[0-9]*'