From 9aa32d9e81da08a8f0b2055b120b503c3bced66e Mon Sep 17 00:00:00 2001 From: Youjung Kim <126618609+ykim-1@users.noreply.github.com> Date: Fri, 27 Sep 2024 13:24:03 -0700 Subject: [PATCH] test: Add slack notifications to integraion test workflow (#592) * add slack notifications to integration-tests.yml * fix lint error * fix lint error * fix build result text syntax --- .github/workflows/integration-tests.yml | 70 ++++++++++++++++++++++++- Makefile | 2 +- 2 files changed, 69 insertions(+), 3 deletions(-) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 564f143d..ecc77c01 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -8,7 +8,7 @@ on: - dev jobs: - run-tests: + integration-tests: runs-on: ubuntu-latest env: EXIT_STATUS: 0 @@ -78,7 +78,7 @@ jobs: process-upload-report: runs-on: ubuntu-latest needs: [run-tests] - if: always() # Run even if previous job fails + if: always() && github.repository == 'linode/ansible_linode' steps: - name: Checkout code @@ -127,3 +127,69 @@ jobs: env: LINODE_CLI_OBJ_ACCESS_KEY: ${{ secrets.LINODE_CLI_OBJ_ACCESS_KEY }} LINODE_CLI_OBJ_SECRET_KEY: ${{ secrets.LINODE_CLI_OBJ_SECRET_KEY }} + + notify-slack: + runs-on: ubuntu-latest + needs: [integration-tests] + if: always() && github.repository == 'linode/ansible_linode' # Run even if integration tests fail and only on main repository + + steps: + - name: Notify Slack + uses: slackapi/slack-github-action@v1.27.0 + with: + channel-id: ${{ secrets.SLACK_CHANNEL_ID }} + payload: | + { + "blocks": [ + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": ":rocket: *${{ github.workflow }} Completed in: ${{ github.repository }}* :white_check_mark:" + } + }, + { + "type": "divider" + }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Build Result:*\n${{ needs.integration-tests.result == 'success' && ':large_green_circle: Build Passed' || ':red_circle: Build Failed' }}" + }, + { + "type": "mrkdwn", + "text": "*Branch:*\n`${{ github.ref_name }}`" + } + ] + }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Commit Hash:*\n<${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}|${{ github.sha }}>" + }, + { + "type": "mrkdwn", + "text": "*Run URL:*\n<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Run Details>" + } + ] + }, + { + "type": "divider" + }, + { + "type": "context", + "elements": [ + { + "type": "mrkdwn", + "text": "Triggered by: :bust_in_silhouette: `${{ github.actor }}`" + } + ] + } + ] + } + env: + SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} \ No newline at end of file diff --git a/Makefile b/Makefile index a5d6dcf2..3bcf736a 100644 --- a/Makefile +++ b/Makefile @@ -30,7 +30,7 @@ deps: pip install -r requirements.txt -r requirements-dev.txt --upgrade lint: - pylint plugins + pylint --disable=too-many-positional-arguments plugins mypy plugins/modules mypy plugins/inventory