Skip to content

fix(ci): derive Railway preview URLs from env name#52

Merged
aspiers merged 1 commit intomainfrom
fix/e2e-preview-url-derivation
Apr 8, 2026
Merged

fix(ci): derive Railway preview URLs from env name#52
aspiers merged 1 commit intomainfrom
fix/e2e-preview-url-derivation

Conversation

@aspiers
Copy link
Copy Markdown
Contributor

@aspiers aspiers commented Apr 8, 2026

Summary

Fixes the e2e-pr workflow's URL derivation so it works when Railway gives a PR environment its collision-avoidance fallback name (e.g. pr-3897f1-47) instead of the usual ePDS-pr-<N>.

Observed on PR #47: a force-push hit Railway's 1–2 minute env-cleanup window, Railway created the new env as pr-3897f1-47, the service domains became certified-app<svc>-pr-3897f1-47.up.railway.app, and the workflow's hardcoded certified-app<svc>-epds-pr-<N>.up.railway.app template pointed at nothing. The wait-for-services step then timed out after 5 minutes. Railway's explanation of the fallback naming: https://station.railway.com/questions/pr-environment-name-format-change-causin-9aaa904f

This PR makes the workflow read the live env name out of github.event.deployment.environment, lowercase it, and build URLs as <service>-<env-name>.up.railway.app. That matches Railway's actual domain-generation rule for both the normal and the fallback naming formats — no Railway API token needed.

Why this is a separate PR

GitHub runs deployment_status-triggered workflows from the default branch's copy of the workflow file, not the PR branch's. So this fix has to land on main before it can be exercised on #47 (which is where it was discovered). Kept minimal and workflow-only to make review trivial.

Test plan

  • Empirically verified against live Railway envs: ePDS-pr-48 (normal) → produces certified-apppds-core-epds-pr-48.up.railway.app ✓ ; pr-3897f1-47 (fallback) → produces certified-apppds-core-pr-3897f1-47.up.railway.app ✓. Both match what environment { serviceInstances { domains { serviceDomains } } } reports from Railway's GraphQL API.
  • Slug-derivation bash verified against "ePDS / ePDS-pr-48", "ePDS / ePDS-pr-47", "ePDS / pr-3897f1-47".
  • After merge: trigger a deployment_status on expand e2e coverage to account-settings, consent and auto-account-creation #47 and confirm the e2e suite reaches the test phase (not a wait-for-services timeout).

Summary by CodeRabbit

  • Chores
    • CI workflow updated to derive service URLs from the deployment environment slug (normalized to lowercase).
    • Added validation of environment names and fail-fast behavior for invalid values.
    • Service URL outputs are now emitted in a consolidated block for improved consistency and maintainability.

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 8, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
epds-demo Ready Ready Preview, Comment Apr 8, 2026 0:30am

Request Review

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 8, 2026

Caution

Review failed

Pull request was closed or merged during review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: aac1d32d-aece-4f59-8f0f-ed241bfa9fe6

📥 Commits

Reviewing files that changed from the base of the PR and between 47f81e1 and 3c4b50f.

📒 Files selected for processing (1)
  • .github/workflows/e2e-pr.yml

📝 Walkthrough

Walkthrough

The workflow removes the "Extract PR number" step and updates the "Derive service URLs" step to parse, lowercase, and validate the deployment environment slug from github.event.deployment.environment, then construct and emit four service URL outputs from that slug; the workflow now fails if parsing/validation fails.

Changes

Cohort / File(s) Summary
GitHub Actions Workflow Configuration
.github/workflows/e2e-pr.yml
Removed the PR number extraction step; changed URL derivation to parse and lowercase the deployment environment slug from github.event.deployment.environment; added slug validation and failure on parse error; consolidated writing of epds_url, auth_url, demo_url, and mailpit_url to a single $GITHUB_OUTPUT block.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 I parsed the slug with nimble paws,
Lowercased names and checked the laws,
URLs stitched neat from env so bright,
No PR digits in my sight,
The workflow hops and sleeps tonight. 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and accurately summarizes the main change: deriving Railway preview URLs from the environment name instead of the PR number.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/e2e-preview-url-derivation

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 and usage tips.

@railway-app
Copy link
Copy Markdown

railway-app bot commented Apr 8, 2026

🚅 Deployed to the ePDS-pr-52 environment in ePDS

Service Status Web Updated (UTC)
@certified-app/pds-core ✅ Success (View Logs) Web Apr 8, 2026 at 12:22 am
@certified-app/demo ✅ Success (View Logs) Web Apr 8, 2026 at 12:21 am
@certified-app/auth-service ✅ Success (View Logs) Web Apr 8, 2026 at 12:21 am

@coveralls-official
Copy link
Copy Markdown

coveralls-official bot commented Apr 8, 2026

Coverage Report for CI Build 24111163068

Coverage remained the same at 29.583%

Details

  • Coverage remained the same as the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 1638
Covered Lines: 517
Line Coverage: 31.56%
Relevant Branches: 931
Covered Branches: 243
Branch Coverage: 26.1%
Branches in Coverage %: Yes
Coverage Strength: 2.6 hits per line

💛 - Coveralls

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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/e2e-pr.yml:
- Around line 39-44: The env parsing is too permissive: before deriving
ENV_NAME/ENV_SLUG from FULL_ENV ensure FULL_ENV contains the literal separator "
/ " and validate the parsed ENV_NAME against an allowed charset (e.g.,
alphanumeric, dash, underscore, dot) with a regexp; if either check fails, emit
a clear ::error:: message including the offending FULL_ENV and exit 1. Update
the block that sets ENV_NAME, ENV_SLUG and the error branch to first test for
the separator and then test ENV_NAME with the regexp (use the ENV_NAME variable
and ENV_SLUG creation via lowercasing as currently implemented) so malformed
payloads fail immediately rather than producing bad URLs later.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4463b2d3-259a-44b3-b97e-a5b289981db7

📥 Commits

Reviewing files that changed from the base of the PR and between 1865314 and 47f81e1.

📒 Files selected for processing (1)
  • .github/workflows/e2e-pr.yml

Comment thread .github/workflows/e2e-pr.yml
The previous approach hardcoded a URL template
"certified-app<svc>-epds-pr-<N>.up.railway.app", which only works when
Railway gives the env its normal "ePDS-pr-<N>" name. When a PR is
force-pushed (or closed/reopened) during Railway's 1-2 minute env
cleanup window, Railway falls back to a collision-avoidance name like
"pr-3897f1-47" (per Railway's own explanation:
https://station.railway.com/questions/pr-environment-name-format-change-causin-9aaa904f).
The resulting service domains then look like
"certified-app<svc>-pr-3897f1-47.up.railway.app", and the templated
URLs become unreachable, causing the wait-for-services step to time
out after 5 minutes.

Read the live env name out of the deployment_status webhook payload
instead, lowercase it, and build URLs as <service>-<env-name>. This
matches Railway's actual domain-generation rule and works for both the
normal and the fallback naming formats with no Railway API lookup
(which would require a Railway token in repo secrets).

Also validate the incoming env string: require the "<project> / <env>"
separator and constrain the parsed env name to a DNS-slug charset so
malformed payloads fail immediately with a clear error rather than
producing bad URLs that only fail later in the polling step.

Verified empirically against current envs ePDS-pr-48 and pr-3897f1-47:
both produce URLs matching what Railway has actually generated.
@aspiers aspiers force-pushed the fix/e2e-preview-url-derivation branch from 47f81e1 to 3c4b50f Compare April 8, 2026 00:29
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 8, 2026

@aspiers aspiers merged commit 5fd73ca into main Apr 8, 2026
11 of 12 checks passed
@aspiers aspiers deleted the fix/e2e-preview-url-derivation branch April 8, 2026 00:31
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