Add threaded Slack failure notifications#74
Open
saturnflyer wants to merge 3 commits into
Open
Conversation
When a Slack bot token is configured, failures are posted to the Slack Web API as a threaded conversation: a parent summary message for the branch/run, followed by the failing files grouped into reasonably sized batches as threaded replies. The bot token is preferred over an incoming webhook, and webhook-only setups are unchanged. Added: Threaded Slack failure notifications via a Slack bot token (NOTIFY_SLACK_BOT_TOKEN), grouping failing files into batched thread replies version: minor
Add NOTIFY_SLACK_BOT_TOKEN from secrets and target the channel by ID (C05985VPUSH = #oss-notices) so the threaded Web API path is exercised.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When a Slack bot token is configured, test-run failures are posted to the Slack Web API (
chat.postMessage) as a threaded conversation instead of a single message::boom: <app> <ruby> <sha> has failed N times! in <branch>+ the run URL).Configuration:
NOTIFY_SLACK_BOT_TOKEN—xoxb-…token; enables threading (needschat:write)NOTIFY_SLACK_NOTIFY_CHANNEL— channel to post to (reused)NOTIFY_SLACK_THREAD_GROUP_SIZE— optional, files per reply (default 10)When both a bot token and an incoming webhook are configured, the bot token is preferred. Webhook-only setups are completely unchanged.
Implementation notes
ChatNotifier::FailureGroupsnormalizes failure locations (RSpec"path:line"strings and Minitest[file, line]arrays), groups by file, and packs files into batched reply texts.Chatter::Slack#postbranches to the Web API path when a token is present; the parent post is read for itsts, and replies are posted withthread_ts. If the parent fails or returnsok: false, replies are skipped (no orphan thread).Draft pending review of the threading UX in a real channel.