Skip to content

Commit 4c87df8

Browse files
!
1 parent 0eb87c7 commit 4c87df8

File tree

2 files changed

+75
-80
lines changed

2 files changed

+75
-80
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: "Send Qmods Slack notification"
2+
description: "Send failing Qmods notification from pytest output"
3+
4+
inputs:
5+
pytest_output:
6+
required: true
7+
description: "Pytest output file path"
8+
9+
runs:
10+
using: "composite"
11+
steps:
12+
- name: Print failing tests
13+
if: failure()
14+
shell: bash
15+
run: |
16+
echo FAILING_TESTS=$(
17+
yq -o json -I 0 -p xml '
18+
.testsuites[].testcase[] | select(.failure // .error) |
19+
select((.failure // .error)["+@message"] | test("^((AssertionError: Qmod file)|(AssertionError: Found uncommitted Qmod)).*")) |
20+
{
21+
"name": (.["+@classname"] + "::" + .["+@name"]),
22+
"message": (.failure // .error)["+@message"]
23+
}
24+
' ${{ inputs.pytest_output }} | \
25+
jq -r -s '
26+
sort_by(.name) | .[] |
27+
"• " + .name + ": " + (.message | @html | split("\n") | .[0]) + "\n"
28+
'
29+
) >> $GITHUB_ENV
30+
31+
- name: Send JSON to slack workflow
32+
id: slack
33+
if: failure()
34+
uses: slackapi/slack-github-action@v2.1
35+
with:
36+
method: chat.postMessage
37+
token: ${{ secrets.SLACK_BOT_TOKEN }}
38+
payload: |
39+
{
40+
"channel": "ci-notebooks-alerts",
41+
"blocks": [
42+
{
43+
"type": "header",
44+
"text": {
45+
"type": "plain_text",
46+
"text": "Notification - Classiq library tests failed on branch ${{ github.ref_name }}",
47+
"emoji": true
48+
}
49+
},
50+
{
51+
"type": "section",
52+
"text": {
53+
"type": "mrkdwn",
54+
"text": "Some Classiq library demos failed.\n*Make sure to take a look*"
55+
}
56+
},
57+
{
58+
"type": "section",
59+
"text": {
60+
"type": "mrkdwn",
61+
"text": "${{ env.FAILING_TESTS }}"
62+
}
63+
},
64+
{
65+
"type": "section",
66+
"text": {
67+
"type": "mrkdwn",
68+
"text": "<https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}|Failed action URL>"
69+
}
70+
}
71+
]
72+
}

.github/workflows/Test-CI-daily-notebooks-applications.yml

Lines changed: 3 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -51,84 +51,7 @@ jobs:
5151
CLASSIQ_IDE: "https://nightly.platform.classiq.io"
5252
CLASSIQ_HOST: "https://nightly.platform.classiq.io"
5353

54-
- name: Print failing tests
55-
if: failure()
56-
run: |
57-
if [ -z "$(find ./pytest-results -name "*.xml")" ]; then
58-
# Don't do anything if we don't have any results
59-
exit 0
60-
fi
61-
{
62-
echo "# Failing tests"
63-
echo "| Test | Message |"
64-
echo "| ---- | ------- |"
65-
yq -o json -I 0 -p xml '
66-
.testsuites[].testcase[] | select(.failure // .error) |
67-
select((.failure // .error)["+@message"] | test("^((AssertionError: Qmod file)|(AssertionError: Found uncommitted Qmod)).*")) |
68-
{
69-
"name": (.["+@classname"] + "::" + .["+@name"]),
70-
"message": (.failure // .error)["+@message"]
71-
}
72-
' ./pytest-results/*.xml | \
73-
jq -r -s '
74-
sort_by(.name) | .[] |
75-
"| " + .name + " | " + (.message | @html | split("\n") | .[0]) + " |"
76-
'
77-
}>>"$GITHUB_STEP_SUMMARY"
78-
echo FAILING_TESTS=$(
79-
yq -o json -I 0 -p xml '
80-
.testsuites[].testcase[] | select(.failure // .error) |
81-
select((.failure // .error)["+@message"] | test("^((AssertionError: Qmod file)|(AssertionError: Found uncommitted Qmod)).*")) |
82-
{
83-
"name": (.["+@classname"] + "::" + .["+@name"]),
84-
"message": (.failure // .error)["+@message"]
85-
}
86-
' ./pytest-results/*.xml | \
87-
jq -r -s '
88-
sort_by(.name) | .[] |
89-
"• " + .name + ": " + (.message | @html | split("\n") | .[0]) + "\n"
90-
'
91-
) >> $GITHUB_ENV
92-
93-
- name: Send JSON to slack workflow
94-
id: slack
95-
if: failure()
96-
uses: slackapi/slack-github-action@v2.1
54+
- name: Send Qmods Slack notification
55+
uses: ./.github/actions/send_slack_notification
9756
with:
98-
method: chat.postMessage
99-
token: ${{ secrets.SLACK_BOT_TOKEN }}
100-
payload: |
101-
{
102-
"channel": "ci-notebooks-alerts",
103-
"blocks": [
104-
{
105-
"type": "header",
106-
"text": {
107-
"type": "plain_text",
108-
"text": "Notification - Classiq library tests failed on branch ${{ github.ref_name }}",
109-
"emoji": true
110-
}
111-
},
112-
{
113-
"type": "section",
114-
"text": {
115-
"type": "mrkdwn",
116-
"text": "Some Classiq library demos failed.\n*Make sure to take a look*"
117-
}
118-
},
119-
{
120-
"type": "section",
121-
"text": {
122-
"type": "mrkdwn",
123-
"text": "${{ env.FAILING_TESTS }}"
124-
}
125-
},
126-
{
127-
"type": "section",
128-
"text": {
129-
"type": "mrkdwn",
130-
"text": "<https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}|Failed action URL>"
131-
}
132-
}
133-
]
134-
}
57+
pytest-output: ./pytest-results/test-results-applications.xml

0 commit comments

Comments
 (0)