Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
50 changes: 50 additions & 0 deletions .github/scripts/notify_sdk_validation_failure.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash

# Notifies the APIx DevOps Integrations help usergroup when the Go SDK
# validation step fails during an OpenAPI spec release.
#
# The caller keys this notification to the "go-sdk-validation" step outcome, so
# a failure in an earlier setup step (Node, npm, artifact download, Spectral,
# Go) does not notify. The caller also suppresses duplicates across release
# retries.

set -eou pipefail

: "${SLACK_BEARER_TOKEN:?SLACK_BEARER_TOKEN is required}"
: "${SLACK_CHANNEL_ID:?SLACK_CHANNEL_ID is required}"
: "${SLACK_HELP_GROUP:?SLACK_HELP_GROUP is required}"
: "${TARGET_ENV:?TARGET_ENV is required}"
: "${RUN_URL:?RUN_URL is required}"

SLACK_MESSAGE=$(
cat <<EOF
:rotating_light: The Go SDK validation step failed while validating the OpenAPI spec for the ${TARGET_ENV} environment.
${SLACK_HELP_GROUP} can you take a look? This can be caused by the input spec or by the atlas-sdk-go tooling, so please triage before assuming a root cause.
Run: ${RUN_URL}
EOF
)

PAYLOAD=$(jq -n \
--arg channel "${SLACK_CHANNEL_ID}" \
--arg text "${SLACK_MESSAGE}" \
'{channel: $channel, text: $text}')

SLACK_RESPONSE=$(curl --silent --show-error \
--request POST \
--header "Authorization: Bearer ${SLACK_BEARER_TOKEN}" \
--header "Content-type: application/json; charset=utf-8" \
--data "${PAYLOAD}" \
https://slack.com/api/chat.postMessage)

SLACK_OK=$(echo "${SLACK_RESPONSE}" | jq -r '.ok')
if [ "${SLACK_OK}" != "true" ]; then
SLACK_ERROR=$(echo "${SLACK_RESPONSE}" | jq -r '.error')
echo "Failed to send the Slack notification: ${SLACK_ERROR}"
if [ "${SLACK_ERROR}" == "not_in_channel" ]; then
echo "The Slack bot is not a member of channel ${SLACK_CHANNEL_ID}."
echo "Invite the bot to the channel or update SLACK_CHANNEL_ID."
fi
exit 1
fi

echo "Slack notification sent to ${SLACK_CHANNEL_ID}."
6 changes: 3 additions & 3 deletions .github/workflows/failure-handler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,19 @@ jobs:
RELEASE_NAME: ${{ inputs.release_name }}
REPO: ${{ github.repository }}
run: |
query="(${TARGET_ENV}}) The ${RELEASE_NAME} Release has failed."
query="(${TARGET_ENV}) The ${RELEASE_NAME} Release has failed."
number_issue=$(gh search issues "${query}" --repo "${REPO}" --state open --label failed-release --json title | jq length)

if [ -z "${number_issue}" ]; then
echo "There was an issue with the GH APIs. Stopping execution."
return 1
exit 1
fi

echo "number_issue=${number_issue}"
if [ "${number_issue}" -gt 0 ]; then
echo "An issue already exists. Stopping execution."
echo "found-issue=true" >> "${GITHUB_OUTPUT}"
return 0
exit 0
fi

echo "found-issue=false" >> "${GITHUB_OUTPUT}"
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/release-spec-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ jobs:
api_bot_pat: ${{ secrets.API_BOT_PAT }}
jira_api_token: ${{ secrets.JIRA_API_TOKEN }}
bump_token: ${{secrets.BUMP_TOKEN}}
slack_bearer_token: ${{ secrets.SLACK_BEARER_TOKEN }}
with:
aws_default_region: ${{ vars.AWS_DEFAULT_REGION}}
aws_s3_bucket: ${{ vars.S3_BUCKET_DEV}}
Expand All @@ -78,6 +79,7 @@ jobs:
api_bot_pat: ${{ secrets.API_BOT_PAT }}
jira_api_token: ${{ secrets.JIRA_API_TOKEN }}
bump_token: ${{secrets.BUMP_TOKEN}}
slack_bearer_token: ${{ secrets.SLACK_BEARER_TOKEN }}
with:
aws_default_region: ${{ vars.AWS_DEFAULT_REGION}}
aws_s3_role_to_assume: ${{ vars.AWS_S3_ROLE_TO_ASSUME }}
Expand All @@ -98,6 +100,7 @@ jobs:
api_bot_pat: ${{ secrets.API_BOT_PAT }}
jira_api_token: ${{ secrets.JIRA_API_TOKEN }}
bump_token: ${{secrets.BUMP_TOKEN}}
slack_bearer_token: ${{ secrets.SLACK_BEARER_TOKEN }}
with:
aws_default_region: ${{ vars.AWS_DEFAULT_REGION}}
aws_s3_role_to_assume: ${{ vars.AWS_S3_ROLE_TO_ASSUME }}
Expand All @@ -120,6 +123,7 @@ jobs:
workspace_id: ${{ secrets.WORKSPACE_ID }}
jira_api_token: ${{ secrets.JIRA_API_TOKEN }}
bump_token: ${{secrets.BUMP_TOKEN}}
slack_bearer_token: ${{ secrets.SLACK_BEARER_TOKEN }}
with:
aws_default_region: ${{ vars.AWS_DEFAULT_REGION}}
aws_s3_role_to_assume: ${{ vars.AWS_S3_ROLE_TO_ASSUME }}
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/release-spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ on:
required: false
bump_token:
required: true
slack_bearer_token:
required: true

permissions:
contents: write
Expand All @@ -86,6 +88,7 @@ jobs:
uses: ./.github/workflows/required-spec-validations.yml
secrets:
api_bot_pat: ${{ secrets.api_bot_pat }}
slack_bearer_token: ${{ secrets.slack_bearer_token }}
with:
env: ${{ inputs.env }}

Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/required-spec-validations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ on:
secrets: # all secrets are passed explicitly in this workflow
api_bot_pat:
required: true
slack_bearer_token:
required: true
permissions:
contents: write

Expand Down Expand Up @@ -74,3 +76,26 @@ jobs:
pushd atlas-sdk-go
make -e openapi-pipeline
popd
# Notify the APIx DevOps Integrations on-call so an SDK validation
# failure is routed quickly. Keyed to the go-sdk-validation step
# outcome: an earlier setup failure (Node, npm, artifact download,
# Spectral, Go, SDK checkout) leaves this step without a failure
# outcome, so it does not notify.
- name: Notify the Go SDK validation failure
# Notify once per incident. The release retry handler requests a
# rerun of failed jobs while github.run_attempt < 3, so attempt 3 is
# the first attempt after the automatic retries are exhausted.
# Attempts beyond 3 come from reruns the handler already queued and
# would duplicate the alert.
if: ${{ failure() && steps.go-sdk-validation.outcome == 'failure' && fromJSON(github.run_attempt) == 3 }}
env:
SLACK_BEARER_TOKEN: ${{ secrets.slack_bearer_token }}
# #cloud-apix-devops-integrations-notifications and
# @apix-devops-integrations-help (S0C2KP6E273). These are
# non-sensitive IDs, kept inline because only the repo owner can
# manage repository secrets.
SLACK_CHANNEL_ID: C06Q7QF1ZST
SLACK_HELP_GROUP: '<!subteam^S0C2KP6E273>'
TARGET_ENV: ${{ inputs.env }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: .github/scripts/notify_sdk_validation_failure.sh
Loading