Skip to content

Commit 956b568

Browse files
authored
* Update documentation (#172)
* Slight colour adjustment for partial results * Add sample test results for fail, partial, pass
1 parent 9a73848 commit 956b568

15 files changed

+62
-9
lines changed

scripts/integrations/slack/README.md

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,27 @@ The Slack integration is designed to notify outcome teams of post-deployment tes
99
* **Modularity** The notification script is designed as a reusable component, allowing for easy updates to message formats without modifying the core pipeline logic.
1010
* **Error Handling** The scripts handle basic scenarios such as lack of required parameters like the webhook URL, or if test result parsing fails.
1111

12+
## Message Styles for Test Results
13+
14+
This integration script generates the following style of notification messages:
15+
16+
**Full Pass Rate**
17+
All tests have passed based on test results.
18+
19+
![Tests are successful](./assets/Message_Success.jpg)
20+
21+
22+
**Partial Pass Rate**
23+
_Some_ tests failed or raised warnings. Please click the build link to navigate to the build details.
24+
25+
![Tests are partial](./Message_Partial.jpg)
26+
27+
28+
29+
**Failure**
30+
_All_ tests failed or raised warnings. Please click the build link to navigate to the build details.
31+
32+
![Tests failed](./Message_Failed.jpg)
1233

1334
## Set Up the Slack App
1435

@@ -44,19 +65,19 @@ settings:
4465
org_deploy_enabled: false
4566
socket_mode_enabled: false
4667
token_rotation_enabled: false
47-
4868
```
69+
4970
5. In the _Review summary & create your app_, click **Create**.
5071
5. You will now be navigated to the application configuration.
51-
![alt text](image.png)
72+
![App Credentials](./assets/Setup-1.png)
5273
5. Record all the entires for `App ID`, `Client ID`, `Client Secret`, `Signing Secret`, `Verification Token` etc.
5374
5. Navigate to **Incoming Webhooks** and enable the toggle **Activate Incoming Webhooks**.
54-
![alt text](image-1.png)
75+
![Activate Webhooks](./assets/Setup-2.png)
5576
5. Scroll down the page to create a webhook endpoint.
5677
5. Click on **Add new webhook**
5778
5. In the next screen, Slack requires permission to generate a webhook inside a selected channel. So, select the appropriate channel you wish the app to post notifications to and click **Allow**.
5879
5. You'll now see the generated URL for the application to post to the specified channel
59-
![alt text](image-2.png)
80+
![Webhook URLs](./assets/Setup-3.png)
6081
5. Copy this webhook URL. This URL will be used by the Azure Pipelines and Python script.
6182

6283

@@ -65,6 +86,7 @@ settings:
6586
## Azure Pipelines
6687

6788
### General Flow
89+
6890
```
6991
START
7092
|
@@ -111,11 +133,11 @@ The parent pipeline triggers the child pipeline and passes parameters, such as t
111133
testfileDirectory: 'src/tests/e2e/testFiles'
112134
slackWebHook: $(SLACK_WEBHOOK_URL)
113135
```
136+
114137
| Parameter | Meaning | Source |
115138
|-|-|-|
116139
| SLACK_WEBHOOK_URL | This is a unique URL provided by Slack for an installed Slack App's Webhook. | Specified either in the Azure Pipeline's Variable Groups, or set as an environment variable. _Recommend to store this value in the pipeline variable groups._
117140

118-
119141
### Child Pipeline
120142

121143
The child pipeline runs all Playwright tests and publishes the results as an artifact linked to the build. If then generate **JUnit** XML results (`results.xml`) and triggers the Python script with all relevant parameters.

scripts/integrations/slack/SlackMessages.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,6 @@ def safe_get(key):
119119
{"type": "mrkdwn", "text": f"*Failures:*\n {safe_get('failures')}"},
120120
{"type": "mrkdwn", "text": f"*Errors:*\n {safe_get('errors')}"},
121121
{"type": "mrkdwn", "text": f"*Skipped:*\n {safe_get('skipped')}"},
122-
],
123-
}
122+
]
123+
},
124124
]

scripts/integrations/slack/SlackWebhookBot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ def send_report_message(self, args: Namespace, test_results) -> bool:
3232

3333
border_color = (
3434
"#2eb886" if test_results["pass_rate"] == 100 else
35-
"#e01e5a" if test_results["failures"] > 0 else
36-
"#ecb22e"
35+
"#d9d904" if test_results["pass_rate"] > 0 else
36+
"#e01e5a"
3737
)
3838

3939
message = slack_message(header_b1, body, None, border_color)
29.6 KB
Loading
27.7 KB
Loading
27.3 KB
Loading
187 KB
Loading
44.4 KB
Loading
28 KB
Loading
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<testsuites tests="5" failures="2" errors="3" skipped="0" time="3.21">
3+
<testsuite name="SampleTestSuite" tests="5" failures="2" errors="3" skipped="0" timestamp="2024-04-30T15:30:00" time="3.21">
4+
<testcase classname="SampleTests" name="test_pass_1" time="0.5"/>
5+
<testcase classname="SampleTests" name="test_pass_2" time="0.6"/>
6+
<testcase classname="SampleTests" name="test_failure_1" time="0.4"/>
7+
<testcase classname="SampleTests" name="test_error_1" time="0.3"/>
8+
<testcase classname="SampleTests" name="test_skipped_1" time="0.2"/>
9+
</testsuite>
10+
</testsuites>

0 commit comments

Comments
 (0)