Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: modify workflows for new CI slack bot #1277

Merged
merged 50 commits into from
Sep 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
44f3350
build: modify workflows for new CI slack bot
gbotrel Sep 13, 2024
c8a1541
build: add slack destination channel
gbotrel Sep 13, 2024
506920b
build: fix workflow syntax, maybe
gbotrel Sep 13, 2024
b475d7d
build: ci test
gbotrel Sep 13, 2024
c582300
build: ci test
gbotrel Sep 13, 2024
95b2fdd
build: ci test
gbotrel Sep 13, 2024
795cc1f
build: ci test
gbotrel Sep 13, 2024
167fdea
build: ci test
gbotrel Sep 13, 2024
a325a74
build: ci test
gbotrel Sep 13, 2024
3745421
build: ci test
gbotrel Sep 13, 2024
bf680c6
build: ci test
gbotrel Sep 13, 2024
9804ce6
build: ci test
gbotrel Sep 13, 2024
2a949dc
build: ci test
gbotrel Sep 13, 2024
d2e0e58
build: ci test
gbotrel Sep 13, 2024
e7300d9
build: ci test
gbotrel Sep 13, 2024
0070f9c
build: ci test
gbotrel Sep 13, 2024
cb454e3
build: ci test
gbotrel Sep 13, 2024
26add90
build: ci test
gbotrel Sep 13, 2024
4c857d1
build: ci test
gbotrel Sep 13, 2024
cd5bc2b
build: ci test
gbotrel Sep 13, 2024
cdc457a
build: ci test
gbotrel Sep 13, 2024
d9281ae
build: ci test
gbotrel Sep 13, 2024
a664504
build: ci test
gbotrel Sep 13, 2024
08ebf19
build: ci test
gbotrel Sep 13, 2024
4de199a
build: ci test
gbotrel Sep 13, 2024
9361747
build: ci test
gbotrel Sep 13, 2024
c7d1422
build: ci test
gbotrel Sep 13, 2024
8f38879
build: ci test
gbotrel Sep 13, 2024
3e05da0
build: ci test
gbotrel Sep 13, 2024
6c46d32
build: ci test
gbotrel Sep 13, 2024
54bd7a0
build: ci test
gbotrel Sep 13, 2024
ed17e3a
build: ci test
gbotrel Sep 13, 2024
65540e4
build: ci test
gbotrel Sep 13, 2024
26f9407
build: ci test
gbotrel Sep 13, 2024
1e6bff0
build: ci test
gbotrel Sep 13, 2024
b4af3cf
build: ci test
gbotrel Sep 13, 2024
b3d59b1
build: test ci
gbotrel Sep 13, 2024
b420616
build: test ci
gbotrel Sep 13, 2024
c20d6a0
build: test ci
gbotrel Sep 13, 2024
67d2edf
build: test ci
gbotrel Sep 13, 2024
0c6515e
build: test ci
gbotrel Sep 14, 2024
c117bfe
build: test ci
gbotrel Sep 14, 2024
ee05fd2
build: test ci
gbotrel Sep 14, 2024
cff90f5
build: test ci
gbotrel Sep 14, 2024
3b5cb2f
build: test ci
gbotrel Sep 14, 2024
7d36a05
build: test ci
gbotrel Sep 14, 2024
e9f2c22
build: test ci
gbotrel Sep 14, 2024
25ea167
build: test ci
gbotrel Sep 14, 2024
cae235a
build: test ci
gbotrel Sep 14, 2024
710d7b1
build: ci cleanup
gbotrel Sep 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions .github/parse-tests.js

This file was deleted.

70 changes: 13 additions & 57 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
on: pull_request
name: pull_request

jobs:
staticcheck:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -36,11 +37,10 @@ jobs:
args: -v --timeout=5m

test:
needs: staticcheck
runs-on: ubuntu-latest-128
permissions:
pull-requests: write
outputs:
failures: ${{ steps.generate-job-summary.outputs.failures }}
steps:
- name: checkout code
uses: actions/checkout@v4
Expand Down Expand Up @@ -75,62 +75,18 @@ jobs:
go test -json -v -p 4 -tags=prover_checks ./examples/... 2>&1 | gotestfmt -hide=all | tee -a /tmp/gotest.log
go test -json -v -run=NONE -fuzz=FuzzIntcomp -fuzztime=30s ./internal/backend/ioutils 2>&1 | gotestfmt -hide=all | tee -a /tmp/gotest.log

- name: Generate job summary
id: generate-job-summary
if: ${{ always() }}
run: |
if [ -s /tmp/gotest.log ]; then
cat /tmp/gotest.log > $GITHUB_STEP_SUMMARY
echo "failures=$(cat /tmp/gotest.log | node .github/parse-tests.js)" > $GITHUB_OUTPUT
else
echo "## Success ✅" > $GITHUB_STEP_SUMMARY
echo "failures=" > $GITHUB_OUTPUT
fi

slack-workflow-status-failed:
if: failure()
name: post workflow status to slack
slack-notifications:
if: always()
uses: ./.github/workflows/slack-notifications.yml
needs:
- staticcheck
- test
runs-on: ubuntu-latest
steps:
- name: Notify slack -- workflow failed
id: slack
uses: slackapi/slack-github-action@v1.26.0
with:
payload: |
{
"actor": "${{ github.actor }}",
"repo": "${{ github.repository }}",
"status": "FAIL",
"title": "${{ github.event.pull_request.title }}",
"pr": "${{ github.event.pull_request.head.ref }}",
"failed_step_url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/",
"message": "${{ needs.test.outputs.failures }}"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

slack-workflow-status-success:
if: success()
name: post workflow status to slack
needs:
- staticcheck
- test
runs-on: ubuntu-latest
steps:
- name: Notify slack -- workflow succeeded
id: slack
uses: slackapi/slack-github-action@v1.26.0
with:
payload: |
{
"actor": "${{ github.actor }}",
"repo": "${{ github.repository }}",
"status": "SUCCESS",
"title": "${{ github.event.pull_request.title }}",
"pr": "${{ github.event.pull_request.head.ref }}"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_SUCCESS }}
secrets:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
with:
status: ${{ needs.staticcheck.result }}${{ needs.test.result }}
actor: ${{ github.actor }}
repository: ${{ github.repository }}
branch: ${{ github.event.pull_request.head.ref }}
run_id: ${{ github.run_id }}
58 changes: 13 additions & 45 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
branches:
- 'master'
name: push_master

jobs:
staticcheck:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -81,51 +82,18 @@ jobs:
go test -v -p 4 -timeout=50m -tags=release_checks -short -race ./test/...
go test -v -run=NONE -fuzz=FuzzIntcomp -fuzztime=30s ./internal/backend/ioutils


slack-workflow-status-failed:
if: failure()
name: post workflow status to slack
needs:
- staticcheck
- test
runs-on: ubuntu-latest
steps:
- name: Notify slack -- workflow failed
id: slack
uses: slackapi/slack-github-action@v1.26.0
with:
payload: |
{
"actor": "${{ github.actor }}",
"repo": "${{ github.repository }}",
"status": "FAIL",
"title": "push to master ⚠",
"pr": "",
"failed_step_url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/",
"message": ""
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

slack-workflow-status-success:
if: success()
name: post workflow status to slack
slack-notifications:
if: always()
uses: ./.github/workflows/slack-notifications.yml
needs:
- staticcheck
- test
runs-on: ubuntu-latest
steps:
- name: Notify slack -- workflow succeeded
id: slack
uses: slackapi/slack-github-action@v1.26.0
with:
payload: |
{
"actor": "${{ github.actor }}",
"repo": "${{ github.repository }}",
"status": "SUCCESS",
"title": "push to master ✅",
"pr": ""
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_SUCCESS }}
- staticcheck
secrets:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
with:
status: ${{ needs.staticcheck.result }}${{ needs.test.result }}
actor: ${{ github.actor }}
repository: ${{ github.repository }}
branch: "master"
run_id: ${{ github.run_id }}
85 changes: 85 additions & 0 deletions .github/workflows/slack-notifications.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# .github/workflows/slack-notifications.yml
name: Slack Notifications

on:
workflow_call:
secrets:
SLACK_BOT_TOKEN:
required: true
inputs:
status:
description: 'The status of the workflow (successsuccess or failure)'
required: true
type: string
actor:
description: 'The GitHub actor'
required: true
type: string
repository:
description: 'The GitHub repository'
required: true
type: string
branch:
description: 'The branch name'
required: true
type: string
run_id:
description: 'The workflow run ID'
required: true
type: string

jobs:
notify_slack:
runs-on: ubuntu-latest
steps:
- name: Post to Slack
run: |
if [ "${{ inputs.status }}" == "successsuccess" ]; then
payload=$(jq -n --arg repository "${{ inputs.repository }}" --arg branch "${{ inputs.branch }}" --arg actor "${{ inputs.actor }}" --arg run_id "${{ inputs.run_id }}" '{
"channel": "team-gnark-build",
"text": "GitHub Action build result: success",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":large_green_circle: *All checks have passed:* *\($branch)* :white_check_mark:"
},
},
{
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": "\($repository) -- \($actor) -- <https://github.com/\($repository)/actions/runs/\($run_id)|View details>"
}
]
}
]
}')
else
payload=$(jq -n --arg repository "${{ inputs.repository }}" --arg branch "${{ inputs.branch }}" --arg actor "${{ inputs.actor }}" --arg run_id "${{ inputs.run_id }}" '{
"channel": "team-gnark-build",
"text": "GitHub Action build result: failure",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":red_circle: *Failed run:* *\($branch)*"
},
},
{
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": "\($repository) -- \($actor) -- <https://github.com/\($repository)/actions/runs/\($run_id)|View details>"
}
]
}
]
}')
fi
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 }}" )
shell: bash
17 changes: 10 additions & 7 deletions .gotestfmt/downloads.gotpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,35 @@ This template contains the format for a package download.
{{- $settings := .Settings -}}
{{- if or .Packages .Reason -}}
{{- if or (not .Settings.HideSuccessfulDownloads) .Failed -}}
::group::
{{- if .Failed -}}
{{ "\033" }}[0;31m
{{- else -}}
📥
{{ "\033" }}[0;34m📥
{{- end -}}
{{ " " }} Dependency downloads
{{ "\n" -}}
{{ " " }}Dependency downloads
{{- "\033" }}[0m{{ "\n" -}}

{{- range .Packages -}}
{{- if or (not $settings.HideSuccessfulDownloads) .Failed -}}
{{- " " -}}
{{- if .Failed -}}
{{ "\033" }}[0;31m
{{- else -}}
📦
{{- end -}}
{{- " " -}}
{{- .Package }} {{ .Version -}}
{{- "\033" }}[0m
{{- "\n" -}}
{{ with .Reason -}}
{{- " " -}}{{ . -}}{{ "\n" -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- with .Reason -}}
{{- " " -}}🛑 {{ . }}{{ "\n" -}}
{{- " " -}}{{- "\033" }}[0;31m🛑 {{ . }}{{- "\033" }}[0m{{ "\n" -}}
{{- end -}}
::endgroup::
{{- end -}}
{{- end -}}
{{- end -}}
41 changes: 27 additions & 14 deletions .gotestfmt/package.gotpl
Original file line number Diff line number Diff line change
@@ -1,42 +1,55 @@
{{- /*gotype: github.com/gotesttools/gotestfmt/v2/parser.Package*/ -}}

{{- /*
This template contains the format for an individual package. GitHub actions does not currently support nested groups so
we are creating a stylized header for each package.
*/ -}}
{{- $settings := .Settings -}}
{{- if and (or (not $settings.HideSuccessfulPackages) (ne .Result "PASS")) (or (not $settings.HideEmptyPackages) (ne .Result "SKIP") (ne (len .TestCases) 0)) -}}
📦 `{{ .Name }}`
{{- if eq .Result "PASS" -}}
{{ "\033" }}[0;32m
{{- else if eq .Result "SKIP" -}}
{{ "\033" }}[0;33m
{{- else -}}
{{ "\033" }}[0;31m
{{- end -}}
📦 {{ .Name }}{{- "\033" }}[0m
{{- with .Coverage -}}
({{ . }}% coverage)
{{- "\033" -}}[0;37m ({{ . }}% coverage){{- "\033" -}}[0m
{{- end -}}
{{- "\n" -}}
{{- with .Reason -}}
{{- " " -}}🛑 {{ . -}}{{- "\n" -}}
{{- end -}}
{{- with .Output -}}
```{{- "\n" -}}
{{- . -}}{{- "\n" -}}
```{{- "\n" -}}
{{- end -}}
{{- with .TestCases -}}
{{- range . -}}
{{- if or (not $settings.HideSuccessfulTests) (ne .Result "PASS") -}}
::group::
{{- if eq .Result "PASS" -}}
{{ "\033" }}[0;32m
{{- else if eq .Result "SKIP" -}}
🚧
{{ "\033" }}[0;33m🚧
{{- else -}}
{{ "\033" }}[0;31m
{{- end -}}
{{ " " }}`{{- .Name -}}` {{ .Duration -}}
{{ " " }}{{- .Name -}}
{{- "\033" -}}[0;37m ({{if $settings.ShowTestStatus}}{{.Result}}; {{end}}{{ .Duration -}}
{{- with .Coverage -}}
, coverage: {{ . }}%
{{- end -}})
{{- "\033" -}}[0m
{{- "\n" -}}

{{- with .Output -}}
```{{- "\n" -}}
{{- formatTestOutput . $settings -}}{{- "\n" -}}
```{{- "\n" -}}
{{- formatTestOutput . $settings -}}
{{- "\n" -}}
{{- end -}}

{{- "\n" -}}
::endgroup::{{- "\n" -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- "\n" -}}
{{- end -}}
{{- end -}}