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

fix(actions): Consolidate slack notification logic on test failure #5533

Merged
merged 4 commits into from
May 9, 2024
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
15 changes: 15 additions & 0 deletions .github/actions/slack/notify-on-failure.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: 'Notify Slack on workflow failure'
runs:
using: "composite"
steps:
- name: Notify Slack Action
uses: ravsamhq/notify-slack-action@v2
if: ${{ always() && github.ref_name == 'next' || github.ref_name == 'main' || github.ref_name == 'prod' }}
with:
footer: "Run: {run_url}\nCommit: {commit_url}"
message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}>"
notification_title: "{workflow} is now failing!"
notify_when: "failure"
status: "failure"
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL_ENG_FEED_GITHUB }}
22 changes: 1 addition & 21 deletions .github/workflows/reusable-api-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,6 @@ on:
description: 'job name [options: novu/api-ee, novu/api]'
required: true
type: string
slack_notification:
description: 'notify if e2e fail via slack'
required: false
default: false
type: boolean
environment:
required: false
default: 'Development'
type: string

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
Expand All @@ -56,7 +47,6 @@ jobs:
if: ${{ (contains(inputs.job-name, '-ee') && inputs.test-e2e-ee-affected) || (!contains(inputs.job-name, '-ee') && inputs.test-e2e-affected) }}
runs-on: ubuntu-latest
timeout-minutes: 80
environment: ${{ inputs.environment }}
permissions:
contents: read
packages: write
Expand Down Expand Up @@ -122,14 +112,4 @@ jobs:
run: |
cd apps/api && pnpm test

- name: Notify Slack Action
uses: ravsamhq/notify-slack-action@v2
if: ${{ always() && inputs.slack_notification }}
with:
status: ${{ job.status }}
notification_title: "{workflow} for API has {status_message}"
message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}>"
footer: "Linked Run URL {run_url}\nCommit URL{commit_url}"
notify_when: "failure"
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
- uses: ./.github/actions/slack/notify-on-failure
40 changes: 2 additions & 38 deletions .github/workflows/reusable-web-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,13 @@ on:
required: false
default: true
type: boolean
environment:
required: false
default: 'Development'
type: string
workflow_call:
inputs:
ee:
description: 'use the ee version of worker'
required: false
default: false
type: boolean
slack_notification:
description: 'notify if e2e fail via slack'
required: false
default: false
type: boolean
environment:
required: false
default: 'Development'
type: string

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
Expand All @@ -52,7 +39,6 @@ jobs:
# The type of runner that the job will run on
runs-on: ubuntu-latest
timeout-minutes: 80
environment: ${{ inputs.environment }}

permissions:
contents: read
Expand Down Expand Up @@ -175,7 +161,6 @@ jobs:
# Merge reports after playwright-tests, even if some shards have failed
if: ${{ !cancelled() }}
needs: [e2e_web]
environment: ${{ inputs.environment }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -200,25 +185,14 @@ jobs:
path: playwright-report
retention-days: 14

- name: Notify Slack Action
uses: ravsamhq/notify-slack-action@v2
if: ${{ inputs.slack_notification && needs.e2e_web.result == 'failure' }}
with:
status: "failure"
notification_title: "{workflow} for WEB has failed"
message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}>"
footer: "Linked Run URL {run_url}\nCommit URL{commit_url}"
notify_when: "failure"
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
- uses: ./.github/actions/slack/notify-on-failure

component_web:
if: "!contains(github.event.head_commit.message, 'ci skip')"

# The type of runner that the job will run on
runs-on: ubuntu-latest
timeout-minutes: 80
environment: ${{ inputs.environment }}

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
Expand Down Expand Up @@ -257,14 +231,4 @@ jobs:
name: cypress-screenshots
path: apps/web/cypress/screenshots

- name: Notify Slack Action
uses: ravsamhq/notify-slack-action@v2
if: ${{ always() && inputs.slack_notification }}
with:
status: ${{ job.status }}
notification_title: "{workflow} for Component WEB has {status_message}"
message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}>"
footer: "Linked Run URL {run_url}\nCommit URL{commit_url}"
notify_when: "failure"
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
- uses: ./.github/actions/slack/notify-on-failure
22 changes: 1 addition & 21 deletions .github/workflows/reusable-widget-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,6 @@ on:
required: false
default: false
type: boolean
slack_notification:
description: 'notify if e2e fail via slack'
required: false
default: false
type: boolean
environment:
required: false
default: 'Development'
type: string

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
Expand All @@ -27,7 +18,6 @@ jobs:
# The type of runner that the job will run on
runs-on: ubuntu-latest
timeout-minutes: 80
environment: ${{ inputs.environment }}
permissions:
contents: read
packages: write
Expand Down Expand Up @@ -122,14 +112,4 @@ jobs:
name: cypress-videos
path: apps/widget/cypress/videos

- name: Notify Slack Action
uses: ravsamhq/notify-slack-action@v2
if: ${{ always() && inputs.slack_notification }}
with:
status: ${{ job.status }}
notification_title: "{workflow} for Widget has {status_message}"
message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}>"
footer: "Linked Run URL {run_url}\nCommit URL{commit_url}"
notify_when: "failure"
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
- uses: ./.github/actions/slack/notify-on-failure
3 changes: 0 additions & 3 deletions .github/workflows/scheduled_e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,12 @@ jobs:
secrets: inherit
with:
ee: true
slack_notification: true

test_widget:
name: Test Widget Cypress
uses: ./.github/workflows/reusable-widget-e2e.yml
with:
ee: true
slack_notification: true
secrets: inherit

test_unit_api:
Expand All @@ -44,7 +42,6 @@ jobs:
test-e2e-affected: true
test-e2e-ee-affected: true
job-name: ${{ matrix.name }}
slack_notification: true
secrets: inherit

release_decision:
Expand Down
Loading