Skip to content

Commit

Permalink
feat(EWT-193): Slack notification for failed scheduled acceptance tes…
Browse files Browse the repository at this point in the history
…ts (#257)
  • Loading branch information
dili91 authored Dec 21, 2023
1 parent c7cabf0 commit d6b7222
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 2 deletions.
56 changes: 55 additions & 1 deletion .github/workflows/acceptance-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -17,6 +22,8 @@ on:
required: true
tl_signing_private_key:
required: true
slack_webhook_url:
required: false

jobs:
acceptance-tests:
Expand All @@ -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
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"
}
]
}
4 changes: 3 additions & 1 deletion .github/workflows/workflow-scheduled-acceptance-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
tl_signing_private_key: ${{ secrets.ACCEPTANCE_TEST_SIGNING_PRIVATE_KEY }}
slack_webhook_url: ${{ secrets.SLACK_WEBHOOK_URL}}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit d6b7222

Please sign in to comment.