From d6b7222bd6efd4d7e2e44c5206d54197e7ecf7be Mon Sep 17 00:00:00 2001 From: Andrea Di Lisio Date: Thu, 21 Dec 2023 17:25:14 +0100 Subject: [PATCH 1/2] feat(EWT-193): Slack notification for failed scheduled acceptance tests (#257) --- .github/workflows/acceptance-tests.yml | 56 ++++++++++++++++++- .../workflow-scheduled-acceptance-tests.yml | 4 +- README.md | 1 + 3 files changed, 59 insertions(+), 2 deletions(-) diff --git a/.github/workflows/acceptance-tests.yml b/.github/workflows/acceptance-tests.yml index 494c90a2..f862c838 100644 --- a/.github/workflows/acceptance-tests.yml +++ b/.github/workflows/acceptance-tests.yml @@ -8,6 +8,11 @@ on: description: 'The reference to checkout before running the acceptance tests. Used to run the tests on a fork.' required: true type: string + notify_slack_on_failure: + description: 'Whether to notify slack or not.' + required: false + default: false + type: boolean secrets: tl_client_id: required: true @@ -17,6 +22,8 @@ on: required: true tl_signing_private_key: required: true + slack_webhook_url: + required: false jobs: acceptance-tests: @@ -39,4 +46,51 @@ jobs: TL_CLIENT_SECRET: ${{ secrets.tl_client_secret }} TL_SIGNING_KEY_ID: ${{ secrets.tl_signing_key_id }} TL_SIGNING_PRIVATE_KEY: ${{ secrets.tl_signing_private_key }} - run: ./gradlew acceptance-tests \ No newline at end of file + run: ./gradlew acceptance-tests + notify-slack: + needs: acceptance-tests + runs-on: ubuntu-latest + if: ${{ always() && contains(needs.*.result, 'failure') && inputs.notify_slack_on_failure == true }} + steps: + - name: Notify slack + uses: slackapi/slack-github-action@v1.24.0 + env: + SLACK_WEBHOOK_URL: ${{ secrets.slack_webhook_url }} + # type is required for custom payloads + SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK + with: + payload: | + { + "blocks": [ + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": ":fire: *Acceptance tests* are failing in *Sandbox* on our *Java* backend library! :java:" + } + }, + { + "type": "actions", + "elements": [ + { + "type": "button", + "text": { + "type": "plain_text", + "text": ":eyes: View on Github" + }, + "url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" + } + ] + }, + { + "type": "image", + "title": { + "type": "plain_text", + "text": "I don't like that", + "emoji": true + }, + "image_url": "https://media.giphy.com/media/4cuyucPeVWbNS/giphy.gif", + "alt_text": "marg" + } + ] + } \ No newline at end of file diff --git a/.github/workflows/workflow-scheduled-acceptance-tests.yml b/.github/workflows/workflow-scheduled-acceptance-tests.yml index 89a855ce..a63be40f 100644 --- a/.github/workflows/workflow-scheduled-acceptance-tests.yml +++ b/.github/workflows/workflow-scheduled-acceptance-tests.yml @@ -10,8 +10,10 @@ jobs: uses: ./.github/workflows/acceptance-tests.yml with: checkout_ref: /refs/heads/main + notify_slack_on_failure: true secrets: tl_client_id: ${{ secrets.ACCEPTANCE_TEST_CLIENT_ID }} tl_client_secret: ${{ secrets.ACCEPTANCE_TEST_CLIENT_SECRET }} tl_signing_key_id: ${{ secrets.ACCEPTANCE_TEST_SIGNING_KEY_ID }} - tl_signing_private_key: ${{ secrets.ACCEPTANCE_TEST_SIGNING_PRIVATE_KEY }} \ No newline at end of file + tl_signing_private_key: ${{ secrets.ACCEPTANCE_TEST_SIGNING_PRIVATE_KEY }} + slack_webhook_url: ${{ secrets.SLACK_WEBHOOK_URL}} \ No newline at end of file diff --git a/README.md b/README.md index a96ac0fa..4cf0fd6d 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.truelayer/truelayer-java/badge.svg?style=flat)](https://search.maven.org/artifact/com.truelayer/truelayer-java) [![javadoc](https://javadoc.io/badge2/com.truelayer/truelayer-java/javadoc.svg)](https://javadoc.io/doc/com.truelayer/truelayer-java) [![Coverage Status](https://coveralls.io/repos/github/TrueLayer/truelayer-java/badge.svg?t=gcGKQv)](https://coveralls.io/github/TrueLayer/truelayer-java) +[![Scheduled acceptance tests](https://github.com/TrueLayer/truelayer-java/actions/workflows/scheduled-acceptance-tests.yml/badge.svg)](https://github.com/TrueLayer/truelayer-java/actions/workflows/scheduled-acceptance-tests.yml) [![License](https://img.shields.io/:license-mit-blue.svg)](https://truelayer.mit-license.org/) The official [TrueLayer](https://truelayer.com) Java client provides convenient access to TrueLayer APIs from applications built with Java. From 617ead00761fd0a1084ec226e3167170194ba552 Mon Sep 17 00:00:00 2001 From: Andrea Di Lisio Date: Fri, 22 Dec 2023 10:04:36 +0100 Subject: [PATCH 2/2] fix(EWT-193): schedule acceptance test fix (#263) [skip ci] --- .github/workflows/workflow-scheduled-acceptance-tests.yml | 5 +++-- README.md | 3 +-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/workflow-scheduled-acceptance-tests.yml b/.github/workflows/workflow-scheduled-acceptance-tests.yml index a63be40f..15304bfe 100644 --- a/.github/workflows/workflow-scheduled-acceptance-tests.yml +++ b/.github/workflows/workflow-scheduled-acceptance-tests.yml @@ -3,14 +3,15 @@ name: Scheduled acceptance tests in Sandbox environment on: schedule: - - cron: "0 7-19/2 * * *" # every 2 hours between 10 and 20 (UTC) + # every hour between 8 and 19 UTC time + - cron: "0 8-19/1 * * *" jobs: scheduled-acceptance-tests: uses: ./.github/workflows/acceptance-tests.yml with: - checkout_ref: /refs/heads/main notify_slack_on_failure: true + checkout_ref: main secrets: tl_client_id: ${{ secrets.ACCEPTANCE_TEST_CLIENT_ID }} tl_client_secret: ${{ secrets.ACCEPTANCE_TEST_CLIENT_SECRET }} diff --git a/README.md b/README.md index 4cf0fd6d..5c36165f 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,9 @@ # TrueLayer Java -[![Release final version](https://github.com/TrueLayer/truelayer-java/actions/workflows/release-final.yml/badge.svg)](https://github.com/TrueLayer/truelayer-java/actions/workflows/release-final.yml) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.truelayer/truelayer-java/badge.svg?style=flat)](https://search.maven.org/artifact/com.truelayer/truelayer-java) [![javadoc](https://javadoc.io/badge2/com.truelayer/truelayer-java/javadoc.svg)](https://javadoc.io/doc/com.truelayer/truelayer-java) [![Coverage Status](https://coveralls.io/repos/github/TrueLayer/truelayer-java/badge.svg?t=gcGKQv)](https://coveralls.io/github/TrueLayer/truelayer-java) -[![Scheduled acceptance tests](https://github.com/TrueLayer/truelayer-java/actions/workflows/scheduled-acceptance-tests.yml/badge.svg)](https://github.com/TrueLayer/truelayer-java/actions/workflows/scheduled-acceptance-tests.yml) +[![Scheduled acceptance tests in Sandbox environment](https://github.com/TrueLayer/truelayer-java/actions/workflows/workflow-scheduled-acceptance-tests.yml/badge.svg)](https://github.com/TrueLayer/truelayer-java/actions/workflows/workflow-scheduled-acceptance-tests.yml) [![License](https://img.shields.io/:license-mit-blue.svg)](https://truelayer.mit-license.org/) The official [TrueLayer](https://truelayer.com) Java client provides convenient access to TrueLayer APIs from applications built with Java.