Skip to content

[#2863] Added opt-in for visual regression on non-PR deployments. - #2864

Merged
AlexSkrypnyk merged 10 commits into
mainfrom
feature/2863-vr-release-optin
Jul 29, 2026
Merged

[#2863] Added opt-in for visual regression on non-PR deployments.#2864
AlexSkrypnyk merged 10 commits into
mainfrom
feature/2863-vr-release-optin

Conversation

@AlexSkrypnyk

@AlexSkrypnyk AlexSkrypnyk commented Jul 29, 2026

Copy link
Copy Markdown
Member

Closes #2863

Summary

The gate step in .github/workflows/test-vr.yml exited as soon as the dispatched target_url had no pr-<number> segment, so a release branch or any other permanent-environment deployment could never trigger a Diffy comparison automatically - only a manual workflow_dispatch with a hand-pasted URL could. This adds an opt-in repository variable, VR_DIFFY_BRANCHES, holding a comma-separated glob list of deployed branch names. When a dispatch resolves no PR, the gate matches the deployed branch against that list before deciding to skip. The branch is already carried in the client_payload.branch field that vortex-notify-diffy sends, so the check costs no extra API call. The variable is empty by default, which preserves today's behaviour exactly.

Breaking change

VR_DIFFY_AUTO_BRANCHES is renamed to VR_DIFFY_PR_SKIP_BRANCHES, so each variable now states which gate it controls: VR_DIFFY_PR_SKIP_BRANCHES lists PR head branches that skip the label check, and VR_DIFFY_BRANCHES lists deployed branches that run without a PR. A consumer that has set the old repository variable falls back to the deps/* default until it is renamed - same value in the common case, but it needs calling out in the release notes.

Changes

Gate

  • Added DIFFY_BRANCHES (from vars.VR_DIFFY_BRANCHES, empty by default) and BRANCH (from client_payload.branch) to the workflow-level env block, so neither value is interpolated into a run: script.
  • Reworked the no-PR-resolved path to consult the opt-in list: it proceeds when the deployed branch matches a pattern, and otherwise skips with the same ::notice:: as before.
  • Extracted the comma-separated glob matching into a ref_matches helper, reused by both the new opt-in check and the VR_DIFFY_PR_SKIP_BRANCHES PR head-branch check, which previously carried the only copy of that loop inline. The list is split on whitespace as well as commas, so padding around a pattern is absorbed rather than trimmed by hand.
  • Extracted proceed and skip helpers for the "record the decision and end the step" pair that was written out at all seven exit points, and collapsed the guards into AND lists. The step is roughly half its previous height, and each decision is now a single line.
  • Replaced the lowercase-both-sides label comparison with a case-insensitive fixed-string grep, which also removes the risk of a label containing regex metacharacters being treated as a pattern.
  • Guarded the gh pr view lookup with an exit-status check. A pr-<number> segment that does not resolve to a real pull request now skips the run with a ::notice:: instead of failing the vr-compare check under set -euo pipefail - a comparison that should not run must not present as a red check.
  • Renamed the step to Gate run on PR label or opted-in branch, and downgraded the "no PR pattern found" line from ::notice:: to a plain echo since it is no longer a terminal outcome.

Documentation

  • Documented VR_DIFFY_BRANCHES in the variables table, renamed VR_DIFFY_AUTO_BRANCHES throughout, and added a Release and other non-PR deployments section with a run/no-run decision table.
  • Called out that patterns match the git branch name, not the hostname: Lagoon deploys release/26.7.5 to a host containing release-26-7-5, and the gate compares against the original branch name.
  • Redrew the automatic-deployment diagram so both gate paths are visible and rejoin at the run-summary node, and noted in the Jobs section that vr-report runs only when a PR was resolved.
  • Updated How the PR is resolved and Costs and quotas, the latter warning that * compares on every deployment to every permanent environment.

Fixtures

  • Regenerated the visual_regression_enabled installer fixture via ahoy update-snapshots.

Verification

The gate is inline shell inside YAML with no test harness in this repository, so the decision table was exercised locally by running the step verbatim against a mocked gh: 19 cases covering manual dispatch, the four PR paths (label, lowercase label, no label, deps/* skip), a failed PR lookup, a mixed-case configured label, and nine no-PR cases including the empty default, the * wildcard, multi-pattern lists, space- and tab-padded lists, an all-empty list, and the sanitized-hostname trap. actionlint (the pinned CI image and ignore list) and zizmor both pass.

Before / After

BEFORE                                  AFTER
──────                                  ─────
repository_dispatch                     repository_dispatch
        │                                       │
        ▼                                       ▼
  pr-<n> in URL?                          pr-<n> in URL?
        │                                       │
   ┌────┴────┐                             ┌────┴────┐
  yes        no                           yes        no
   │          │                            │          │
   ▼          ▼                            ▼          ▼
label /   skipped=true                  label /   branch matches
PR skip    (always - no                 PR skip   VR_DIFFY_BRANCHES?
branch      way to opt in)              branch          │
gate                                    gate       ┌────┴────┐
   │                                       │      yes        no
   ▼                                       ▼       │          │
diffy compare                        diffy compare ◄┘         ▼
                                                        skipped=true

Summary by CodeRabbit

  • New Features

    • Added support for running visual regression checks on opted-in non-PR deployments via branch configuration.
    • Enhanced gating so PR runs depend on labels, while non-PR runs follow an explicit branch opt-in.
    • Improved reporting: when PR context isn’t available, results appear in workflow summaries and the Diffy UI instead of PR comments.
  • Bug Fixes

    • Visual regression now safely skips when PR metadata can’t be read, with clearer messaging.
  • Documentation

    • Updated visual regression docs with the non-PR opt-in mechanism, run/no-run matrix examples, and quota guidance.

@github-project-automation github-project-automation Bot moved this to BACKLOG in Vortex 1.x Jul 29, 2026
@AlexSkrypnyk AlexSkrypnyk added the A1 Board worker 1 label Jul 29, 2026
@AlexSkrypnyk AlexSkrypnyk added this to the 1.41.0 milestone Jul 29, 2026
@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 25 seconds

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 182235a7-04fa-4700-9401-e22abd0ee3e4

📥 Commits

Reviewing files that changed from the base of the PR and between 7c08efd and eea9651.

⛔ Files ignored due to path filters (1)
  • .vortex/installer/tests/Fixtures/handler_process/visual_regression_enabled/.github/workflows/test-vr.yml is excluded by !.vortex/installer/tests/Fixtures/**
📒 Files selected for processing (2)
  • .github/workflows/test-vr.yml
  • .vortex/docs/content/development/visual-regression.mdx

Walkthrough

Diffy visual regression gating now supports opted-in non-PR branches, glob-based matching, safer PR metadata handling, and updated documentation for execution paths and result reporting.

Changes

Visual regression flow

Layer / File(s) Summary
Branch and PR gating
.github/workflows/test-vr.yml
Adds non-PR branch configuration, reusable glob matching, explicit proceed/skip handling, safer PR metadata lookup, and PR auto-run matching.
Workflow behavior documentation
.vortex/docs/content/development/visual-regression.mdx
Documents non-PR branch opt-in, gating paths, workflow-summary versus PR-comment reporting, job behavior, and quota guidance.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Deployment
  participant DiffyWorkflow
  participant GitHub
  Deployment->>DiffyWorkflow: Dispatch visual regression workflow
  DiffyWorkflow->>GitHub: Resolve PR metadata when available
  GitHub-->>DiffyWorkflow: Return PR data or no PR
  DiffyWorkflow->>DiffyWorkflow: Apply PR label, auto-branch, or non-PR branch gating
  DiffyWorkflow->>GitHub: Publish PR comment or workflow summary
Loading

Poem

A rabbit hops through branches bright,
Matching globs by moonlit light.
PRs get comments, releases run,
Summaries shine when comments shun.
Diffy checks now leap and play.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The workflow adds env-variable opt-in for non-PR deployments and preserves default skip behavior when unset.
Out of Scope Changes check ✅ Passed The changes stay within the visual-regression workflow and docs updates described by the issue.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: opt-in visual regression support for non-PR deployments.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/2863-vr-release-optin

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/test-vr.yml:
- Around line 307-319: Gate the GITHUB_STEP_SUMMARY report block on an empty
resolved PR number so it runs only when no PR comment will be posted. Preserve
the existing summary contents and non-PR reporting behavior, using the
workflow’s resolved PR number variable.

In @.vortex/docs/content/development/visual-regression.mdx:
- Around line 145-157: Update the visual regression flow diagram so the PR
deployment path also leads from vr-report to run summary, while preserving the
existing PR comment step for that path. Ensure both PR-resolved and
no-PR-resolved paths show the unconditional run-summary output described in the
Jobs section.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 24e9b714-5f8b-442c-9cda-0e5beaaab944

📥 Commits

Reviewing files that changed from the base of the PR and between ece8160 and 2e68f70.

⛔ Files ignored due to path filters (1)
  • .vortex/installer/tests/Fixtures/handler_process/visual_regression_enabled/.github/workflows/test-vr.yml is excluded by !.vortex/installer/tests/Fixtures/**
📒 Files selected for processing (2)
  • .github/workflows/test-vr.yml
  • .vortex/docs/content/development/visual-regression.mdx

Comment thread .github/workflows/test-vr.yml Outdated
Comment thread .vortex/docs/content/development/visual-regression.mdx Outdated
@github-actions

This comment has been minimized.

@AlexSkrypnyk

This comment has been minimized.

2 similar comments
@AlexSkrypnyk

This comment has been minimized.

@AlexSkrypnyk

This comment has been minimized.

@codecov

codecov Bot commented Jul 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.38%. Comparing base (ab2ae94) to head (eea9651).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2864      +/-   ##
==========================================
- Coverage   86.81%   86.38%   -0.43%     
==========================================
  Files         100       93       -7     
  Lines        4846     4687     -159     
  Branches       47        3      -44     
==========================================
- Hits         4207     4049     -158     
+ Misses        639      638       -1     

☔ View full report in Codecov by Harness.
📢 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.

@github-actions

github-actions Bot commented Jul 29, 2026

Copy link
Copy Markdown

📖 Documentation preview for this pull request has been deployed to Netlify:

https://6a69d54e598381806734e2a9--vortex-docs.netlify.app

This preview is rebuilt on every commit and is not the production documentation site.

Added the 'VR_DIFFY_NON_PR_BRANCHES' repository variable so deployments without a pull request environment - release branches, integration branches, permanent environments - can run a Diffy comparison when the deployed branch matches. Empty by default, preserving the current skip.

Extracted the glob matching into a 'ref_matches' helper shared by the PR head-branch bypass and the new branch opt-in, reported the result to the workflow run summary for runs that have no pull request to comment on, and skipped instead of failing when a resolved PR number cannot be read.
A pattern list written as 'release/*,  develop' left the extra spaces in place, so the pattern never matched.
@github-actions github-actions Bot added the CONFLICT Pull request has a conflict that needs to be resolved before it can be merged label Jul 29, 2026
…ult.

The flow diagrams showed every run ending in a PR comment, and the manual entry point showed a 'vr-report' job that never runs without a resolved PR.
…low diagram.

The entry box implied the branch opt-in was evaluated before the deployment, when the workflow evaluates it after the dispatch.
…elpers.

Recording the decision and ending the step was written out at all seven exit points, so a change to the step's output contract had to be repeated seven times.
@AlexSkrypnyk
AlexSkrypnyk force-pushed the feature/2863-vr-release-optin branch from 2e68f70 to 7c08efd Compare July 29, 2026 09:16
@github-actions github-actions Bot removed the CONFLICT Pull request has a conflict that needs to be resolved before it can be merged label Jul 29, 2026
@github-actions

This comment has been minimized.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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)
.github/workflows/test-vr.yml (1)

333-337: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick win

Use a random delimiter for the $GITHUB_OUTPUT heredoc.

The multi-line output uses a static VR_SUMMARY_EOF delimiter while the body interpolates TARGET_URL and SHARED_URL (Diffy's shared report URL). If either value ever contains a line equal to VR_SUMMARY_EOF, subsequent lines get parsed as arbitrary $GITHUB_OUTPUT key=value pairs — including overriding pr_number, which vr-report later uses to pick the PR to comment on. Low likelihood today, but the fix is trivial.

♻️ Proposed fix
+          delimiter="vr_summary_$(date +%s%N)_${RANDOM}"
           {
-            echo "summary<<VR_SUMMARY_EOF"
+            echo "summary<<${delimiter}"
             printf '%s\n' "${summary}"
-            echo "VR_SUMMARY_EOF"
+            echo "${delimiter}"
           } >> "$GITHUB_OUTPUT"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/test-vr.yml around lines 333 - 337, Update the multi-line
GITHUB_OUTPUT block around the summary output to generate and use a per-run
random heredoc delimiter instead of the static VR_SUMMARY_EOF value. Ensure the
same delimiter wraps the printf output and cannot collide with interpolated
TARGET_URL or SHARED_URL content, while preserving the existing summary output
name and formatting.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In @.github/workflows/test-vr.yml:
- Around line 333-337: Update the multi-line GITHUB_OUTPUT block around the
summary output to generate and use a per-run random heredoc delimiter instead of
the static VR_SUMMARY_EOF value. Ensure the same delimiter wraps the printf
output and cannot collide with interpolated TARGET_URL or SHARED_URL content,
while preserving the existing summary output name and formatting.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 1b7a8447-5276-411e-8cf7-488664c3d267

📥 Commits

Reviewing files that changed from the base of the PR and between 2e68f70 and 7c08efd.

⛔ Files ignored due to path filters (1)
  • .vortex/installer/tests/Fixtures/handler_process/visual_regression_enabled/.github/workflows/test-vr.yml is excluded by !.vortex/installer/tests/Fixtures/**
📒 Files selected for processing (2)
  • .github/workflows/test-vr.yml
  • .vortex/docs/content/development/visual-regression.mdx

@AlexSkrypnyk

This comment has been minimized.

2 similar comments
@AlexSkrypnyk

This comment has been minimized.

@AlexSkrypnyk

This comment has been minimized.

@AlexSkrypnyk AlexSkrypnyk added the Needs review Pull request needs a review from assigned developers label Jul 29, 2026
Named the new variable 'VR_DIFFY_BRANCHES' rather than describing it by what it is not, and renamed 'VR_DIFFY_AUTO_BRANCHES' to 'VR_DIFFY_PR_SKIP_BRANCHES' so each name states which gate it controls.

Collapsed the gate to roughly half its height: single-line helpers, guard clauses as AND lists, splitting the pattern list on whitespace as well as commas instead of trimming each pattern by hand, and a case-insensitive fixed-string 'grep' in place of lowercasing both sides of the label comparison.

'VR_DIFFY_AUTO_BRANCHES' is an existing repository variable, so a consumer that has set it falls back to the 'deps/*' default until it is renamed.
@github-actions

Copy link
Copy Markdown

Code coverage (threshold: 90%)

  Classes: 100.00% (1/1)
  Methods: 100.00% (2/2)
  Lines:   98.55% (204/207)
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:   98.55% (204/207)
Per-class coverage
Drupal\ys_demo\Plugin\Block\CounterBlock
  Methods: 100.00% ( 2/ 2)   Lines: 100.00% ( 10/ 10)

@AlexSkrypnyk
AlexSkrypnyk merged commit dc399b6 into main Jul 29, 2026
34 checks passed
@AlexSkrypnyk
AlexSkrypnyk deleted the feature/2863-vr-release-optin branch July 29, 2026 10:37
@github-project-automation github-project-automation Bot moved this from BACKLOG to Release queue in Vortex 1.x Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A1 Board worker 1 Needs review Pull request needs a review from assigned developers

Projects

Status: Release queue

Development

Successfully merging this pull request may close these issues.

Allow VR to run automatically for releases by opting in with a env variable in CI

1 participant