Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/ci-filters.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,19 @@
"scripts/ci-results.*",
"scripts/ci-selection.*"
],
"web-images": [
"apps/dashboard/**",
"apps/learn/**",
"apps/website/**",
"CHANGELOG.md",
".railway/**",
".github/workflows/ci.yml",
".github/workflows/web-hosting.yml",
".github/ci-filters.json",
"scripts/test-web-hosting.mjs",
"scripts/ci-results.*",
"scripts/ci-selection.*"
],
"reviewer": [
"tools/pr-reviewer/**",
".github/workflows/ai-review.yml",
Expand Down
5 changes: 0 additions & 5 deletions .github/codeql-filters.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
{
"workflow": [
".github/workflows/codeql.yml",
".github/codeql-filters.json",
"scripts/codeql-matrix*.mjs"
],
"actions": [".github/workflows/**", ".github/actions/**"],
"javascript": [
"**/*.{js,jsx,ts,tsx,mjs,cjs,mts,cts,svelte,astro}",
Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
dashboard: ${{ steps.filter.outputs.dashboard }}
collection: ${{ steps.filter.outputs.collection }}
website: ${{ steps.filter.outputs.website }}
web-images: ${{ steps.filter.outputs.web-images }}
learn: ${{ steps.filter.outputs.learn }}
reviewer: ${{ steps.filter.outputs.reviewer }}
contracts: ${{ steps.filter.outputs.contracts }}
Expand All @@ -32,6 +33,19 @@ jobs:
with:
filters: .github/ci-filters.json

codeql:
uses: ./.github/workflows/codeql.yml
permissions:
contents: read
pull-requests: read
packages: read
security-events: write

web-images:
needs: changes
if: ${{ needs.changes.outputs.web-images == 'true' }}
uses: ./.github/workflows/web-hosting.yml

structure:
name: Structure
runs-on: ubuntu-latest
Expand Down Expand Up @@ -586,6 +600,8 @@ jobs:
changes,
structure,
railway-config,
codeql,
web-images,
contracts,
reviewer,
server,
Expand Down
46 changes: 20 additions & 26 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,12 @@
name: CodeQL

on:
push:
branches: [main]
paths:
- '.github/workflows/**'
- 'apps/**'
- 'packages/**'
- 'scripts/**'
- 'tools/**'
- '.github/actions/**'
- '.github/codeql-filters.json'
- '*'
pull_request:
branches: [main]
paths:
- '.github/workflows/**'
- 'apps/**'
- 'packages/**'
- 'scripts/**'
- 'tools/**'
- '.github/actions/**'
- '.github/codeql-filters.json'
- '*'
workflow_call:
workflow_dispatch:

permissions:
contents: read

concurrency:
group: codeql-${{ github.ref }}
cancel-in-progress: true

jobs:
changes:
name: Detect CodeQL inputs
Expand Down Expand Up @@ -169,3 +144,22 @@ jobs:
path: ${{ runner.temp }}/codeql-results/*.sarif
if-no-files-found: error
retention-days: 7

result:
name: Require applicable CodeQL analyses
if: ${{ always() }}
needs: [changes, analyze]
runs-on: ubuntu-latest
permissions: {}
env:
DETECTION_RESULT: ${{ needs.changes.result }}
ANALYSIS_SELECTED: ${{ needs.changes.outputs.any }}
ANALYSIS_RESULT: ${{ needs.analyze.result }}
steps:
- name: Check scan outcome
run: |
test "$DETECTION_RESULT" = success
case "$ANALYSIS_SELECTED:$ANALYSIS_RESULT" in
true:success|false:skipped) ;;
*) echo 'An applicable CodeQL analysis did not succeed.' >&2; exit 1 ;;
esac
9 changes: 1 addition & 8 deletions .github/workflows/web-hosting.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
name: Web hosting images
on:
pull_request:
paths:
- 'apps/website/**'
- 'CHANGELOG.md'
- 'apps/learn/**'
- 'apps/dashboard/**'
- '.github/workflows/web-hosting.yml'
- 'scripts/test-web-hosting.mjs'
workflow_call:
workflow_dispatch:
permissions:
contents: read
Expand Down
58 changes: 57 additions & 1 deletion .railway/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ deployment. Do not put its path in the dashboard's legacy **Config File** field.
2. Verify the declared source connections and roots: `/` for api, worker, website;
`/apps/dashboard` for dashboard; `/apps/learn` for learn. For a PR environment, set
`RAILWAY_CONFIG_BRANCH` to its existing GitHub branch for every plan/apply.
Production uses `main`; staging retains `offseason/mock-game-charged-up`.
Production and staging use `main`, matching the verified live services.
Compare variable names with `env` in the file and add `preserve()` entries for
any newly configured variables before applying. Never include secret values. Preserve Dashboard's existing release workflow when deciding source/deploy policy.
3. Confirm the preview has isolated Postgres/Redis and sandbox integration keys.
Expand Down Expand Up @@ -80,3 +80,59 @@ For finite offseason batches, see [Worker batch rollout](../docs/worker-batch-ro
`RAILWAY_WORKER_CRON='0 18 * * *'` is an opt-in local plan/apply input; production defaults to six-hour event-aware windows after the rollout. An
explicit empty `RAILWAY_WORKER_CRON` restores continuous mode. Merging this configuration does not enable
Cron or PostgreSQL Serverless.

## Tested-commit deployment gate (LVT-337)

GitHub requires `Monorepo CI` on `main`. That job requires Railway IaC checks,
app tests, applicable production web image HTTP checks, and the CodeQL result.
CodeQL selects each language by its watch paths. Only a manual CodeQL run
requests the full matrix. A successful selection with zero applicable analyses
passes the aggregate. A failed or cancelled selected analysis fails it.
CI runs on every push to `main`.

`RAILWAY_WAIT_FOR_CI=true` opts all five GitHub sources in the linked environment
into Railway's [Wait for CI](https://docs.railway.com/deployments/github-autodeploys).
Keep that input in subsequent plans for an environment after enabling it. An
explicit `false` restores the prior setting. Pass the current live Worker mode
to the plan as well. For a continuously running Worker, use
`RAILWAY_WORKER_CRON=''` so the same apply does not switch it to scheduled mode.

1. Link to an isolated environment with GitHub autodeploy enabled. Generate a
read-only plan and confirm the only intended change is `checkSuites` on app
sources. Review the plan and keep the IDs of the currently healthy deployments.
2. After applying the reviewed test plan, verify a commit with an applicable
failing check does not deploy. Verify a later passing commit does deploy.
Match the GitHub workflow SHA to the Railway deployment SHA and record both.
3. Review the production plan separately. Services with autodeploy disabled
still need their approved promotion path. For manual rollback, identify the
last healthy deployment by ID and verify service health after redeployment.

Railway evaluates workflow conclusions and can ignore a cancelled workflow when
another workflow passed. Keep the `main` CI workflow free of superseding-run
cancellation. Verify the aggregate outcome and deployed SHA for each promotion.

The November 20 read-only production audit found the API already had sleeping
enabled. The graph now preserves that setting alongside the Worker's existing
six-hour schedule. The refreshed production plan proposed only the five
`source.checkSuites` updates and reported zero diagnostics. The PR #128 preview
plan also proposes explicitly writing
`WORKER_MODE=continuous` where the Worker previously used its default. Review
that reconciliation independently before using the preview to test Wait for CI.

## Verified live state (November 12, 2026)

The Lovat project is `c210dce8-37af-4bf0-b1e0-7e28b30597c6` in **8033 Admin's
Projects**. The connected list-projects inventory omitted it; a direct project ID
lookup and the local Railway CLI both work. See the
[cutover verification record](evidence/2026-11-12/verification.md) and redacted
configuration snapshot. The five application services already belong to the
`lovat-apps` named partial in production and staging. PR #128 inherits matching
settings but has no explicit partial ownership; preview adoption remains open.

The audit found source/sleeping/preview-limit drift in the authored file. The
updated definitions preserve the observed live settings rather than changing
service availability, cost or staging source on the next apply. Healthcheck
readiness (LVT-339) and release migrations (LVT-338) remain separate proposed
changes. No live settings were applied by
this audit. Secret-value isolation and a restore/rollback exercise still need
independent evidence.
63 changes: 56 additions & 7 deletions .railway/config.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,29 @@ import { test } from "node:test";
import { createRailwayContext } from "railway/iac";
import config, { partial } from "./railway.ts";

test("Wait for CI requires an explicit setting when rendering a plan", (t) => {
const previous = process.env.RAILWAY_WAIT_FOR_CI;
t.after(() => {
if (previous === undefined) delete process.env.RAILWAY_WAIT_FOR_CI;
else process.env.RAILWAY_WAIT_FOR_CI = previous;
});
const context = createRailwayContext({ environment: "production" });
const sourceSettings = () =>
config(context).resources.map((app) => app.source.checkSuites);

delete process.env.RAILWAY_WAIT_FOR_CI;
assert(sourceSettings().every((enabled) => enabled === false));
process.env.RAILWAY_WAIT_FOR_CI = "true";
assert(sourceSettings().every((enabled) => enabled === true));
process.env.RAILWAY_WAIT_FOR_CI = "false";
assert(sourceSettings().every((enabled) => enabled === false));
process.env.RAILWAY_WAIT_FOR_CI = "yes";
assert.throws(
() => config(context),
/RAILWAY_WAIT_FOR_CI must be true or false/,
);
});

for (const environment of ["production", "staging"]) {
test(`${environment} retains deployment contracts`, () => {
const graph = config(
Expand All @@ -20,7 +43,10 @@ for (const environment of ["production", "staging"]) {
for (const resource of graph.resources) {
assert.equal(resource.build.builder, "DOCKERFILE");
assert(resource.build.watchPatterns.includes("/.railway/**"));
assert.notEqual(resource.deploy.sleepApplication, true);
assert.equal(
resource.deploy.sleepApplication,
resource.name === "worker" ? undefined : true,
);
assert.equal(
resource.deploy.restartPolicyType ?? "ON_FAILURE",
resource.name === "worker" && environment === "production"
Expand All @@ -29,12 +55,7 @@ for (const environment of ["production", "staging"]) {
);
// Keep source connections and credential values during adoption.
assert.equal(resource.source.repo, "HighlanderRobotics/lovat");
assert.equal(
resource.source.branch,
environment === "production"
? "main"
: "offseason/mock-game-charged-up",
);
assert.equal(resource.source.branch, "main");
assert(Object.keys(resource.variables).length > 0);
for (const [name, value] of Object.entries(resource.variables)) {
assert.deepEqual(
Expand Down Expand Up @@ -108,6 +129,34 @@ test("refuses preview plans without an explicit source branch", () => {
}
});

test("preview retains inherited sleeping and API limits without owning databases", (t) => {
const previous = process.env.RAILWAY_CONFIG_BRANCH;
process.env.RAILWAY_CONFIG_BRANCH =
"jackshim415/lvt-334-server-redact-request-analytics-and";
t.after(() => {
if (previous === undefined) {
delete process.env.RAILWAY_CONFIG_BRANCH;
} else {
process.env.RAILWAY_CONFIG_BRANCH = previous;
}
});
const graph = config(
createRailwayContext({ environment: "lovat-pr-128", projectName: "lovat" }),
);
assert.equal(graph.resources.length, 5);
for (const resource of graph.resources) {
assert.equal(resource.source.branch, process.env.RAILWAY_CONFIG_BRANCH);
assert.equal(
resource.deploy.sleepApplication,
resource.name === "worker" ? undefined : true,
);
}
const api = graph.resources.find((r) => r.name === "api");
assert.deepEqual(api.deploy.limitOverride, {
containers: { cpu: 2, memoryBytes: 2147483648 },
});
});

test("offseason cron uses a finite batch without a health listener or restarts", () => {
const previous = process.env.RAILWAY_WORKER_CRON;
process.env.RAILWAY_WORKER_CRON = "0 18 * * *";
Expand Down
Loading
Loading