Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slack integration for GHA failures (build cop) #366

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

tyler-yankee
Copy link
Collaborator

@tyler-yankee tyler-yankee commented Jan 27, 2025

Addresses #22019. Adds CI workflow for a custom Slack bot in DrakeDevelopers to send a notification to the #buildcop channel when GitHub Actions fails.

  • The Slack workflow in CI is triggered when the main CI workflow finishes, and the "send notification" step happens when the main CI workflow failed (or timed out).
  • The message is formatted as follows (save for the "test" names), with links to the failed run, the branch, and the repository:
  • The Slack "app" (bot) that is running this, GitHub Actions Build Cop, is installed to the DrakeDevelopers workspace. I've added @jwnimmer-tri and @BetsyMcPhail as collaborators so that changes can be made as needed.

image

It turns out that GitHub's Slack integration doesn't support only filtering for workflow failures (see: integrations/slack#1563), which is why we're using the notify-slack-action instead.


This change is Reviewable

@tyler-yankee tyler-yankee force-pushed the ghafail-slack branch 2 times, most recently from 09a00f4 to 4eb53a1 Compare January 27, 2025 18:38
@tyler-yankee
Copy link
Collaborator Author

I've tested the functionality on a dummy repository that you can see in the example above. Unfortunately, to do any further testing on drake-external-examples, the slack.yml file needs to be on main ... see https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#workflow_run.

@tyler-yankee
Copy link
Collaborator Author

Previously, tyler-yankee wrote…

I've tested the functionality on a dummy repository that you can see in the example above. Unfortunately, to do any further testing on drake-external-examples, the slack.yml file needs to be on main ... see https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#workflow_run.

+@BetsyMcPhail for feature review, please!

Copy link
Contributor

@BetsyMcPhail BetsyMcPhail left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 1 unresolved discussion, LGTM missing from assignee betsymcphail, LGTM missing from assignee nicolecheetham, platform LGTM missing (waiting on @nicolecheetham and @tyler-yankee)


a discussion (no related file):

Previously, tyler-yankee (Tyler Yankee) wrote…

+@BetsyMcPhail for feature review, please!

+@nicolecheetham can you take over feature review on this please?

@BetsyMcPhail BetsyMcPhail removed their assignment Feb 25, 2025
Copy link
Collaborator

@nicolecheetham nicolecheetham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good, mostly just a few tiny things here and there. Nice job!

Also, is there more work that needs to be done that hasn't been shown? Your last comment seems to suggest as such and I remember you mentioning needing to update the variable used for SLACK_WEBHOOK_URL.

Reviewable status: 7 unresolved discussions, LGTM missing from assignee nicolecheetham, platform LGTM missing (waiting on @tyler-yankee)


.github/workflows/slack.yml line 11 at r1 (raw file):

jobs:
  notify:

nit consider renaming the job as to specify the type of notification. Maybe like notify_errors, failure_notifications, or error_notifications?


.github/workflows/slack.yml line 14 at r1 (raw file):

    runs-on: ubuntu-latest
    steps:
      - name: Notify Build Cop Slack

nit similar to the job name.


.github/workflows/slack.yml line 15 at r1 (raw file):

    steps:
      - name: Notify Build Cop Slack
        if: github.event.workflow_run.conclusion == 'failure' || github.event.workflow_run.conclusion == 'timed_out'

This expression should be surrounded by ${{ }}


.github/workflows/slack.yml line 20 at r1 (raw file):

          status: ${{ github.event.workflow_run.conclusion }}
          notification_title: >
            ${{github.event.workflow_run.name}} failed on ${{github.event.workflow_run.head_branch}} -

nit I think you could replace "failed" with ${{github.event.workflow_run.conclusion}}. This would allow you to remove the message format line that says "Result: ..." simplifying the overall notification.


.github/workflows/slack.yml line 21 at r1 (raw file):

          notification_title: >
            ${{github.event.workflow_run.name}} failed on ${{github.event.workflow_run.head_branch}} -
            <${{github.server_url}}/${{github.repository}}/actions/runs/${{github.event.workflow_run.id}}|View Failure>

nit The path can be simplified to ${{github.event.workflow_run.url}}


.github/workflows/slack.yml line 25 at r1 (raw file):

            Result: ${{github.event.workflow_run.conclusion}}
            Run: ${{github.event.workflow_run.run_number}}
            Branch: <${{github.server_url}}/${{github.repository}}/tree/${{github.event.workflow_run.head_branch}}|${{github.repository}}/${{github.event.workflow_run.head_branch}}>

nit Is there a way to use ravsamhq/notify-slack-action@v2 customs variables to make the branch and footer notification less verbose code wise? Like {branch_url} and {repo_url}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants