Skip to content

Commit c8ac32b

Browse files
Created Actions for Discord Summary.
1 parent ad65786 commit c8ac32b

2 files changed

Lines changed: 61 additions & 29 deletions

File tree

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: "Send Test Summary to Discord"
2+
description: "Send formatted test summary to Discord"
3+
inputs:
4+
passed:
5+
required: true
6+
failed:
7+
required: true
8+
skipped:
9+
required: true
10+
total:
11+
required: true
12+
browser:
13+
required: true
14+
runs:
15+
using: "composite"
16+
steps:
17+
- name: Build and Send Discord Message
18+
shell: bash
19+
run: |
20+
pass_percentage=$(awk "BEGIN {print (${{ inputs.passed }}/${{ inputs.total }})*100}")
21+
fail_percentage=$(awk "BEGIN {print (${{ inputs.failed }}/${{ inputs.total }})*100}")
22+
23+
content="-----------------------------------\n\n"
24+
content+="🛠️ **Job: ${{ github.job }}**\n"
25+
content+="👤 **User: ${{ github.actor }}**\n"
26+
content+="🌎 **Browser: ${{ inputs.browser }}**\n"
27+
content+="🎉 **Passed**: ${{ inputs.passed }}\n"
28+
content+="❌ **Failed**: ${{ inputs.failed }}\n"
29+
content+="⚠️ **Skipped**: ${{ inputs.skipped }}\n"
30+
content+="📊 **Total**: ${{ inputs.total }}\n\n"
31+
content+="✅ **Pass %**: ${pass_percentage}%\n"
32+
content+="❌ **Fail %**: ${fail_percentage}%\n\n"
33+
content+="-----------------------------------\n\n"
34+
35+
curl --location "$DISCORD_WEBHOOK_URL" \
36+
--header 'Content-Type: application/json' \
37+
--data-raw "{
38+
\"content\": \"$content\",
39+
\"username\": \"TestBot\"
40+
}"

.github/workflows/ci.yml

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,6 @@ env:
77
SWAGLABS_USERNAME: ${{ secrets.SWAGLABS_USERNAME }}
88
SWAGLABS_PASSWORD: ${{ secrets.SWAGLABS_PASSWORD }}
99
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
10-
DISCORD_SCRIPT: |
11-
passed="${{ steps.summary.outputs.passed }}"
12-
failed="${{ steps.summary.outputs.failed }}"
13-
skipped="${{ steps.summary.outputs.skipped }}"
14-
total="${{ steps.summary.outputs.total }}"
15-
pass_percentage=$(awk "BEGIN {print ($passed/$total)*100}")
16-
fail_percentage=$(awk "BEGIN {print ($failed/$total)*100}")
17-
18-
content="-----------------------------------\n\n"
19-
content+="🛠️ **Job: ${{ github.job }}**\n"
20-
content+="👤 **User: ${{ github.actor }}**\n"
21-
content+="🌎 **Browser: ${{ matrix.browser }}**\n"
22-
content+="🎉 **Passed**: ${passed}\n"
23-
content+="❌ **Failed**: ${failed}\n"
24-
content+="⚠️ **Skipped**: ${skipped}\n"
25-
content+="📊 **Total**: ${total}\n\n"
26-
content+="✅ **Pass %**: ${pass_percentage}%\n"
27-
content+="❌ **Fail %**: ${fail_percentage}%\n\n"
28-
content+="-----------------------------------\n\n"
29-
30-
curl --location "$DISCORD_WEBHOOK_URL" \
31-
--header 'Content-Type: application/json' \
32-
--data-raw "{
33-
\"content\": \"$content\",
34-
\"username\": \"TestBot\"
35-
}"
3610

3711
on:
3812
workflow_dispatch:
@@ -168,7 +142,13 @@ jobs:
168142
if: always()
169143

170144
- name: Send Results to Discord
171-
run: $DISCORD_SCRIPT
145+
uses: ./.github/actions/discord-summary
146+
with:
147+
passed: ${{ steps.summary.outputs.passed }}
148+
failed: ${{ steps.summary.outputs.failed }}
149+
skipped: ${{ steps.summary.outputs.skipped }}
150+
total: ${{ steps.summary.outputs.total }}
151+
browser: ${{ matrix.browser }}
172152

173153
regression_tests:
174154
name: Run Regression Tests
@@ -215,7 +195,13 @@ jobs:
215195
if: always()
216196

217197
- name: Send Results to Discord
218-
run: $DISCORD_SCRIPT
198+
uses: ./.github/actions/discord-summary
199+
with:
200+
passed: ${{ steps.summary.outputs.passed }}
201+
failed: ${{ steps.summary.outputs.failed }}
202+
skipped: ${{ steps.summary.outputs.skipped }}
203+
total: ${{ steps.summary.outputs.total }}
204+
browser: ${{ matrix.browser }}
219205

220206
e2e_tests:
221207
name: Run E2E Tests
@@ -266,4 +252,10 @@ jobs:
266252
if: always()
267253

268254
- name: Send Results to Discord
269-
run: $DISCORD_SCRIPT
255+
uses: ./.github/actions/discord-summary
256+
with:
257+
passed: ${{ steps.summary.outputs.passed }}
258+
failed: ${{ steps.summary.outputs.failed }}
259+
skipped: ${{ steps.summary.outputs.skipped }}
260+
total: ${{ steps.summary.outputs.total }}
261+
browser: ${{ matrix.browser }}

0 commit comments

Comments
 (0)