Skip to content

Commit 4abc1c1

Browse files
authored
chore: reintroduce slack notif (#802)
1 parent 0cb721c commit 4abc1c1

File tree

3 files changed

+114
-4
lines changed

3 files changed

+114
-4
lines changed

.github/workflows/pr.yml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,22 @@ jobs:
5858
- name: Run tests
5959
run: |
6060
set -euo pipefail
61-
go test -json -v -short -timeout=30m ./... 2>&1 | gotestfmt -hide=all | tee /tmp/gotest.log
62-
go test -json -v -tags=purego -timeout=30m ./... 2>&1 | gotestfmt -hide=all | tee -a /tmp/gotest.log
61+
go test -json -v -short -timeout=30m ./... 2>&1 | gotestfmt -hide=all | tee /tmp/gotest.log
62+
go test -json -v -tags=purego -timeout=30m ./... 2>&1 | gotestfmt -hide=all | tee -a /tmp/gotest.log
6363
GOARCH=386 go test -json -short -v -timeout=30m ./ecc/bn254/... 2>&1 | gotestfmt -hide=all | tee -a /tmp/gotest.log
64-
GOARCH=386 go test -json -short -v -timeout=30m ./field/goldilocks 2>&1 | gotestfmt -hide=all | tee -a /tmp/gotest.log
65-
GOARCH=386 go test -json -short -v -timeout=30m ./field/koalabear 2>&1 | gotestfmt -hide=all | tee -a /tmp/gotest.log
64+
GOARCH=386 go test -json -short -v -timeout=30m ./field/goldilocks 2>&1 | gotestfmt -hide=all | tee -a /tmp/gotest.log
65+
GOARCH=386 go test -json -short -v -timeout=30m ./field/koalabear 2>&1 | gotestfmt -hide=all | tee -a /tmp/gotest.log
6666
GOARCH=386 go test -json -short -v -timeout=30m ./field/babybear 2>&1 | gotestfmt -hide=all | tee -a /tmp/gotest.log
67+
68+
slack-notification:
69+
needs: [staticcheck, test]
70+
if: always()
71+
uses: ./.github/workflows/slack-notifications.yml
72+
with:
73+
status: ${{ (needs.staticcheck.result == 'success' && needs.test.result == 'success') && 'success' || 'failure' }}
74+
actor: ${{ github.actor }}
75+
repository: ${{ github.repository }}
76+
branch: ${{ github.head_ref || github.ref_name }}
77+
run_id: ${{ github.run_id }}
78+
secrets:
79+
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}

.github/workflows/push.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,16 @@ jobs:
7878
GOARCH=386 go test -json -short -v -timeout=30m ./field/goldilocks 2>&1 | gotestfmt -hide=all | tee -a /tmp/gotest.log
7979
GOARCH=386 go test -json -short -v -timeout=30m ./field/koalabear 2>&1 | gotestfmt -hide=all | tee -a /tmp/gotest.log
8080
GOARCH=386 go test -json -short -v -timeout=30m ./field/babybear 2>&1 | gotestfmt -hide=all | tee -a /tmp/gotest.log
81+
82+
slack-notification:
83+
needs: [staticcheck, test]
84+
if: always()
85+
uses: ./.github/workflows/slack-notifications.yml
86+
with:
87+
status: ${{ (needs.staticcheck.result == 'success' && needs.test.result == 'success') && 'success' || 'failure' }}
88+
actor: ${{ github.actor }}
89+
repository: ${{ github.repository }}
90+
branch: ${{ github.ref_name }}
91+
run_id: ${{ github.run_id }}
92+
secrets:
93+
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: Slack Notifications
2+
3+
on:
4+
workflow_call:
5+
secrets:
6+
SLACK_BOT_TOKEN:
7+
required: true
8+
inputs:
9+
status:
10+
description: 'The status of the workflow (success or failure)'
11+
required: true
12+
type: string
13+
actor:
14+
description: 'The GitHub actor'
15+
required: true
16+
type: string
17+
repository:
18+
description: 'The GitHub repository'
19+
required: true
20+
type: string
21+
branch:
22+
description: 'The branch name'
23+
required: true
24+
type: string
25+
run_id:
26+
description: 'The workflow run ID'
27+
required: true
28+
type: string
29+
30+
jobs:
31+
notify_slack:
32+
runs-on: ubuntu-latest
33+
steps:
34+
- name: Post to Slack
35+
run: |
36+
if [ "${{ inputs.status }}" == "success" ]; then
37+
payload=$(jq -n --arg repository "${{ inputs.repository }}" --arg branch "${{ inputs.branch }}" --arg actor "${{ inputs.actor }}" --arg run_id "${{ inputs.run_id }}" '{
38+
"channel": "team-gnark-build",
39+
"text": "GitHub Action build result: success",
40+
"blocks": [
41+
{
42+
"type": "section",
43+
"text": {
44+
"type": "mrkdwn",
45+
"text": ":large_green_circle: *All checks have passed:* *\($branch)* :white_check_mark:"
46+
},
47+
},
48+
{
49+
"type": "context",
50+
"elements": [
51+
{
52+
"type": "mrkdwn",
53+
"text": "\($repository) -- \($actor) -- <https://github.com/\($repository)/actions/runs/\($run_id)|View details>"
54+
}
55+
]
56+
}
57+
]
58+
}')
59+
else
60+
payload=$(jq -n --arg repository "${{ inputs.repository }}" --arg branch "${{ inputs.branch }}" --arg actor "${{ inputs.actor }}" --arg run_id "${{ inputs.run_id }}" '{
61+
"channel": "team-gnark-build",
62+
"text": "GitHub Action build result: failure",
63+
"blocks": [
64+
{
65+
"type": "section",
66+
"text": {
67+
"type": "mrkdwn",
68+
"text": ":red_circle: *Failed run:* *\($branch)*"
69+
},
70+
},
71+
{
72+
"type": "context",
73+
"elements": [
74+
{
75+
"type": "mrkdwn",
76+
"text": "\($repository) -- \($actor) -- <https://github.com/\($repository)/actions/runs/\($run_id)|View details>"
77+
}
78+
]
79+
}
80+
]
81+
}')
82+
fi
83+
response=$(curl -s -X POST -H 'Content-type: application/json; charset=utf-8' --data "$payload" https://slack.com/api/chat.postMessage -H "Authorization: Bearer ${{ secrets.SLACK_BOT_TOKEN }}" )
84+
shell: bash

0 commit comments

Comments
 (0)