Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions .github/actions/report-failure/action.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
name: 'Report failure'
description: >-
Track failures of a scheduled workflow in a single open issue: open it on the
first failure and comment on it for every subsequent one until someone closes
it. Run this as the last step with "if: failure()".
Track failures of a workflow in a single open issue: open it on the first
failure and comment on it for every subsequent one until someone closes it.
Run this as the last step with "if: failure()", or from a workflow_run
handler with "workflow" and "run-url" pointing at the failed run.
Requires the calling job to have "permissions: issues: write".

inputs:
Expand All @@ -12,6 +13,14 @@ inputs:
assignees:
description: Comma-separated GitHub users to assign to a newly opened issue.
required: true
workflow:
description: Name of the failed workflow. Defaults to the current one.
required: false
default: ${{ github.workflow }}
run-url:
description: URL of the failed run. Defaults to the current one.
required: false
default: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}

runs:
using: 'composite'
Expand All @@ -23,23 +32,23 @@ runs:
GH_REPO: ${{ github.repository }}
LABEL: ${{ inputs.label }}
ASSIGNEES: ${{ inputs.assignees }}
WORKFLOW: ${{ github.workflow }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
WORKFLOW: ${{ inputs.workflow }}
RUN_URL: ${{ inputs.run-url }}
run: |-
set -euo pipefail
gh label create "$LABEL" --force \
--color B60205 \
--description "The $WORKFLOW workflow is failing"
issue="$(gh issue list --label "$LABEL" --state open --json number --jq '.[0].number // empty')"
if [ -n "$issue" ]; then
gh issue comment "$issue" --body "Failed again: $RUN_URL"
gh issue comment "$issue" --body "\`$WORKFLOW\` failed again: $RUN_URL"
else
# Assign individuals: a team mention posted by github-actions does not
# notify the team's members.
gh issue create --label "$LABEL" \
--assignee "$ASSIGNEES" \
--title "$WORKFLOW workflow is failing" \
--body "@databricks/eng-deco-cli the scheduled \`$WORKFLOW\` workflow failed.
--body "@databricks/eng-deco-cli the \`$WORKFLOW\` workflow failed.

$RUN_URL"
fi
52 changes: 52 additions & 0 deletions .github/workflows/report-main-failure.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Report main failure

# Open (or comment on) a tracking issue when one of the workflows below fails
# on main. A failed run on main is otherwise only visible in the Actions tab.
# The merge queue runs most of the same checks before a commit lands, but not
# all of them: the Windows and macOS test cells only run on push, and the
# changelog preview is not a merge-queue check. Integration tests run in
# another repository and are not expected to be green at all times, so they
# are not covered.
on:
workflow_run:
workflows:
- build
- check
- python build
- Changelog Preview
- conftest
- release-build
types: [completed]
branches: [main]

permissions:
issues: write

# One push can fail several of these workflows at once. Serialize so the
# first run opens the issue and the others comment on it.
concurrency:
group: report-main-failure

jobs:
report:
# The "branches" filter matches the head branch of the triggering run, so
# it also admits a pull request from a fork's main branch; the event check
# narrows this to runs of main itself (push and the nightly schedule).
if: >-
github.event.workflow_run.conclusion == 'failure' &&
(github.event.workflow_run.event == 'push' || github.event.workflow_run.event == 'schedule')
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
sparse-checkout: .github/actions/report-failure

- name: Report failure
uses: ./.github/actions/report-failure
with:
label: main-failure
assignees: simonfaltum,andrewnester,anton-107,denik,janniklasrose,pietern,shreyas-goenka
workflow: ${{ github.event.workflow_run.name }}
run-url: ${{ github.event.workflow_run.html_url }}
Loading