From a424d98946d6c0b1dc9183133404689b7c9ef48b Mon Sep 17 00:00:00 2001 From: Vlada Dusek Date: Mon, 27 Apr 2026 10:17:24 +0200 Subject: [PATCH] ci: Send Slack notification when scheduled e2e tests fail Adds a notify_on_failure job to the daily scheduled e2e workflow that posts to #tooling-team-python via SLACK_WEBHOOK_URL when any matrix combination fails. The message links to the workflow run and lists the failed jobs. Manual workflow_dispatch runs are skipped to avoid noise. --- .github/workflows/on_schedule_tests.yaml | 57 ++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/.github/workflows/on_schedule_tests.yaml b/.github/workflows/on_schedule_tests.yaml index da9a7fdba7..60c0177ba5 100644 --- a/.github/workflows/on_schedule_tests.yaml +++ b/.github/workflows/on_schedule_tests.yaml @@ -67,3 +67,60 @@ jobs: run: uv run poe e2e-templates-tests -m "${{ matrix.http-client }} and ${{ matrix.crawler-type }} and ${{ matrix.package-manager }}" env: APIFY_TEST_USER_API_TOKEN: ${{ secrets.APIFY_TEST_USER_API_TOKEN }} + + # Send a Slack notification to #tooling-team-python when scheduled e2e tests fail. + # Skipped on workflow_dispatch (manual runs) so that ad-hoc triggers don't spam the channel. + notify_on_failure: + name: Notify Slack on failure + needs: end_to_end_tests + if: failure() && github.event_name == 'schedule' + runs-on: ubuntu-latest + permissions: + contents: read + actions: read + + steps: + - name: Build Slack payload + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + REPO: ${{ github.repository }} + RUN_ID: ${{ github.run_id }} + RUN_ATTEMPT: ${{ github.run_attempt }} + WORKFLOW_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + HEADING: ':red_circle: Scheduled e2e tests failed' + run: | + failed_jobs=$(gh api \ + "repos/${REPO}/actions/runs/${RUN_ID}/attempts/${RUN_ATTEMPT}/jobs?per_page=100" \ + --jq '[.jobs[] | select(.conclusion == "failure") | "• \(.name)"] | join("\n")') + jq -n \ + --arg repo "${REPO}" \ + --arg url "${WORKFLOW_URL}" \ + --arg heading "${HEADING}" \ + --arg failed "${failed_jobs}" \ + '{ + text: "\($heading) in \($repo)", + blocks: [ + { + type: "header", + text: { type: "plain_text", text: $heading, emoji: true } + }, + { + type: "section", + fields: [ + { type: "mrkdwn", text: "*Repository:*\n\($repo)" }, + { type: "mrkdwn", text: "*Workflow run:*\n<\($url)|View on GitHub>" } + ] + }, + { + type: "section", + text: { type: "mrkdwn", text: "*Failed jobs:*\n\($failed)" } + } + ] + }' > slack-payload.json + + - name: Send Slack notification + uses: slackapi/slack-github-action@v3.0.2 + with: + webhook: ${{ secrets.SLACK_WEBHOOK_URL }} + webhook-type: incoming-webhook + payload-file-path: slack-payload.json