From 1ee769fcea4fafffb6f9cdd14c19a7fecabb7770 Mon Sep 17 00:00:00 2001 From: Sokratis Vidros Date: Thu, 9 May 2024 15:48:33 +0300 Subject: [PATCH] fix(actions): Consolidate slack notification logic on test failure (#5533) * Fixes for scheduled e2e (#5532) * fix(actions): Disable deployment only if e2e fails on next or prod * fix(actions): Disable all affected release workflows on e2e failure * fix(actions): Consolidate slack notification logic on test failure * fix(actions): Remove unused environment input The environment-specific SLACK_WEBHOOK_URL secret has been replaced with a repo-specific secret. --- .github/actions/slack/notify-on-failure.yml | 15 ++++++++ .github/workflows/reusable-api-e2e.yml | 22 +----------- .github/workflows/reusable-web-e2e.yml | 40 ++------------------- .github/workflows/reusable-widget-e2e.yml | 22 +----------- .github/workflows/scheduled_e2e.yml | 3 -- 5 files changed, 19 insertions(+), 83 deletions(-) create mode 100644 .github/actions/slack/notify-on-failure.yml diff --git a/.github/actions/slack/notify-on-failure.yml b/.github/actions/slack/notify-on-failure.yml new file mode 100644 index 00000000000..3ff8f141d2d --- /dev/null +++ b/.github/actions/slack/notify-on-failure.yml @@ -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 }} diff --git a/.github/workflows/reusable-api-e2e.yml b/.github/workflows/reusable-api-e2e.yml index bc71cdb2e17..17fb5b85f6a 100644 --- a/.github/workflows/reusable-api-e2e.yml +++ b/.github/workflows/reusable-api-e2e.yml @@ -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: @@ -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 @@ -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 diff --git a/.github/workflows/reusable-web-e2e.yml b/.github/workflows/reusable-web-e2e.yml index 65a31c2913e..eda94cfdc2b 100644 --- a/.github/workflows/reusable-web-e2e.yml +++ b/.github/workflows/reusable-web-e2e.yml @@ -11,10 +11,6 @@ on: required: false default: true type: boolean - environment: - required: false - default: 'Development' - type: string workflow_call: inputs: ee: @@ -22,15 +18,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: @@ -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 @@ -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 @@ -200,17 +185,7 @@ 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')" @@ -218,7 +193,6 @@ jobs: # 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: @@ -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 diff --git a/.github/workflows/reusable-widget-e2e.yml b/.github/workflows/reusable-widget-e2e.yml index 98b9200cec2..22e3c82d49a 100644 --- a/.github/workflows/reusable-widget-e2e.yml +++ b/.github/workflows/reusable-widget-e2e.yml @@ -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: @@ -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 @@ -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 diff --git a/.github/workflows/scheduled_e2e.yml b/.github/workflows/scheduled_e2e.yml index 00968969a6a..8277dd21f89 100644 --- a/.github/workflows/scheduled_e2e.yml +++ b/.github/workflows/scheduled_e2e.yml @@ -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: @@ -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: