centralize the slack message action (#3614)
centralizes the ci action for slack messages, and adds slack messages for per-resource cleanup failures. --- #### Does this PR need a docs update or release note? - [x] ⛔ No #### Type of change - [x] 🤖 Supportability/Tests #### Issues - #3503
This commit is contained in:
parent
3a98bcdcf5
commit
0175033a83
57
.github/actions/slack-message/action.yml
vendored
Normal file
57
.github/actions/slack-message/action.yml
vendored
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
name: Send a message to slack
|
||||||
|
|
||||||
|
inputs:
|
||||||
|
msg:
|
||||||
|
description: The slack message text
|
||||||
|
slack_url:
|
||||||
|
description: passthrough for secrets.SLACK_WEBHOOK_URL
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: composite
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: set github ref
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
echo "github_reference=${{ github.ref }}" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: trim github ref
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
echo "trimmed_ref=${github_reference#refs/}" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: build urls
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
echo "logurl=$(printf '<https://github.com/alcionai/corso/actions/runs/%s|[Action]>' ${{ github.run_id }})" >> $GITHUB_ENV
|
||||||
|
echo "commiturl=$(printf '<https://github.com/alcionai/corso/commit/%s|[Commit]>' ${{ github.sha }})" >> $GITHUB_ENV
|
||||||
|
echo "refurl=$(printf '<https://github.com/alcionai/corso/%s|[Ref]>' ${{ env.trimmed_ref }})" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: use url or blank val
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
echo "JOB=${{ github.job || '' }}" >> $GITHUB_ENV
|
||||||
|
echo "LOGS=${{ github.run_id && env.logurl || '-' }}" >> $GITHUB_ENV
|
||||||
|
echo "COMMIT=${{ github.sha && env.commiturl || '-' }}" >> $GITHUB_ENV
|
||||||
|
echo "REF=${{ env.trimmed_ref && env.refurl || '-' }}" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- id: slack-message
|
||||||
|
uses: slackapi/slack-github-action@v1.24.0
|
||||||
|
env:
|
||||||
|
SLACK_WEBHOOK_URL: ${{ inputs.slack_url }}
|
||||||
|
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
|
||||||
|
with:
|
||||||
|
payload: |
|
||||||
|
{
|
||||||
|
"text": "${{ inputs.msg }} :: ${{ env.LOGS }} ${{ env.COMMIT }} ${{ env.REF }}",
|
||||||
|
"blocks": [
|
||||||
|
{
|
||||||
|
"type": "section",
|
||||||
|
"text": {
|
||||||
|
"type": "mrkdwn",
|
||||||
|
"text": "${{ inputs.msg }} :: ${{ env.JOB }}\n${{ env.LOGS }} ${{ env.COMMIT }} ${{ env.REF }}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
22
.github/workflows/ci_test_cleanup.yml
vendored
22
.github/workflows/ci_test_cleanup.yml
vendored
@ -18,9 +18,7 @@ jobs:
|
|||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
# sets the maximum time to now-30m.
|
# sets the maximum time to now-30m.
|
||||||
# CI test have a 10 minute timeout.
|
# CI test have a 20 minute timeout.
|
||||||
# At 20 minutes ago, we should be safe from conflicts.
|
|
||||||
# The additional 10 minutes is just to be good citizens.
|
|
||||||
- name: Set purge boundary
|
- name: Set purge boundary
|
||||||
run: echo "HALF_HOUR_AGO=$(date -d '30 minutes ago' -u +"%Y-%m-%dT%H:%M:%SZ")" >> $GITHUB_ENV
|
run: echo "HALF_HOUR_AGO=$(date -d '30 minutes ago' -u +"%Y-%m-%dT%H:%M:%SZ")" >> $GITHUB_ENV
|
||||||
|
|
||||||
@ -36,6 +34,13 @@ jobs:
|
|||||||
m365-admin-user: ${{ secrets.M365_TENANT_ADMIN_USER }}
|
m365-admin-user: ${{ secrets.M365_TENANT_ADMIN_USER }}
|
||||||
m365-admin-password: ${{ secrets.M365_TENANT_ADMIN_PASSWORD }}
|
m365-admin-password: ${{ secrets.M365_TENANT_ADMIN_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Notify failure in slack
|
||||||
|
if: failure()
|
||||||
|
uses: ./.github/actions/slack-message
|
||||||
|
with:
|
||||||
|
msg: "[FAILED] ${{ vars[matrix.user] }} CI Cleanup"
|
||||||
|
slack_url: ${{ secrets.SLACK_WEBHOOK_URL }}
|
||||||
|
|
||||||
Test-Site-Data-Cleanup:
|
Test-Site-Data-Cleanup:
|
||||||
environment: Testing
|
environment: Testing
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@ -48,9 +53,7 @@ jobs:
|
|||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
# sets the maximum time to now-30m.
|
# sets the maximum time to now-30m.
|
||||||
# CI test have a 10 minute timeout.
|
# CI test have a 20 minute timeout.
|
||||||
# At 20 minutes ago, we should be safe from conflicts.
|
|
||||||
# The additional 10 minutes is just to be good citizens.
|
|
||||||
- name: Set purge boundary
|
- name: Set purge boundary
|
||||||
run: echo "HALF_HOUR_AGO=$(date -d '30 minutes ago' -u +"%Y-%m-%dT%H:%M:%SZ")" >> $GITHUB_ENV
|
run: echo "HALF_HOUR_AGO=$(date -d '30 minutes ago' -u +"%Y-%m-%dT%H:%M:%SZ")" >> $GITHUB_ENV
|
||||||
|
|
||||||
@ -67,3 +70,10 @@ jobs:
|
|||||||
azure-tenant-id: ${{ secrets.TENANT_ID }}
|
azure-tenant-id: ${{ secrets.TENANT_ID }}
|
||||||
m365-admin-user: ${{ secrets.M365_TENANT_ADMIN_USER }}
|
m365-admin-user: ${{ secrets.M365_TENANT_ADMIN_USER }}
|
||||||
m365-admin-password: ${{ secrets.M365_TENANT_ADMIN_PASSWORD }}
|
m365-admin-password: ${{ secrets.M365_TENANT_ADMIN_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Notify failure in slack
|
||||||
|
if: failure()
|
||||||
|
uses: ./.github/actions/slack-message
|
||||||
|
with:
|
||||||
|
msg: "[FAILED] ${{ vars[matrix.site] }} CI Cleanup"
|
||||||
|
slack_url: ${{ secrets.SLACK_WEBHOOK_URL }}
|
||||||
|
|||||||
32
.github/workflows/longevity_test.yml
vendored
32
.github/workflows/longevity_test.yml
vendored
@ -277,33 +277,9 @@ jobs:
|
|||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
retention-days: 14
|
retention-days: 14
|
||||||
|
|
||||||
- name: SHA info
|
- name: Notify failure in slack
|
||||||
id: sha-info
|
|
||||||
if: failure()
|
if: failure()
|
||||||
run: |
|
uses: ./.github/actions/slack-message
|
||||||
echo ${GITHUB_REF#refs/heads/}-${GITHUB_SHA}
|
|
||||||
echo SHA=${GITHUB_REF#refs/heads/}-${GITHUB_SHA} >> $GITHUB_OUTPUT
|
|
||||||
echo RUN_URL=${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} >> $GITHUB_OUTPUT
|
|
||||||
echo COMMIT_URL=${{ github.server_url }}/${{ github.repository }}/commit/${GITHUB_SHA} >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
- name: Send Github Action failure to Slack
|
|
||||||
id: slack-notification
|
|
||||||
if: failure()
|
|
||||||
uses: slackapi/slack-github-action@v1.24.0
|
|
||||||
with:
|
with:
|
||||||
payload: |
|
msg: "[FAILED] Longevity Test"
|
||||||
{
|
slack_url: ${{ secrets.SLACK_WEBHOOK_URL }}
|
||||||
"text": "Longevity test failure - build: ${{ job.status }} - SHA: ${{ steps.sha-info.outputs.SHA }}",
|
|
||||||
"blocks": [
|
|
||||||
{
|
|
||||||
"type": "section",
|
|
||||||
"text": {
|
|
||||||
"type": "mrkdwn",
|
|
||||||
"text": "[FAILED] Longevity Checks :: <${{ steps.sha-info.outputs.RUN_URL }}|[Logs]> <${{ steps.sha-info.outputs.COMMIT_URL }}|[Base]>\nCommit: <${{ steps.sha-info.outputs.COMMIT_URL }}|${{ steps.sha-info.outputs.SHA }}>"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
env:
|
|
||||||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
|
|
||||||
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
|
|
||||||
|
|||||||
32
.github/workflows/nightly_test.yml
vendored
32
.github/workflows/nightly_test.yml
vendored
@ -120,33 +120,9 @@ jobs:
|
|||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
retention-days: 14
|
retention-days: 14
|
||||||
|
|
||||||
- name: SHA info
|
- name: Notify failure in slack
|
||||||
id: sha-info
|
|
||||||
if: failure()
|
if: failure()
|
||||||
run: |
|
uses: ./.github/actions/slack-message
|
||||||
echo ${GITHUB_REF#refs/heads/}-${GITHUB_SHA}
|
|
||||||
echo SHA=${GITHUB_REF#refs/heads/}-${GITHUB_SHA} >> $GITHUB_OUTPUT
|
|
||||||
echo RUN_URL=${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} >> $GITHUB_OUTPUT
|
|
||||||
echo COMMIT_URL=${{ github.server_url }}/${{ github.repository }}/commit/${GITHUB_SHA} >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
- name: Send Github Action failure to Slack
|
|
||||||
id: slack-notification
|
|
||||||
if: failure()
|
|
||||||
uses: slackapi/slack-github-action@v1.24.0
|
|
||||||
with:
|
with:
|
||||||
payload: |
|
msg: "[FAILED] Nightly Checks"
|
||||||
{
|
slack_url: ${{ secrets.SLACK_WEBHOOK_URL }}
|
||||||
"text": "Nightly test failure - build: ${{ job.status }} - SHA: ${{ steps.sha-info.outputs.SHA }}",
|
|
||||||
"blocks": [
|
|
||||||
{
|
|
||||||
"type": "section",
|
|
||||||
"text": {
|
|
||||||
"type": "mrkdwn",
|
|
||||||
"text": "[FAILED] Nightly Checks :: <${{ steps.sha-info.outputs.RUN_URL }}|[Logs]> <${{ steps.sha-info.outputs.COMMIT_URL }}|[Base]>\nCommit: <${{ steps.sha-info.outputs.COMMIT_URL }}|${{ steps.sha-info.outputs.SHA }}>"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
env:
|
|
||||||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
|
|
||||||
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
|
|
||||||
|
|||||||
32
.github/workflows/sanity-test.yaml
vendored
32
.github/workflows/sanity-test.yaml
vendored
@ -333,33 +333,9 @@ jobs:
|
|||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
retention-days: 14
|
retention-days: 14
|
||||||
|
|
||||||
- name: SHA info
|
- name: Notify failure in slack
|
||||||
id: sha-info
|
|
||||||
if: failure()
|
if: failure()
|
||||||
run: |
|
uses: ./.github/actions/slack-message
|
||||||
echo ${GITHUB_REF#refs/heads/}-${GITHUB_SHA}
|
|
||||||
echo SHA=${GITHUB_REF#refs/heads/}-${GITHUB_SHA} >> $GITHUB_OUTPUT
|
|
||||||
echo RUN_URL=${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} >> $GITHUB_OUTPUT
|
|
||||||
echo COMMIT_URL=${{ github.server_url }}/${{ github.repository }}/commit/${GITHUB_SHA} >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
- name: Send Github Action failure to Slack
|
|
||||||
id: slack-notification
|
|
||||||
if: failure()
|
|
||||||
uses: slackapi/slack-github-action@v1.24.0
|
|
||||||
with:
|
with:
|
||||||
payload: |
|
msg: "[FAILED] Sanity Tests"
|
||||||
{
|
slack_url: ${{ secrets.SLACK_WEBHOOK_URL }}
|
||||||
"text": "Sanity test failure - build: ${{ job.status }} - SHA: ${{ steps.sha-info.outputs.SHA }}",
|
|
||||||
"blocks": [
|
|
||||||
{
|
|
||||||
"type": "section",
|
|
||||||
"text": {
|
|
||||||
"type": "mrkdwn",
|
|
||||||
"text": "[FAILED] Sanity Checks :: <${{ steps.sha-info.outputs.RUN_URL }}|[Logs]> <${{ github.event.pull_request.html_url || github.event.head_commit.url }}|[Base]>\nCommit: <${{ steps.sha-info.outputs.COMMIT_URL }}|${{ steps.sha-info.outputs.SHA }}>"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
env:
|
|
||||||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
|
|
||||||
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
|
|
||||||
@ -21,6 +21,16 @@ You can run the linter manually or with the `Makefile` in the repository. Runnin
|
|||||||
the `Makefile` will also ensure you have the proper version of golangci-lint
|
the `Makefile` will also ensure you have the proper version of golangci-lint
|
||||||
installed.
|
installed.
|
||||||
|
|
||||||
|
### Running the actions linter
|
||||||
|
|
||||||
|
Installation:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
go install github.com/rhysd/actionlint/cmd/actionlint@latest
|
||||||
|
```
|
||||||
|
|
||||||
|
[Instructions for running locally.](https://github.com/rhysd/actionlint/blob/main/docs/usage.md)
|
||||||
|
|
||||||
### Running with the `Makefile`
|
### Running with the `Makefile`
|
||||||
|
|
||||||
There’s a `Makefile` in the corso/src that will automatically check if the proper
|
There’s a `Makefile` in the corso/src that will automatically check if the proper
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user