From e36fa988df3df19e4b78420f8e402400526bbf0e Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Mon, 13 May 2024 10:39:31 +0100 Subject: [PATCH] Send notification when a test passes unexpectedly See gh-210 --- .github/actions/send-notification/action.yml | 5 ++++- .github/workflows/smoke-test.yml | 7 ++++--- .../src/main/resources/smoke-test.yml | 7 ++++--- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/actions/send-notification/action.yml b/.github/actions/send-notification/action.yml index b8b4a881..0c4c6711 100644 --- a/.github/actions/send-notification/action.yml +++ b/.github/actions/send-notification/action.yml @@ -16,9 +16,12 @@ inputs: webhook-url: description: 'Google Chat Webhook URL' required: true + outcome-description: + required: false + default: 'failed' runs: using: composite steps: - shell: bash run: | - curl -s -o /dev/null -X POST '${{ inputs.webhook-url }}' -H 'Content-Type: application/json' -d "{ text: \"${{ inputs.owner-ids }} ${{ inputs.task }} <${{ inputs.failure-url }}|failed> on ${{ inputs.branch }} \"}" || true + curl -s -o /dev/null -X POST '${{ inputs.webhook-url }}' -H 'Content-Type: application/json' -d "{ text: \"${{ inputs.owner-ids }} ${{ inputs.task }} <${{ inputs.failure-url }}|${{ inputs.outcome-description }}> on ${{ inputs.branch }} \"}" || true diff --git a/.github/workflows/smoke-test.yml b/.github/workflows/smoke-test.yml index 4d792c9f..686041c7 100644 --- a/.github/workflows/smoke-test.yml +++ b/.github/workflows/smoke-test.yml @@ -61,13 +61,13 @@ jobs: continue-on-error: ${{ inputs.expected_to_fail }} - name: Check out send notification action uses: actions/checkout@v4 - if: ${{ failure() }} + if: ${{ failure() || (steps.build.outcome == 'success' && inputs.expected_to_fail)}} with: path: ci ref: ci sparse-checkout: .github/actions/send-notification - name: Determine owner ID secret names - if: ${{ failure() }} + if: ${{ failure() || (steps.build.outcome == 'success' && inputs.expected_to_fail)}} run: | projectName=$(echo ${{ inputs.project }} | tr '[:lower:]:-' '[:upper:]__') groupName=$(echo $projectName | awk '{print substr($1, 0, index($1, "_") - 1)}') @@ -75,10 +75,11 @@ jobs: echo SECRET_NAME_OWNER_IDS_GROUP=OWNER_IDS_${groupName} >> $GITHUB_ENV - name: Send notification uses: ./ci/.github/actions/send-notification - if: ${{ failure() }} + if: ${{ failure() || (steps.build.outcome == 'success' && inputs.expected_to_fail)}} with: webhook-url: ${{ secrets.GOOGLE_CHAT_WEBHOOK_URL }} task: ${{ inputs.project }}:${{ inputs.task }} owner-ids: ${{ secrets[env.SECRET_NAME_OWNER_IDS_PROJECT] || secrets[env.SECRET_NAME_OWNER_IDS_GROUP]}} branch: ${{ inputs.checkout_ref }} failure-url: ${{ steps.build.outputs.build-scan-url || format('{0}/{1}/actions/runs/{2}', github.server_url, github.repository, github.run_id) }} + outcome-description: ${{ inputs.expected_to_fail && 'passed unexpectedly' || 'failed' }} diff --git a/gradle/plugins/aot-smoke-test-ci-plugin/src/main/resources/smoke-test.yml b/gradle/plugins/aot-smoke-test-ci-plugin/src/main/resources/smoke-test.yml index 4d792c9f..686041c7 100644 --- a/gradle/plugins/aot-smoke-test-ci-plugin/src/main/resources/smoke-test.yml +++ b/gradle/plugins/aot-smoke-test-ci-plugin/src/main/resources/smoke-test.yml @@ -61,13 +61,13 @@ jobs: continue-on-error: ${{ inputs.expected_to_fail }} - name: Check out send notification action uses: actions/checkout@v4 - if: ${{ failure() }} + if: ${{ failure() || (steps.build.outcome == 'success' && inputs.expected_to_fail)}} with: path: ci ref: ci sparse-checkout: .github/actions/send-notification - name: Determine owner ID secret names - if: ${{ failure() }} + if: ${{ failure() || (steps.build.outcome == 'success' && inputs.expected_to_fail)}} run: | projectName=$(echo ${{ inputs.project }} | tr '[:lower:]:-' '[:upper:]__') groupName=$(echo $projectName | awk '{print substr($1, 0, index($1, "_") - 1)}') @@ -75,10 +75,11 @@ jobs: echo SECRET_NAME_OWNER_IDS_GROUP=OWNER_IDS_${groupName} >> $GITHUB_ENV - name: Send notification uses: ./ci/.github/actions/send-notification - if: ${{ failure() }} + if: ${{ failure() || (steps.build.outcome == 'success' && inputs.expected_to_fail)}} with: webhook-url: ${{ secrets.GOOGLE_CHAT_WEBHOOK_URL }} task: ${{ inputs.project }}:${{ inputs.task }} owner-ids: ${{ secrets[env.SECRET_NAME_OWNER_IDS_PROJECT] || secrets[env.SECRET_NAME_OWNER_IDS_GROUP]}} branch: ${{ inputs.checkout_ref }} failure-url: ${{ steps.build.outputs.build-scan-url || format('{0}/{1}/actions/runs/{2}', github.server_url, github.repository, github.run_id) }} + outcome-description: ${{ inputs.expected_to_fail && 'passed unexpectedly' || 'failed' }}