Skip to content

Add threaded Slack failure notifications#74

Open
saturnflyer wants to merge 3 commits into
mainfrom
slack-threaded-failures
Open

Add threaded Slack failure notifications#74
saturnflyer wants to merge 3 commits into
mainfrom
slack-threaded-failures

Conversation

@saturnflyer

Copy link
Copy Markdown
Member

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:

  • A parent message carries the branch/run summary (:boom: <app> <ruby> <sha> has failed N times! in <branch> + the run URL).
  • The failing files are grouped and posted as threaded replies, batched to a reasonable size (default 10 files per reply, also split under Slack's ~3000-char block limit).

Configuration:

  • NOTIFY_SLACK_BOT_TOKENxoxb-… token; enables threading (needs chat: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

  • New ChatNotifier::FailureGroups normalizes failure locations (RSpec "path:line" strings and Minitest [file, line] arrays), groups by file, and packs files into batched reply texts.
  • Chatter::Slack#post branches to the Web API path when a token is present; the parent post is read for its ts, and replies are posted with thread_ts. If the parent fails or returns ok: false, replies are skipped (no orphan thread).
  • Replies list file locations only — that's all the gem currently captures per failure (richer per-failure context is a separate roadmap item).

Draft pending review of the threading UX in a real channel.

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.
@saturnflyer saturnflyer marked this pull request as ready for review June 17, 2026 16:13
@saturnflyer saturnflyer requested a review from a team as a code owner June 17, 2026 16:13
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.

1 participant