From ab6f7ac59679c7ea03a229e07c85783fd988a464 Mon Sep 17 00:00:00 2001 From: Tzahi Taub Date: Sun, 15 Oct 2023 23:09:17 +0300 Subject: [PATCH] test(JSON-RPC): send a slack alert upon GW integration test failure --- .github/workflows/nightly-tests-call.yml | 22 ++++++++++++++++++++-- .github/workflows/nightly-tests.yml | 4 ++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/.github/workflows/nightly-tests-call.yml b/.github/workflows/nightly-tests-call.yml index 5cdc0ad634..bd13045eb0 100644 --- a/.github/workflows/nightly-tests-call.yml +++ b/.github/workflows/nightly-tests-call.yml @@ -11,6 +11,10 @@ on: required: true INTEGRATION_TESTNET_SENDER_PRIVATE_KEY: required: true + SLACK_BOT_TOKEN: + required: true + SLACK_ALERT_CHANNEL: + required: true jobs: GW-integration-test-call: @@ -25,13 +29,27 @@ jobs: # run. As we want to keep running this step after a test failure we can either start with # `set +e` to suppress all errors, or, as done below, append `|| retVal=$?` to the command # which makes it successful while storing the potential erroneous code. - - run: > + - id: run_test + run: > sudo apt update; sudo apt -y install libclang-dev; INTEGRATION_TESTNET_NODE_URL=${{ secrets.INTEGRATION_TESTNET_NODE_URL }} SENDER_PRIVATE_KEY=${{ secrets.INTEGRATION_TESTNET_SENDER_PRIVATE_KEY }} cargo test --test gateway_integration_test -p papyrus_rpc test_gw_integration_testnet -- --ignored || retVal=$?; + echo "retVal=$retVal" >> $GITHUB_OUTPUT; if [ $retVal -ne 0 ]; then echo "Integration test failed with exit code $retVal"; fi; - exit $retVal + - name: In case of a failure - post to a Slack channel. + id: slack + if: ${{ steps.run_test.outputs.retVal }} != 0 + uses: slackapi/slack-github-action@v1.24.0 + with: + channel-id: ${{ secrets.SLACK_ALERT_CHANNEL }} + slack-message: > + gateway_integration_test failed with exit code: ${{ steps.run_test.outputs.retVal }}, + see + <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}| + logs>. + env: + SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} diff --git a/.github/workflows/nightly-tests.yml b/.github/workflows/nightly-tests.yml index d14b91475a..ac9ea76923 100644 --- a/.github/workflows/nightly-tests.yml +++ b/.github/workflows/nightly-tests.yml @@ -14,6 +14,8 @@ jobs: secrets: INTEGRATION_TESTNET_NODE_URL: ${{ secrets.INTEGRATION_TESTNET_NODE_URL }} INTEGRATION_TESTNET_SENDER_PRIVATE_KEY: ${{ secrets.INTEGRATION_TESTNET_SENDER_PRIVATE_KEY }} + SLACK_ALERT_CHANNEL: ${{ secrets.SLACK_ALERT_CHANNEL }} + SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} if: github.event.schedule != '30 3 * * *' GW-integration-test-macos: @@ -23,6 +25,8 @@ jobs: secrets: INTEGRATION_TESTNET_NODE_URL: ${{ secrets.INTEGRATION_TESTNET_NODE_URL }} INTEGRATION_TESTNET_SENDER_PRIVATE_KEY: ${{ secrets.INTEGRATION_TESTNET_SENDER_PRIVATE_KEY }} + SLACK_ALERT_CHANNEL: ${{ secrets.SLACK_ALERT_CHANNEL }} + SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} if: github.event.schedule == '30 3 * * *'