Skip to content

ci(relay2): only deploy relay2 when relay2-relevant paths change - #6359

Closed
saddlepaddle wants to merge 1 commit into
mainfrom
relay2-deploy-gate
Closed

saddlepaddle wants to merge 1 commit into
mainfrom
relay2-deploy-gate

Conversation

@saddlepaddle

@saddlepaddle saddlepaddle commented Aug 11, 2026 •

Copy link
Copy Markdown
Member

Summary

Every relay2 deploy restarts its Durable Objects, which severs every live host tunnel (hosts reconnect in ~2s, but in-flight streams drop). deploy-production.yml runs on every push to main with no path gating, so today's six unrelated merges bounced the entire relay2 fleet six times in one hour.

This gates the deploy-relay2 job with dorny/paths-filter (pinned v3.0.2): it now deploys only when apps/relay2/**, its workspace deps (packages/shared/**, packages/trpc/**), bun.lock, or the workflow itself changed. workflow_dispatch always deploys, preserving the manual escape hatch.

The stateless Cloudflare workers (electric-proxy) are left as-is — redeploying them on every push is harmless.

Test plan

  • bun run lint clean
  • After merge: verify an unrelated main push skips the Deploy Worker step, and a relay2-touching push (or manual dispatch) still deploys

Summary by CodeRabbit

  • Chores
    • Improved production deployment handling by detecting relevant changes before running deployment steps.
    • Manual deployments continue to run on demand without change filtering.
    • Added clearer deployment guidance, including information about restart behavior during updates.

Summary by cubic

Gate relay2 deployments so the job only runs when relay2-related files change, preventing unnecessary Durable Object restarts and dropped host tunnels. Uses dorny/[email protected] to watch apps/relay2/**, packages/shared/**, packages/trpc/**, bun.lock, and the workflow; workflow_dispatch still triggers a deploy.

Written for commit 9510012. Summary will update on new commits.

Review in cubic

Every relay2 deploy restarts its Durable Objects and severs every live
host tunnel. deploy-production runs on every push to main, so unrelated
merges were bouncing the whole relay fleet several times an hour.
@coderabbitai

coderabbitai Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The production workflow now detects Relay2-related changes on push events. It runs Relay2 setup, dependency installation, caching, and deployment only when matching files change. Manual workflow dispatches continue to deploy unconditionally.

Changes

Relay2 deployment gating

Layer / File(s) Summary
Change detection and conditional deployment
.github/workflows/deploy-production.yml
The workflow filters changes in Relay2, shared packages, tRPC, bun.lock, and the workflow file. Relay2 setup, dependency installation, caching, and deployment run for matching pushes or manual dispatches. Comments document Durable Objects restarts and live tunnel termination.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • superset-sh/superset#5575: Both changes add conditional deployment behavior for Relay-related services while preserving manual dispatch support.
  • superset-sh/superset#6204: Both changes modify the deploy-relay2 job in the production deployment workflow.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description check ✅ Passed The description explains the change, its impact, deployment paths, testing, and pending post-merge verification.
Title check ✅ Passed The title uses conventional commit format and clearly identifies the relay2 path-gating change.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch relay2-deploy-gate

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Preview Deployment

🔗 Preview Links

Service Status Link
Neon Database (Neon) ✅ View Branch
Vercel API (Vercel) ✅ Open Preview
Vercel Web (Vercel) ✅ Open Preview
Vercel Marketing (Vercel) ✅ Open Preview
Vercel Admin (Vercel) ✅ Open Preview
Vercel Docs (Vercel) ✅ Open Preview

Preview updates automatically with new commits

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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/deploy-production.yml:
- Around line 497-502: Add ".bun-version" to the relay2 path filters in the
deployment workflow so changes to the Bun version trigger the Relay2 deployment
steps. Preserve all existing relay2 paths and conditions.
- Around line 491-494: Declare least-privilege GITHUB_TOKEN permissions in the
workflow by setting contents: read at the workflow level, or specifically on the
deploy-relay2 job after verifying other jobs’ requirements; preserve all
existing job behavior.
🪄 Autofix

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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 29d1e28b-62d6-41fc-8419-63017e10466c

📥 Commits

Reviewing files that changed from the base of the PR and between 8e489fc and 9510012.

📒 Files selected for processing (1)
  • .github/workflows/deploy-production.yml

Comment on lines +491 to +494
- name: Detect relay2-relevant changes
if: github.event_name == 'push'
id: changes
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -eu

printf '%s\n' '--- workflow structure ---'
awk 'NR <= 80 || (NR >= 430 && NR <= 540) {printf "%5d %s\n", NR, $0}' .github/workflows/deploy-production.yml

printf '%s\n' '--- jobs, permissions, and relevant action references ---'
rg -n '^(name:|on:|  [A-Za-z0-9_-]+:|    permissions:|      permissions:|        permissions:|permissions:|.*dorny/paths-filter|.*actions/checkout|.*github\.token|.*GITHUB_TOKEN|.*paths-filter|.*outputs|.*environment:)' .github/workflows/deploy-production.yml

printf '%s\n' '--- repository workflow files and permission declarations ---'
git ls-files '.github/workflows/*'
rg -n '(^permissions:|^[[:space:]]+permissions:|dorny/paths-filter|actions/checkout)' .github/workflows

Repository: superset-sh/superset

Length of output: 16201


🌐 Web query:

dorny paths-filter v3 GitHub Actions required permissions push workflow_dispatch contents read

💡 Result:

For the dorny/paths-filter action (including v3 and newer versions), the required permissions depend on how the workflow is triggered [1][2]. 1. Pull Request Events: When a workflow is triggered by pull_request or pull_request_target events, the action requires the pull-requests: read permission to fetch the list of modified files via the GitHub REST API [3][4][2]. If you are also using actions/checkout in the same job, you typically need contents: read as well [3][4]. 2. Other Events (e.g., push, workflow_dispatch): In cases where the job does not rely on the pull request API (i.e., it executes local git commands instead), explicit pull-requests: read permissions are generally not required [1]. However, if you include a permissions: block in your workflow, it overrides any default permissions [5]. If you manually define permissions, ensure you include the necessary scopes for all steps in the job, such as contents: read for actions/checkout [3][4][5]. Important Considerations: - Permission Overrides: Defining a permissions block at the job level will override inherited permissions [5]. If your workflow requires both actions/checkout and paths-filter, ensure your configuration includes both required scopes [3][4]: permissions: contents: read pull-requests: read - workflow_dispatch: When using workflow_dispatch, the action does not automatically have a "before" commit to compare against [6]. If you experience issues with change detection in manual triggers, verify your base input configuration; often, removing the explicit base configuration allows the action to correctly default to the repository's main branch [6].

Citations:


🌐 Web query:

GitHub Actions workflow syntax permissions unspecified default GITHUB_TOKEN repository organization enterprise settings job-level permissions contents read actions checkout

💡 Result:

In GitHub Actions, the GITHUB_TOKEN is a temporary, repository-scoped access token used for authentication [1][2]. Understanding its permission model is essential for adhering to the principle of least privilege [1][3][2]. Default Permissions The default permissions of the GITHUB_TOKEN are determined by settings configured at the repository, organization, or enterprise level [4][5]. Administrators can choose between two primary settings: - Restricted: Generally grants read-only access to contents and packages [6][4]. This is the recommended secure default [3][2]. - Permissive: Grants read and write access to a wider range of scopes [4]. If you do not explicitly define a permissions key in your workflow, the GITHUB_TOKEN inherits these repository-level default settings [4][7]. Workflow Syntax and Permission Scoping To enforce the principle of least privilege, you should use the permissions key in your workflow file to explicitly define only the necessary access [1][5][8]. - Top-level permissions: When placed at the top level of a workflow file, these settings apply to all jobs within that workflow [9][10]. - Job-level permissions: When placed within a specific job (e.g., jobs.<job_id>.permissions), these settings override the repository defaults and any top-level workflow permissions entirely for that specific job [5][9][10]. Important Behaviors - Overriding: If you define permissions at the job level, you must specify all required permissions for that job, as they do not merge with workflow-level permissions; they replace them completely [5][10]. - Explicit Definition: If you specify a permission for even one scope (e.g., contents: read), all other unspecified scopes are set to none [5][9][11]. - Forked Repositories: If a workflow is triggered by a pull request from a forked repository, permissions are automatically restricted to read-only for security reasons, unless explicitly configured otherwise by organization settings (e.g., "Send write tokens to workflows from pull requests") [4][5]. For common tasks like actions/checkout, the contents: read permission is typically required [7]. You should audit your workflows to ensure they use the minimum necessary permissions rather than relying on broad, potentially overly permissive defaults [1][3][2].

Citations:


🏁 Script executed:

#!/bin/bash
set -eu

python3 - <<'PY'
from pathlib import Path
import re

path = Path(".github/workflows/deploy-production.yml")
lines = path.read_text().splitlines()

jobs = []
current = None
for number, line in enumerate(lines, 1):
    m = re.match(r"^  ([A-Za-z0-9_-]+):\s*$", line)
    if m:
        current = {"name": m.group(1), "line": number, "permissions": []}
        jobs.append(current)
    elif current and re.match(r"^    permissions:\s*$", line):
        current["permissions"].append(number)

print("workflow-level permissions:",
      any(re.match(r"^permissions:\s*$", line) for line in lines))
for job in jobs:
    print(f"job={job['name']} line={job['line']} permissions={job['permissions']}")

start = next(i for i, line in enumerate(lines, 1)
             if "id: changes" in line)
end = next(i for i in range(start, len(lines) + 1)
           if i > start and re.match(r"^      - name:", lines[i - 1]))
print(f"paths-filter step lines={start}-{end - 1}")
print("paths-filter filters:")
for i in range(start, end):
    if re.match(r'^\s+- "', lines[i - 1]):
        print(f"{i}: {lines[i - 1].strip()}")
PY

Repository: superset-sh/superset

Length of output: 804


Declare least-privilege token permissions.

If repository defaults grant write access, this workflow gives the deployment jobs broader GITHUB_TOKEN permissions than required. Set contents: read at the workflow level, or at least on deploy-relay2 after checking the other jobs.

🤖 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/deploy-production.yml around lines 491 - 494, Declare
least-privilege GITHUB_TOKEN permissions in the workflow by setting contents:
read at the workflow level, or specifically on the deploy-relay2 job after
verifying other jobs’ requirements; preserve all existing job behavior.

Source: Linters/SAST tools

Comment on lines +497 to +502
relay2:
- "apps/relay2/**"
- "packages/shared/**"
- "packages/trpc/**"
- "bun.lock"
- ".github/workflows/deploy-production.yml"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -eu

printf '%s\n' '--- workflow structure ---'
wc -l .github/workflows/deploy-production.yml
printf '%s\n' '--- relevant lines ---'
sed -n '450,535p' .github/workflows/deploy-production.yml

printf '%s\n' '--- workflow references ---'
rg -n -C 3 'on:|workflow_dispatch|push:|branches:|paths-filter|relay2|\.bun-version|Setup Bun|environment:|permissions:|outputs:' .github/workflows/deploy-production.yml

Repository: superset-sh/superset

Length of output: 10340


🏁 Script executed:

#!/bin/bash
set -eu

python3 - <<'PY'
from pathlib import Path
import re

p = Path(".github/workflows/deploy-production.yml")
text = p.read_text()
lines = text.splitlines()

# Extract the relay2 rule block and the relay2 job/step context without executing
# repository code or a workflow.
for i, line in enumerate(lines):
    if re.match(r"\s+relay2:\s*$", line):
        start = i
        while start > 0 and not re.match(r"\s{8}filters:\s*$", lines[start - 1]):
            start -= 1
        end = i + 1
        while end < len(lines) and (lines[end].startswith("              - ") or not lines[end].strip()):
            end += 1
        print("relay2_filter_lines:")
        for n in range(start + 1, end + 1):
            print(f"{n}: {lines[n-1]}")
    if "Setup Bun" in line:
        print("setup_bun_context:")
        for n in range(max(1, i - 5), min(len(lines), i + 8) + 1):
            print(f"{n}: {lines[n-1]}")

print("top_level_trigger_and_permissions:")
for n, line in enumerate(lines[:80], 1):
    if line.strip() in {"on:", "permissions:"} or re.match(r"\s+(push|workflow_dispatch|branches|paths):", line):
        print(f"{n}: {line}")
PY

Repository: superset-sh/superset

Length of output: 32126


🏁 Script executed:

#!/bin/bash
set -eu

python3 - <<'PY'
from pathlib import Path
import fnmatch
import re

workflow = Path(".github/workflows/deploy-production.yml").read_text().splitlines()
bun = Path(".bun-version")
print(f".bun-version_exists={bun.is_file()}")
print(f".bun-version_tracked={'.bun-version' in set(__import__('subprocess').check_output(['git', 'ls-files', '--', '.bun-version'], text=True).splitlines())}")
print(f".bun-version_value={bun.read_text().strip() if bun.is_file() else '<missing>'}")

start = next(i for i, line in enumerate(workflow)
             if line.strip() == "deploy-relay2:")
filter_start = next(i for i in range(start, len(workflow))
                   if workflow[i].strip() == "relay2:")
patterns = []
for line in workflow[filter_start + 1:]:
    m = re.match(r'\s+-\s+"([^"]+)"\s*$', line)
    if not m:
        break
    patterns.append(m.group(1))

changed_paths = [".bun-version"]
matches = {
    path: [pattern for pattern in patterns if fnmatch.fnmatchcase(path, pattern)]
    for path in changed_paths
}
print(f"relay2_patterns={patterns}")
print(f"changed_paths={changed_paths}")
print(f"relay2_matches={matches}")
print(f"relay2_output_for_only_bun_version={'true' if any(matches.values()) else 'false'}")
print("relay2_deploy_condition_on_push=github.event_name == 'push' && steps.changes.outputs.relay2 == 'true'")
PY

Repository: superset-sh/superset

Length of output: 577


Include .bun-version in the Relay2 filter. A push that changes only .bun-version matches none of the current relay2 rules. The conditional Relay2 steps skip, so the deployment does not use the new Bun version.

🤖 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/deploy-production.yml around lines 497 - 502, Add
".bun-version" to the relay2 path filters in the deployment workflow so changes
to the Bun version trigger the Relay2 deployment steps. Preserve all existing
relay2 paths and conditions.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 1 file

You’re at about 91% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact [email protected].

Architecture diagram
sequenceDiagram
    participant GH as GitHub Actions
    participant WF as deploy-production.yml
    participant PF as dorny/paths-filter
    participant Bun as Bun Setup & Build
    participant CF as Cloudflare Workers
    participant DO as Relay2 Durable Objects

    Note over GH,DO: CI/CD Deployment Pipeline - Current State

    GH->>WF: Trigger workflow (push or workflow_dispatch)
    WF->>WF: Job: deploy-relay2

    alt workflow_dispatch (manual)
        WF->>Bun: Skip path filter (always deploy)
        Bun->>Bun: Setup Bun runtime
        Bun->>Bun: Cache dependencies
        Bun->>Bun: Install dependencies (bun install)
        Bun->>CF: Deploy Worker (wranger deploy)
        CF->>DO: NEW: Restart Durable Objects
        DO-->>CF: Host tunnels reconnect (~2s)
    else push to main
        WF->>PF: Detect relay2-relevant changes
        PF->>PF: Check paths: apps/relay2/**, packages/shared/**, packages/trpc/**, bun.lock, workflow file

        alt relay2-relevant changes detected
            PF-->>WF: relay2 = true
            WF->>Bun: Setup Bun runtime
            Bun->>Bun: Cache dependencies
            Bun->>Bun: Install dependencies (bun install)
            Bun->>CF: Deploy Worker (wranger deploy)
            CF->>DO: Restart Durable Objects
            DO-->>CF: Host tunnels reconnect (~2s)
        else no relay2 changes
            PF-->>WF: relay2 = false
            WF->>WF: Skip deploy (no restart)
            Note over WF,DO: Stateless workers (electric-proxy) deploy<br/>unaffected - harmless redeploy
        end
    end

    Note over CF,DO: IMPORTANT: Every deployment causes<br/>Durable Object restart, severing<br/>live host tunnels (in-flight streams drop)
Loading

Re-trigger cubic

@saddlepaddle

Copy link
Copy Markdown
Member Author

Closing per discussion: deploy-time tunnel bounces are recoverable (liveness sweep + ~2s partysocket reconnect + app-layer terminal resume) and not noticeably disruptive in practice, and out-of-band relay deploys won't be part of the workflow going forward — so the gate isn't worth the CI complexity. Revisit if deploy churn ever becomes user-visible.

@saddlepaddle
saddlepaddle deleted the relay2-deploy-gate branch August 12, 2026 00:59

This branch was previously deployed

1 inactive deployment
preview — 95100129 Deployed Aug 11, 2026 by saddlepaddle via Deploy Docs #7479
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