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

Notify tests fails to slack #1082

Merged
merged 1 commit into from
Aug 21, 2023
Merged
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
39 changes: 39 additions & 0 deletions .github/workflows/notify_slack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Notify Slack
on:
workflow_call:
inputs:
result:
type: string
required: true
run_id:
type: string
required: false
workflow_name:
noaKurman marked this conversation as resolved.
Show resolved Hide resolved
type: string
required: true

jobs:
notify:
name: Notify Slack Failure
runs-on: ubuntu-latest
if: ${{ inputs.result == 'failure' }}
Copy link
Member

@elongl elongl Aug 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The caller should choose when to call this job.
If someone called Notify Slack it should run.
Would also change the name to be Notify Slack and not Notify Slack Failure to remain generic.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm coloring the message, so if we'll want to add a "success" message we'll add another job with a different if statement. For now doesn't feel like a big deal in the implementation

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're not going to change it, then I think we should rename this workflow and step to notify_slack_failure and remove the if.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I might add a success job. thats what I'm saying

steps:
- name: Slack Notification
uses: tokorom/action-slack-incoming-webhook@main
env:
INCOMING_WEBHOOK_URL: ${{ secrets.DEPLOY_SLACK_WEBHOOK_URL }}
with:
text: Scheduled Run Failed - ${{ inputs.workflow_name }}
attachments: |
[
{
"color": "danger",
"fields":
[
{
"title": "URL:",
"value": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ inputs.run_id }}"
}
]
}
]
14 changes: 14 additions & 0 deletions .github/workflows/test-all-warehouses.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,17 @@ jobs:
dbt-version: ${{ matrix.dbt-version }}
generate-data: ${{ inputs.generate-data || false }}
secrets: inherit

notify_failures:
noaKurman marked this conversation as resolved.
Show resolved Hide resolved
name: Notify Slack
needs: test
if: |
always() &&
contains(needs.test.result, 'failure') &&
noaKurman marked this conversation as resolved.
Show resolved Hide resolved
elongl marked this conversation as resolved.
Show resolved Hide resolved
# ! cancelled() &&
${{ github.event_name == 'schedule' }}
uses: ./.github/workflows/notify_slack.yml
with:
result: "failure"
run_id: ${{ github.run_id }}
workflow_name: "Test all warehouse platforms"
14 changes: 14 additions & 0 deletions .github/workflows/test-github-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,17 @@ jobs:
with:
name: edr.log
path: edr_target/edr.log

notify_failures:
name: Notify Slack
needs: test
if: |
always() &&
contains(needs.test.result, 'failure') &&
! cancelled() &&
${{ github.event_name == 'schedule' }}
uses: ./.github/workflows/notify_slack.yml
with:
result: "failure"
run_id: ${{ github.run_id }}
workflow_name: "Test Elementary GitHub action"