notify on go-tests failure on main and release branches. (#19640)

notify on failures in go-tests on main and release branches.
This commit is contained in:
John Murret 2023-11-14 17:42:28 -07:00 committed by GitHub
parent 9ca62aaf33
commit bc26fbcf2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 12 additions and 62 deletions

View File

@ -1,29 +0,0 @@
#!/usr/bin/env bash
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
set -uo pipefail
# This script is used in GitHub Actions pipelines to notify Slack of a job failure.
if [[ $GITHUB_REF_NAME == "main" ]]; then
GITHUB_ENDPOINT="https://github.com/${GITHUB_REPOSITORY}/commit/${GITHUB_SHA}"
GITHUB_ACTIONS_ENDPOINT="https://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
COMMIT_MESSAGE=$(git log -1 --pretty=%B | head -n1)
SHORT_REF=$(git rev-parse --short "${GITHUB_SHA}")
curl -X POST -H 'Content-type: application/json' \
--data \
"{ \
\"attachments\": [ \
{ \
\"fallback\": \"GitHub Actions workflow failed!\", \
\"text\": \"❌ Failed: \`${GITHUB_ACTOR}\`'s <${GITHUB_ACTIONS_ENDPOINT}|${GITHUB_JOB}> job failed for commit <${GITHUB_ENDPOINT}|${SHORT_REF}> on \`${GITHUB_REF_NAME}\`!\n\n- <${COMMIT_MESSAGE}\", \
\"footer\": \"${GITHUB_REPOSITORY}\", \
\"ts\": \"$(date +%s)\", \
\"color\": \"danger\" \
} \
] \
}" "${FEED_CONSUL_GH_URL}"
else
echo "Not posting slack failure notifications for non-main branch"
fi

View File

@ -94,9 +94,6 @@ jobs:
fi
- run: make proto-lint
name: "Protobuf Lint"
- name: Notify Slack
if: ${{ failure() }}
run: .github/scripts/notify_slack.sh
check-codegen:
needs:
- setup
@ -116,9 +113,6 @@ jobs:
echo "Generated code was not updated correctly"
exit 1
fi
- name: Notify Slack
if: ${{ failure() }}
run: .github/scripts/notify_slack.sh
lint-enums:
needs:
@ -134,9 +128,6 @@ jobs:
with:
go-version-file: 'go.mod'
- run: go install github.com/reillywatson/enumcover/cmd/enumcover@master && enumcover ./...
- name: Notify Slack
if: ${{ failure() }}
run: .github/scripts/notify_slack.sh
lint-container-test-deps:
needs:
@ -151,9 +142,6 @@ jobs:
with:
go-version-file: 'go.mod'
- run: make lint-container-test-deps
- name: Notify Slack
if: ${{ failure() }}
run: .github/scripts/notify_slack.sh
lint-consul-retry:
needs:
@ -169,9 +157,6 @@ jobs:
with:
go-version-file: 'go.mod'
- run: go install github.com/hashicorp/lint-consul-retry@master && lint-consul-retry
- name: Notify Slack
if: ${{ failure() }}
run: .github/scripts/notify_slack.sh
lint:
needs:
@ -516,3 +501,15 @@ jobs:
printf "Tests failed or workflow cancelled:\n\n${{ toJSON(needs) }}"
exit 1
fi
- name: Notify Slack
if: ${{ failure() && (github.ref_name == 'main' || startsWith(github.ref_name, 'release/')) }}
id: slack
uses: slackapi/slack-github-action@e28cf165c92ffef168d23c5c9000cffc8a25e117 # v1.24.0
with:
# github.event.head_commit.message and github.ref_name both rely on this event occurring on a push / merge
payload: |
{
"message": "❌ ${{ github.workflow }} workflow failed: \n\n- Run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} \n- Branch: ${{ github.ref_name }} \n- Message: ${{ github.event.head_commit.message }} \n- Author: ${{ github.event.sender.login }}"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.CONSUL_NIGHTLY_INTEG_TEST_SLACK_WEBHOOK }}

View File

@ -33,6 +33,3 @@ jobs:
git status -s
exit 1
fi
- name: Notify Slack
if: ${{ failure() }}
run: .github/scripts/notify_slack.sh

View File

@ -42,6 +42,3 @@ jobs:
with:
name: ${{inputs.uploaded-binary-name}}
path: consul.exe
- name: Notify Slack
if: ${{ failure() }}
run: .github/scripts/notify_slack.sh

View File

@ -54,6 +54,3 @@ jobs:
with:
name: ${{inputs.uploaded-binary-name}}
path: ./bin/consul
- name: Notify Slack
if: ${{ failure() }}
run: .github/scripts/notify_slack.sh

View File

@ -55,6 +55,3 @@ jobs:
version: v1.51.1
args: --build-tags="${{ env.GOTAGS }}" -v
skip-cache: true
- name: Notify Slack
if: ${{ failure() }}
run: .github/scripts/notify_slack.sh

View File

@ -175,6 +175,3 @@ jobs:
- name: "Re-run fails report"
run: |
.github/scripts/rerun_fails_report.sh /tmp/gotestsum-rerun-fails
- name: Notify Slack
if: ${{ failure() }}
run: .github/scripts/notify_slack.sh

View File

@ -154,6 +154,3 @@ jobs:
- name: "Re-run fails report"
run: |
.github/scripts/rerun_fails_report.sh /tmp/gotestsum-rerun-fails
- name: Notify Slack
if: ${{ failure() }}
run: .github/scripts/notify_slack.sh