From 4353079ed1d509f8c1452f1ceb73e4cf4d7d6a2b Mon Sep 17 00:00:00 2001 From: thepetk Date: Tue, 16 Jan 2024 17:01:37 +0000 Subject: [PATCH 1/4] Add slack notification for devfile go integration tests Signed-off-by: thepetk --- .github/workflows/gotest.yaml | 36 ++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/.github/workflows/gotest.yaml b/.github/workflows/gotest.yaml index 0e73762..b74edf5 100644 --- a/.github/workflows/gotest.yaml +++ b/.github/workflows/gotest.yaml @@ -52,8 +52,42 @@ jobs: - name: Run Go Tests run: make test + - name: Send slack notification + if: ${{ failure() && github.event_name == 'schedule' }} + uses: slackapi/slack-github-action@e28cf165c92ffef168d23c5c9000cffc8a25e117 # v1.24.0 + with: + channel-id: ${{ secrets.SLACK_CHANNEL_ID }} + payload: | + { + "text": "GitHub Action failed", + "blocks": [ + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "*Status:* :red_circle: failure\n*Severity:* medium\n*Title:* Devfile go integration tests\n*Description:* run failed for HEAD_REF ${{ github.ref }}" + } + }, + { + "type": "actions", + "elements": [ + { + "type": "button", + "text": { + "type": "plain_text", + "text": ":github: Failed action" + }, + "url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" + } + ] + } + ] + } + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK # - name: Upload Test Coverage results # uses: actions/upload-artifact@v2 # with: # name: lib-test-coverage-html -# path: tests/v2/lib-test-coverage.html \ No newline at end of file +# path: tests/v2/lib-test-coverage.html From cdd833a8549b2b24f5de5b887f964f3000e842f4 Mon Sep 17 00:00:00 2001 From: thepetk Date: Wed, 17 Jan 2024 13:08:10 +0000 Subject: [PATCH 2/4] Finalize slack notification step Signed-off-by: thepetk --- .github/workflows/gotest.yaml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/gotest.yaml b/.github/workflows/gotest.yaml index b74edf5..5add30c 100644 --- a/.github/workflows/gotest.yaml +++ b/.github/workflows/gotest.yaml @@ -2,25 +2,23 @@ name: Devfile Go integration tests on: push: - branches: [ main ] + branches: [main] pull_request: - branches: [ main ] + branches: [main] schedule: # every day at 9am EST - cron: 0 1 * * * jobs: - build: name: Run Tests strategy: matrix: - os: [ ubuntu-latest, macos-latest ] + os: [ubuntu-latest, macos-latest] runs-on: ${{ matrix.os }} continue-on-error: true timeout-minutes: 20 steps: - - name: Setup Go environment uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0 with: @@ -65,7 +63,7 @@ jobs: "type": "section", "text": { "type": "mrkdwn", - "text": "*Status:* :red_circle: failure\n*Severity:* medium\n*Title:* Devfile go integration tests\n*Description:* run failed for HEAD_REF ${{ github.ref }}" + "text": "*Status:* :red_circle: failure\n*Severity:* medium\n*Title:* Devfile go integration tests\n*Description:* run failed for ${{ github.ref }} - ${{ github.sha }}" } }, { From 89fbf332a97ff92e27201c3314732a479b046415 Mon Sep 17 00:00:00 2001 From: thepetk Date: Wed, 17 Jan 2024 14:17:28 +0000 Subject: [PATCH 3/4] Add sha and ref to code block Signed-off-by: thepetk --- .github/workflows/gotest.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gotest.yaml b/.github/workflows/gotest.yaml index 5add30c..2c62026 100644 --- a/.github/workflows/gotest.yaml +++ b/.github/workflows/gotest.yaml @@ -63,7 +63,7 @@ jobs: "type": "section", "text": { "type": "mrkdwn", - "text": "*Status:* :red_circle: failure\n*Severity:* medium\n*Title:* Devfile go integration tests\n*Description:* run failed for ${{ github.ref }} - ${{ github.sha }}" + "text": "*Status:* :red_circle: failure\n*Severity:* medium\n*Title:* Devfile go integration tests\n*Description:* run failed for `${{ github.ref }}` - `${{ github.sha }}`" } }, { From 5018e22b5c06d3b6fbf31cfee41c447901933e53 Mon Sep 17 00:00:00 2001 From: thepetk Date: Wed, 17 Jan 2024 16:37:53 +0000 Subject: [PATCH 4/4] Fix duplicate slack message issue Signed-off-by: thepetk --- .github/workflows/gotest.yaml | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/.github/workflows/gotest.yaml b/.github/workflows/gotest.yaml index 2c62026..dca5516 100644 --- a/.github/workflows/gotest.yaml +++ b/.github/workflows/gotest.yaml @@ -12,10 +12,10 @@ jobs: build: name: Run Tests strategy: + fail-fast: true matrix: os: [ubuntu-latest, macos-latest] runs-on: ${{ matrix.os }} - continue-on-error: true timeout-minutes: 20 steps: @@ -49,9 +49,19 @@ jobs: - name: Run Go Tests run: make test + # - name: Upload Test Coverage results + # uses: actions/upload-artifact@v2 + # with: + # name: lib-test-coverage-html + # path: tests/v2/lib-test-coverage.html - - name: Send slack notification - if: ${{ failure() && github.event_name == 'schedule' }} + slack_notification: + name: Send slack notification + runs-on: ubuntu-latest + if: ${{ always() && contains(join(needs.*.result, ','), 'failure') && github.event_name == 'schedule' }} + needs: [build] + steps: + - name: notify uses: slackapi/slack-github-action@e28cf165c92ffef168d23c5c9000cffc8a25e117 # v1.24.0 with: channel-id: ${{ secrets.SLACK_CHANNEL_ID }} @@ -84,8 +94,3 @@ jobs: env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK -# - name: Upload Test Coverage results -# uses: actions/upload-artifact@v2 -# with: -# name: lib-test-coverage-html -# path: tests/v2/lib-test-coverage.html