Skip to content

[#2173] Added per-channel branch filtering for notifications.#2429

Merged
AlexSkrypnyk merged 3 commits intomainfrom
feature/2173-notify-branch-filter
Mar 26, 2026
Merged

[#2173] Added per-channel branch filtering for notifications.#2429
AlexSkrypnyk merged 3 commits intomainfrom
feature/2173-notify-branch-filter

Conversation

@AlexSkrypnyk
Copy link
Copy Markdown
Member

@AlexSkrypnyk AlexSkrypnyk commented Mar 26, 2026

Closes #2173

Summary

Added per-channel branch filtering to all six notification channels (email, github, jira, newrelic, slack, webhook). Each channel now supports a VORTEX_NOTIFY_<CHANNEL>_BRANCHES variable that, when set, restricts notifications to deployments on the listed branches (comma-separated, exact match). When empty or unset, no filtering is applied. New Relic defaults to main,master; all other channels default to no filter (pass through).

Changes

Notification scripts (scripts/vortex/)

Each of the six channel scripts received the same branch-filtering block:

  • notify-email.sh — reads VORTEX_NOTIFY_EMAIL_BRANCHES
  • notify-github.sh — reads VORTEX_NOTIFY_GITHUB_BRANCHES
  • notify-jira.sh — reads VORTEX_NOTIFY_JIRA_BRANCHES
  • notify-newrelic.sh — reads VORTEX_NOTIFY_NEWRELIC_BRANCHES (default: main,master)
  • notify-slack.sh — reads VORTEX_NOTIFY_SLACK_BRANCHES
  • notify-webhook.sh — reads VORTEX_NOTIFY_WEBHOOK_BRANCHES

Tests (.vortex/tests/bats/unit/)

  • Each channel's BATS test file received two new test cases: one asserting the notification is skipped when the current branch is not in the filter list, and one asserting it proceeds when the branch matches.
  • notify.bats (router test) updated to use main as the branch value for the New Relic default filter test.

Documentation (.vortex/docs/)

  • notifications.mdx — added a new "Branch filtering" section explaining the feature and documenting the VORTEX_NOTIFY_<CHANNEL>_BRANCHES variable for each channel's reference table.
  • variables.mdx — added the six new variables to the auto-generated variable reference table; removed the now-redundant VORTEX_NOTIFY_BRANCH row.

Before / After

Before — notification dispatch had no per-channel branch guard:

deploy trigger
     |
     v
notify.sh
     |
     +---> notify-email.sh   --> send (always)
     +---> notify-slack.sh   --> send (always)
     +---> notify-newrelic.sh--> send (always)
     ...

After — each channel script checks its branch filter before sending:

deploy trigger
     |
     v
notify.sh
     |
     +---> notify-email.sh
     |       VORTEX_NOTIFY_EMAIL_BRANCHES set?
     |       NO  --> send
     |       YES --> branch in list? YES --> send
     |                              NO  --> skip
     |
     +---> notify-newrelic.sh
     |       VORTEX_NOTIFY_NEWRELIC_BRANCHES="main,master" (default)
     |       branch == "main" or "master"? YES --> send
     |                                     NO  --> skip
     ...

Summary by CodeRabbit

  • New Features

    • Added per-channel branch filtering for email, GitHub, Jira, New Relic, Slack, and webhook notifications. Each channel can now be restricted to specific branches via configuration variables with comma-separated branch names.
  • Documentation

    • Updated deployment and variables documentation to explain branch filtering configuration and default behavior for each notification channel.
  • Tests

    • Added comprehensive test coverage for branch filtering skip scenarios across all notification channels.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 26, 2026

Walkthrough

This change implements per-channel branch filtering for notifications by replacing a global VORTEX_NOTIFY_BRANCH variable with individual VORTEX_NOTIFY_<CHANNEL>_BRANCHES environment variables (e.g., VORTEX_NOTIFY_SLACK_BRANCHES, VORTEX_NOTIFY_GITHUB_BRANCHES). Each notification script now exits early if the current branch is not in its allowlist, skipping unnecessary validations and API calls.

Changes

Cohort / File(s) Summary
Documentation
.vortex/docs/content/deployment/notifications.mdx, .vortex/docs/content/development/variables.mdx
Added "Branch filtering" documentation section describing per-channel branch filtering via comma-separated environment variables. Removed deprecated VORTEX_NOTIFY_BRANCH and added six new variables: VORTEX_NOTIFY_EMAIL_BRANCHES, VORTEX_NOTIFY_GITHUB_BRANCHES, VORTEX_NOTIFY_JIRA_BRANCHES, VORTEX_NOTIFY_NEWRELIC_BRANCHES (default main,master), VORTEX_NOTIFY_SLACK_BRANCHES, VORTEX_NOTIFY_WEBHOOK_BRANCHES.
Notification Scripts
scripts/vortex/notify-email.sh, scripts/vortex/notify-github.sh, scripts/vortex/notify-jira.sh, scripts/vortex/notify-newrelic.sh, scripts/vortex/notify-slack.sh, scripts/vortex/notify-webhook.sh
Added early branch-filtering gate to each notification channel script. When the corresponding VORTEX_NOTIFY_*_BRANCHES variable is non-empty and the current branch is not in the allowlist, script exits successfully (exit 0) with a skip message before validating required configuration or making API calls. New Relic defaults to main,master; others default to empty (no filtering).
Unit Tests
.vortex/tests/bats/unit/notify-email.bats, .vortex/tests/bats/unit/notify-github.bats, .vortex/tests/bats/unit/notify-jira.bats, .vortex/tests/bats/unit/notify-newrelic.bats, .vortex/tests/bats/unit/notify-slack.bats, .vortex/tests/bats/unit/notify-webhook.bats, .vortex/tests/bats/unit/notify.bats
Added new test cases validating branch-filter skip behavior for each channel with specific branch configurations (e.g., VORTEX_NOTIFY_EMAIL_BRANCHES=main,develop with VORTEX_NOTIFY_BRANCH=feature/test). Updated New Relic tests to use main instead of develop and added tests for both skip and non-skip scenarios with different branch configurations.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

Poem

🐰 Hop skip and branch away,
Each channel picks its day!
New Relic guards its main,master gate,
While others filter at a customizable rate.
No more all-or-nothing—pure notification fate! 🎯

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding per-channel branch filtering for notifications, which is the primary objective of this PR.
Linked Issues check ✅ Passed All coding requirements from issue #2173 are met: per-channel branch filtering via environment variables is implemented for all six channels, with proper defaults and skip behavior.
Out of Scope Changes check ✅ Passed All changes directly support the linked issue objectives: implementation of branch filtering in notification scripts, corresponding tests, and documentation updates.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/2173-notify-branch-filter

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
.vortex/docs/content/development/variables.mdx (1)

317-338: ⚠️ Potential issue | 🟠 Major

Re-add VORTEX_NOTIFY_BRANCH to the variables table (still required at runtime).

VORTEX_NOTIFY_BRANCH is still a required input in scripts/vortex/notify.sh and is referenced by notification vars (e.g., Line 329, Line 337). Its removal from this page can lead to misconfiguration and hard failures.

Suggested doc patch
 | <a id="vortex_notify_channels"></a>`VORTEX_NOTIFY_CHANNELS`                                                                     | The channels of the notifications.<br/><br/>A combination of comma-separated values: email,slack,newrelic,github,jira,webhook                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             | `email`                                                                  | `.env`, `scripts/vortex/notify.sh`                                                                                                                               |
+| <a id="vortex_notify_branch"></a>`VORTEX_NOTIFY_BRANCH`                                                                         | Notification git branch name used as the source branch for channel branch filtering and channel-specific defaults.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          | `UNDEFINED`                                                              | `scripts/vortex/notify.sh`                                                                                                                                       |
 | <a id="vortex_notify_email_branches"></a>`VORTEX_NOTIFY_EMAIL_BRANCHES`                                                         | Email notification branch filter.<br/><br/>Comma-separated list of branch names. When set, email notifications are only sent for deployments on the listed branches. When empty, no filtering is applied.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 | `UNDEFINED`                                                              | `scripts/vortex/notify-email.sh`                                                                                                                                 |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.vortex/docs/content/development/variables.mdx around lines 317 - 338, The
docs removed the required environment variable VORTEX_NOTIFY_BRANCH which is
still referenced at runtime (e.g., in scripts/vortex/notify.sh and notification
var descriptions like VORTEX_NOTIFY_GITHUB_BRANCH/VORTEX_NOTIFY_JIRA_BRANCH);
add a new table row for `VORTEX_NOTIFY_BRANCH` with a short description
("Notification git branch name used by notify scripts"), a sensible default
placeholder (e.g., `${VORTEX_NOTIFY_BRANCH}` or `UNDEFINED`), and list the
relevant scripts (`scripts/vortex/notify.sh`, `scripts/vortex/notify-github.sh`,
`scripts/vortex/notify-jira.sh`) in the source column so the variable is
documented and discoverable.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In @.vortex/docs/content/development/variables.mdx:
- Around line 317-338: The docs removed the required environment variable
VORTEX_NOTIFY_BRANCH which is still referenced at runtime (e.g., in
scripts/vortex/notify.sh and notification var descriptions like
VORTEX_NOTIFY_GITHUB_BRANCH/VORTEX_NOTIFY_JIRA_BRANCH); add a new table row for
`VORTEX_NOTIFY_BRANCH` with a short description ("Notification git branch name
used by notify scripts"), a sensible default placeholder (e.g.,
`${VORTEX_NOTIFY_BRANCH}` or `UNDEFINED`), and list the relevant scripts
(`scripts/vortex/notify.sh`, `scripts/vortex/notify-github.sh`,
`scripts/vortex/notify-jira.sh`) in the source column so the variable is
documented and discoverable.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: fec6ed8f-3aa0-4a85-936a-75479ab9f817

📥 Commits

Reviewing files that changed from the base of the PR and between 900f162 and 22ed12e.

📒 Files selected for processing (15)
  • .vortex/docs/content/deployment/notifications.mdx
  • .vortex/docs/content/development/variables.mdx
  • .vortex/tests/bats/unit/notify-email.bats
  • .vortex/tests/bats/unit/notify-github.bats
  • .vortex/tests/bats/unit/notify-jira.bats
  • .vortex/tests/bats/unit/notify-newrelic.bats
  • .vortex/tests/bats/unit/notify-slack.bats
  • .vortex/tests/bats/unit/notify-webhook.bats
  • .vortex/tests/bats/unit/notify.bats
  • scripts/vortex/notify-email.sh
  • scripts/vortex/notify-github.sh
  • scripts/vortex/notify-jira.sh
  • scripts/vortex/notify-newrelic.sh
  • scripts/vortex/notify-slack.sh
  • scripts/vortex/notify-webhook.sh

@github-actions
Copy link
Copy Markdown

Code coverage (threshold: 90%)

  Classes: 100.00% (1/1)
  Methods: 100.00% (2/2)
  Lines:   100.00% (189/189)
Per-class coverage
Drupal\ys_demo\Plugin\Block\CounterBlock
  Methods: 100.00% ( 2/ 2)   Lines: 100.00% ( 10/ 10)

@AlexSkrypnyk

This comment has been minimized.

2 similar comments
@AlexSkrypnyk

This comment has been minimized.

@AlexSkrypnyk
Copy link
Copy Markdown
Member Author

Code coverage (threshold: 90%)

  Classes: 100.00% (1/1)
  Methods: 100.00% (2/2)
  Lines:   100.00% (189/189)
Per-class coverage
Drupal\ys_demo\Plugin\Block\CounterBlock
  Methods: 100.00% ( 2/ 2)   Lines: 100.00% ( 10/ 10)

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.24%. Comparing base (900f162) to head (22ed12e).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2429      +/-   ##
==========================================
- Coverage   79.62%   79.24%   -0.38%     
==========================================
  Files         127      120       -7     
  Lines        6801     6672     -129     
  Branches       44        0      -44     
==========================================
- Hits         5415     5287     -128     
+ Misses       1386     1385       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@AlexSkrypnyk AlexSkrypnyk merged commit 9a00092 into main Mar 26, 2026
30 checks passed
@AlexSkrypnyk AlexSkrypnyk deleted the feature/2173-notify-branch-filter branch March 26, 2026 09:18
@github-project-automation github-project-automation bot moved this from BACKLOG to Release queue in Vortex Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Release queue

Development

Successfully merging this pull request may close these issues.

Allow to exclude/include branches for notifications per type

1 participant