From 836271fddf307a41936eeb7e31660800a18b5074 Mon Sep 17 00:00:00 2001 From: William Bezuidenhout Date: Mon, 18 Dec 2023 18:06:50 +0200 Subject: [PATCH] github-actions: report run failures to sentry (#59060) * github-actions: report run failures to sentry * report job name as well * make buildchecker action consistent --- .github/workflows/buildchecker.yml | 4 ++-- .github/workflows/licenses-update.yml | 14 ++++++++++++++ .github/workflows/pr-auditor.yml | 13 +++++++++++++ .github/workflows/sg-binary-release.yml | 14 ++++++++++++++ .github/workflows/tracking-issue.yml | 14 ++++++++++++++ .github/workflows/universal-ctags.yml | 13 +++++++++++++ 6 files changed, 70 insertions(+), 2 deletions(-) diff --git a/.github/workflows/buildchecker.yml b/.github/workflows/buildchecker.yml index 2e5ed48bb20..8878b6c605d 100644 --- a/.github/workflows/buildchecker.yml +++ b/.github/workflows/buildchecker.yml @@ -27,11 +27,11 @@ jobs: SLACK_ANNOUNCE_WEBHOOK: ${{ secrets.AUTOBUILDSHERRIF_SLACK_WEBHOOK }} SLACK_DEBUG_WEBHOOK: ${{ secrets.AUTOBUILDSHERRIF_SLACK_DEBUG_WEBHOOK }} SLACK_TOKEN: ${{ secrets.AUTOBUILDSHERRIF_SLACK_TOKEN }} - - name: report failure to sentry + - name: Report failure to sentry if: ${{ failure() }} run: | npm i -g @sentry/cli - sentry-cli send-event -m 'buildchecker action failure - see run for exact failure' \ + sentry-cli send-event -m "Job '$GITHUB_JOB' in the $GITHUB_WORKFLOW action has failed - see run for exact failure" \ -t "github-action:$GITHUB_WORKFLOW" \ -t "branch:$GITHUB_REF_NAME" \ -t "repository:$GITHUB_REPOSITORY" \ diff --git a/.github/workflows/licenses-update.yml b/.github/workflows/licenses-update.yml index 0aaed4967b6..e2f3780497d 100644 --- a/.github/workflows/licenses-update.yml +++ b/.github/workflows/licenses-update.yml @@ -57,3 +57,17 @@ jobs: token: ${{ secrets.GH_REPO_TOKEN }} pull-request-number: ${{ steps.cpr.outputs.pull-request-number }} merge-method: squash + + - name: Report failure to sentry + if: ${{ failure() }} + run: | + npm i -g @sentry/cli + sentry-cli send-event -m "Job '$GITHUB_JOB' in the $GITHUB_WORKFLOW action has failed - see run for exact failure" \ + -t "github-action:$GITHUB_WORKFLOW" \ + -t "branch:$GITHUB_REF_NAME" \ + -t "repository:$GITHUB_REPOSITORY" \ + -t "workflow-run:$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" + env: + SENTRY_DSN: ${{ secrets.SENTRY_DEV_INFRA_DSN }} + SENTRY_ORG: sourcegraph + SENTRY_PROJECT: dev-infra diff --git a/.github/workflows/pr-auditor.yml b/.github/workflows/pr-auditor.yml index 33bfe9bb128..e9c035233aa 100644 --- a/.github/workflows/pr-auditor.yml +++ b/.github/workflows/pr-auditor.yml @@ -20,3 +20,16 @@ jobs: GITHUB_EVENT_PATH: ${{ env.GITHUB_EVENT_PATH }} GITHUB_TOKEN: ${{ secrets.PR_AUDITOR_TOKEN }} GITHUB_RUN_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} + - name: Report failure to sentry + if: ${{ failure() }} + run: | + npm i -g @sentry/cli + sentry-cli send-event -m "Job $GITHUB_JOB in the $GITHUB_WORKFLOW action has failed - see run for exact failure" \ + -t "github-action:$GITHUB_WORKFLOW" \ + -t "branch:$GITHUB_REF_NAME" \ + -t "repository:$GITHUB_REPOSITORY" \ + -t "workflow-run:$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" + env: + SENTRY_DSN: ${{ secrets.SENTRY_DEV_INFRA_DSN }} + SENTRY_ORG: sourcegraph + SENTRY_PROJECT: dev-infra diff --git a/.github/workflows/sg-binary-release.yml b/.github/workflows/sg-binary-release.yml index 6fafc236785..0ff090d1f2d 100644 --- a/.github/workflows/sg-binary-release.yml +++ b/.github/workflows/sg-binary-release.yml @@ -125,3 +125,17 @@ jobs: env: repo: sourcegraph/sg GITHUB_TOKEN: ${{ secrets.SG_RELEASE_TOKEN }} + + - name: Report failure to sentry + if: ${{ failure() }} + run: | + npm i -g @sentry/cli + sentry-cli send-event -m "Job '$GITHUB_JOB' in the $GITHUB_WORKFLOW action has failed - see run for exact failure" \ + -t "github-action:$GITHUB_WORKFLOW" \ + -t "branch:$GITHUB_REF_NAME" \ + -t "repository:$GITHUB_REPOSITORY" \ + -t "workflow-run:$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" + env: + SENTRY_DSN: ${{ secrets.SENTRY_DEV_INFRA_DSN }} + SENTRY_ORG: sourcegraph + SENTRY_PROJECT: dev-infra diff --git a/.github/workflows/tracking-issue.yml b/.github/workflows/tracking-issue.yml index 7031b07765a..16e401ed3eb 100644 --- a/.github/workflows/tracking-issue.yml +++ b/.github/workflows/tracking-issue.yml @@ -10,3 +10,17 @@ jobs: - uses: docker://sourcegraph/tracking-issue:latest env: GITHUB_TOKEN: ${{ secrets.TRACKING_ISSUE_SYNCER_TOKEN_DEVX_BOT }} + - name: Report failure to sentry + if: ${{ failure() }} + run: | + npm i -g @sentry/cli + sentry-cli send-event -m "Job '$GITHUB_JOB' in the $GITHUB_WORKFLOW action has failed - see run for exact failure" \ + -t "github-action:$GITHUB_WORKFLOW" \ + -t "branch:$GITHUB_REF_NAME" \ + -t "repository:$GITHUB_REPOSITORY" \ + -t "workflow-run:$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" + env: + SENTRY_DSN: ${{ secrets.SENTRY_DEV_INFRA_DSN }} + SENTRY_ORG: sourcegraph + SENTRY_PROJECT: dev-infra + diff --git a/.github/workflows/universal-ctags.yml b/.github/workflows/universal-ctags.yml index 689fa6e4e43..7a42bde8280 100644 --- a/.github/workflows/universal-ctags.yml +++ b/.github/workflows/universal-ctags.yml @@ -122,3 +122,16 @@ jobs: path: './dist/' destination: 'universal_ctags/x86_64-linux' glob: 'universal-ctags-*' + - name: Report failure to sentry + if: ${{ failure() }} + run: | + npm i -g @sentry/cli + sentry-cli send-event -m "Job '$GITHUB_JOB' in the $GITHUB_WORKFLOW action has failed - see run for exact failure" \ + -t "github-action:$GITHUB_WORKFLOW" \ + -t "branch:$GITHUB_REF_NAME" \ + -t "repository:$GITHUB_REPOSITORY" \ + -t "workflow-run:$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" + env: + SENTRY_DSN: ${{ secrets.SENTRY_DEV_INFRA_DSN }} + SENTRY_ORG: sourcegraph + SENTRY_PROJECT: dev-infra