Skip to content

Commit 5cdd5ec

Browse files
fix: refresh queued steer restrictions against main
2 parents ecdc92f + 3afb9b3 commit 5cdd5ec

1,234 files changed

Lines changed: 66268 additions & 28930 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.devcontainer/devcontainer.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Dev container for T3 Code. Mirrors CI (ubuntu-24.04, Node 24, Rust stable)
1+
// Dev container for T3 Code. Mirrors CI (ubuntu-24.04, Node 26, Rust stable)
22
// and the canonical setup in docs/operations/development.md: global `vp`, `vp i`.
33
// Contributor doc: docs/internals/devcontainer.md
44
{
@@ -8,7 +8,7 @@
88
// nodeGypDependencies (default true) brings python3/make/g++, which Linux
99
// needs for node-pty's node-gyp fallback (its prebuilds are mac/win only).
1010
"ghcr.io/devcontainers/features/node:2": {
11-
"version": "24"
11+
"version": "26"
1212
},
1313
// native/resource-monitor (edition 2024, needs stable >= 1.85). The server
1414
// degrades gracefully without the binary, but CI checks cargo fmt + test.

‎.github/actions/setup-ci-deps/action.yml‎

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,38 @@ description: Install Vite+ and the workspace dependencies from cache.
33
runs:
44
using: composite
55
steps:
6-
# setup-vp reuses an installed exact version, so restoring its home skips the
7-
# installer download on every job.
6+
# ~/.vite-plus holds vp, the Node.js runtime, and pnpm. A cache entry never
7+
# updates, so the key names all three versions; otherwise a pnpm or Node.js
8+
# bump makes every job download them from npm again.
89
- name: Resolve Vite+ version
910
id: vp
1011
shell: bash
1112
run: |
1213
echo "version=$(sed -nE 's/^ vite-plus: ([0-9][^ ]*)$/\1/p' pnpm-workspace.yaml)" >> "$GITHUB_OUTPUT"
14+
echo "node=$(jq -r '.engines.node' package.json)" >> "$GITHUB_OUTPUT"
15+
echo "pnpm=$(jq -r '.packageManager' package.json)" >> "$GITHUB_OUTPUT"
1316
1417
- name: Cache Vite+
18+
id: vp_cache
1519
if: steps.vp.outputs.version != ''
1620
uses: actions/cache@v6
1721
with:
1822
path: ~/.vite-plus
19-
key: vite-plus-home-v1-${{ runner.os }}-${{ runner.arch }}-${{ steps.vp.outputs.version }}
23+
key: vite-plus-home-v2-${{ runner.os }}-${{ runner.arch }}-${{ steps.vp.outputs.version }}-node${{ steps.vp.outputs.node }}-${{ steps.vp.outputs.pnpm }}
24+
25+
# setup-vp always runs the installer, which fetches vp from npm even when
26+
# this exact version is installed. A cache hit already has everything, so
27+
# skip setup-vp and do its remaining work here. This keeps npm outages from
28+
# failing jobs.
29+
- name: Use cached Vite+
30+
if: steps.vp_cache.outputs.cache-hit == 'true'
31+
shell: bash
32+
run: |
33+
echo "$HOME/.vite-plus/bin" >> "$GITHUB_PATH"
34+
"$HOME/.vite-plus/bin/vp" env use "${{ steps.vp.outputs.node }}"
2035
2136
- name: Setup Vite+
37+
if: steps.vp_cache.outputs.cache-hit != 'true'
2238
uses: voidzero-dev/setup-vp@v1
2339
with:
2440
node-version-file: package.json
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
const assert = require("node:assert/strict");
2+
const { spawnSync } = require("node:child_process");
3+
const { mkdtempSync, readFileSync, rmSync, existsSync } = require("node:fs");
4+
const { tmpdir } = require("node:os");
5+
const { join } = require("node:path");
6+
const { test } = require("node:test");
7+
8+
const release = readFileSync(join(__dirname, "../workflows/release.yml"), "utf8");
9+
const preview = readFileSync(join(__dirname, "../workflows/web-preview.yml"), "utf8");
10+
const stepPattern =
11+
/ name: (?:Build staged deployment|Deploy preview)\n shell: bash\n run: \|\n((?: .*\n|\n)+)/g;
12+
const steps = [
13+
...Array.from(release.matchAll(stepPattern), (match, index) => [
14+
index === 0 ? "hosted web" : "marketing",
15+
match[1],
16+
]),
17+
...Array.from(preview.matchAll(stepPattern), (match) => ["web preview", match[1]]),
18+
];
19+
assert.equal(steps.length, 3, "Expected both release steps and the preview step");
20+
21+
const url = "https://t3code-fixture-pinglabs.vercel.app";
22+
const warning = 'Error while parsing config file: "/runner/t3code/pnpm-lock.yaml"';
23+
24+
function runStep(script, stdout, exitCode = 0) {
25+
const directory = mkdtempSync(join(tmpdir(), "t3-vercel-output-"));
26+
const outputFile = join(directory, "output");
27+
try {
28+
const result = spawnSync(
29+
"bash",
30+
[
31+
"-c",
32+
'vp() { printf "%s\\n" "$FIXTURE_STDOUT"; return "$FIXTURE_EXIT"; }\n' +
33+
'curl() { printf \'{"id":"fixture-project"}\\n\'; }\n' +
34+
script.replace(/^ /gm, "").replace(/\$\{\{.*?\}\}/g, "fixture"),
35+
],
36+
{
37+
encoding: "utf8",
38+
env: {
39+
PATH: process.env.PATH,
40+
VERCEL_TOKEN: "fixture-token",
41+
VERCEL_ORG_ID: "fixture-org",
42+
VERCEL_PROJECT_ID: "fixture-project",
43+
GITHUB_OUTPUT: outputFile,
44+
FIXTURE_STDOUT: stdout,
45+
FIXTURE_EXIT: String(exitCode),
46+
},
47+
},
48+
);
49+
assert.ifError(result.error);
50+
return {
51+
...result,
52+
output: existsSync(outputFile) ? readFileSync(outputFile, "utf8") : "",
53+
};
54+
} finally {
55+
rmSync(directory, { recursive: true, force: true });
56+
}
57+
}
58+
59+
for (const [name, script] of steps) {
60+
for (const [label, stdout] of [
61+
["plain URL", url],
62+
["lockfile warning", `${warning}\n${url}`],
63+
["trailing diagnostic", `${url}\nDone`],
64+
]) {
65+
test(`${name}: saves one deployment URL after ${label}`, () => {
66+
const result = runStep(script, stdout);
67+
assert.equal(result.status, 0, result.stderr);
68+
assert.deepEqual(
69+
result.output.split("\n").filter((line) => !line.startsWith("project_id=")),
70+
[`deployment_url=${url}`, ""],
71+
);
72+
});
73+
}
74+
75+
for (const [label, stdout, exitCode] of [
76+
["missing URL", warning, 0],
77+
["invalid URL", "https://example.invalid/deployment", 0],
78+
["multiple URLs", `${url}\nhttps://other.vercel.app`, 0],
79+
["failed deployment", url, 1],
80+
]) {
81+
test(`${name}: rejects ${label} without saving output`, () => {
82+
const result = runStep(script, stdout, exitCode);
83+
assert.notEqual(result.status, 0);
84+
assert.equal(result.output, "");
85+
});
86+
}
87+
}

‎.github/workflows/ci.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ jobs:
253253
run: python3 -B .github/scripts/stage-preview-bundle.test.py
254254

255255
- name: Test release checks
256-
run: node --test .github/scripts/check-nightly-release.test.cjs
256+
run: node --test .github/scripts/check-nightly-release.test.cjs .github/scripts/vercel-deployment-output.test.cjs
257257

258258
- name: Finish installing browser secret helper build libraries
259259
timeout-minutes: 5

‎.github/workflows/mobile-showcase-screenshots.yml‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ env:
4343

4444
jobs:
4545
ios:
46-
name: iPhone 6.9, iPhone 6.5, and iPad 13
46+
name: iPhone, iPhone Duo, and iPad 13
4747
if: inputs.platform == 'all' || inputs.platform == 'ios'
4848
runs-on: blacksmith-12vcpu-macos-26
4949
# Capturing every palette multiplies the device matrix by six, and only the
@@ -87,6 +87,9 @@ jobs:
8787
brew install cameroncooke/axe/axe
8888
axe --version
8989
90+
- name: Install foldable simulator controls
91+
run: npm install --global [email protected]
92+
9093
- name: Capture iOS showcase
9194
run: pnpm screenshots:mobile --platform ios --appearance "${{ inputs.appearance }}" --theme "${{ inputs.theme }}"
9295

Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
name: Clean up relay preview
2+
3+
# Tears down stage `pr-<n>` when `relay:preview` is removed or the PR closes,
4+
# and retries teardown for closed labeled PRs on a schedule. A label stays on a
5+
# PR only while its teardown is outstanding, so the scheduled retry lists
6+
# exactly the failures.
7+
#
8+
# This runs under pull_request_target, so the workflow and the Alchemy program
9+
# come from the default branch. No PR code runs here, which is why it needs no
10+
# reviewer approval and why a PR cannot edit its own teardown to reach secrets.
11+
on:
12+
pull_request_target:
13+
types: [unlabeled, closed]
14+
schedule:
15+
- cron: "17 7 * * *"
16+
workflow_dispatch:
17+
18+
permissions:
19+
contents: read
20+
issues: read
21+
pull-requests: read
22+
23+
jobs:
24+
cleanup_pr:
25+
name: Tear down relay preview
26+
if: >-
27+
github.ref == 'refs/heads/main' &&
28+
github.event_name == 'pull_request_target' &&
29+
(
30+
(github.event.action == 'unlabeled' && github.event.label.name == 'relay:preview') ||
31+
(github.event.action == 'closed' && contains(github.event.pull_request.labels.*.name, 'relay:preview'))
32+
)
33+
# Job-level so that events which skip this job, such as a closed PR without
34+
# the label, never take the group's pending slot. GitHub replaces a pending
35+
# run in a group with a newer one, which would drop a queued teardown.
36+
concurrency:
37+
group: relay-preview-${{ github.event.pull_request.number }}
38+
cancel-in-progress: false
39+
permissions:
40+
contents: read
41+
issues: write
42+
pull-requests: write
43+
runs-on: blacksmith-8vcpu-ubuntu-2404
44+
timeout-minutes: 30
45+
environment:
46+
name: relay-preview-cleanup
47+
env:
48+
GH_TOKEN: ${{ github.token }}
49+
STAGE: pr-${{ github.event.pull_request.number }}
50+
CLOUDFLARE_ACCOUNT_ID: ${{ vars.CLOUDFLARE_ACCOUNT_ID }}
51+
PLANETSCALE_ORGANIZATION: ${{ vars.PLANETSCALE_ORGANIZATION }}
52+
AXIOM_ORG_ID: ${{ vars.AXIOM_ORG_ID }}
53+
RELAY_API_ZONE_NAME: ${{ vars.RELAY_API_ZONE_NAME }}
54+
RELAY_TUNNEL_ZONE_NAME: ${{ vars.RELAY_TUNNEL_ZONE_NAME }}
55+
CLERK_PUBLISHABLE_KEY: ${{ vars.CLERK_PUBLISHABLE_KEY }}
56+
CLERK_JWT_AUDIENCE: ${{ vars.CLERK_JWT_AUDIENCE }}
57+
APNS_ENABLED: "false"
58+
ALCHEMY_TELEMETRY_DISABLED: "1"
59+
steps:
60+
- name: Checkout default branch
61+
uses: actions/checkout@v6
62+
with:
63+
ref: ${{ github.event.repository.default_branch }}
64+
sparse-checkout: |
65+
/*
66+
!/.repos/
67+
sparse-checkout-cone-mode: false
68+
69+
- name: Setup Vite+
70+
uses: voidzero-dev/setup-vp@v1
71+
with:
72+
node-version-file: package.json
73+
cache: true
74+
run-install: |
75+
args:
76+
- --filter=t3code-relay...
77+
78+
# Destroy also runs the preview tunnel sweep, which is part of the stack.
79+
- name: Destroy preview stage
80+
run: vp run --filter t3code-relay destroy --stage "$STAGE" --yes --no-input
81+
env:
82+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
83+
PLANETSCALE_API_TOKEN_ID: ${{ secrets.PLANETSCALE_API_TOKEN_ID }}
84+
PLANETSCALE_API_TOKEN: ${{ secrets.PLANETSCALE_API_TOKEN }}
85+
AXIOM_TOKEN: ${{ secrets.AXIOM_TOKEN }}
86+
CLERK_SECRET_KEY: ${{ secrets.CLERK_SECRET_KEY }}
87+
88+
# Only reached after a successful destroy. A failed one keeps the label,
89+
# so the scheduled retry picks the PR up again.
90+
- name: Clear the teardown marker
91+
if: github.event.action == 'closed'
92+
run: gh pr edit "${{ github.event.pull_request.number }}" --repo "$GITHUB_REPOSITORY" --remove-label relay:preview
93+
94+
# An unlabeled event has already removed the label, so a failed teardown
95+
# must put it back or no retry will ever see the stage. Labels added with
96+
# GITHUB_TOKEN do not start new runs, so this does not redeploy.
97+
- name: Restore the teardown marker after a failed destroy
98+
if: failure() && github.event.action == 'unlabeled'
99+
run: gh pr edit "${{ github.event.pull_request.number }}" --repo "$GITHUB_REPOSITORY" --add-label relay:preview
100+
101+
list_closed_previews:
102+
name: List closed relay previews
103+
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request_target'
104+
runs-on: blacksmith-8vcpu-ubuntu-2404
105+
timeout-minutes: 10
106+
outputs:
107+
numbers: ${{ steps.list.outputs.numbers }}
108+
steps:
109+
# The issues endpoint is paginated by gh, so there is no listing cap. Pull
110+
# requests appear there with a `pull_request` key.
111+
- name: List closed PRs labeled relay:preview
112+
id: list
113+
env:
114+
GH_TOKEN: ${{ github.token }}
115+
run: |
116+
numbers=$(gh api --paginate --method GET "repos/$GITHUB_REPOSITORY/issues" \
117+
-f labels=relay:preview -f state=closed -f per_page=100 \
118+
--jq '.[] | select(.pull_request) | .number') \
119+
|| { echo "Could not list closed relay:preview PRs" >&2; exit 1; }
120+
json=$(printf '%s\n' "$numbers" | jq -Rsc 'split("\n") | map(select(length > 0) | tonumber)')
121+
echo "Closed relay:preview PRs: $json"
122+
echo "numbers=$json" >> "$GITHUB_OUTPUT"
123+
124+
sweep_pr:
125+
name: Retry teardown for PR ${{ matrix.number }}
126+
needs: list_closed_previews
127+
if: github.ref == 'refs/heads/main' && needs.list_closed_previews.outputs.numbers != '[]'
128+
runs-on: blacksmith-8vcpu-ubuntu-2404
129+
timeout-minutes: 30
130+
strategy:
131+
fail-fast: false
132+
max-parallel: 4
133+
matrix:
134+
number: ${{ fromJSON(needs.list_closed_previews.outputs.numbers) }}
135+
# Same group as the deploy and teardown for this PR, so a reopened PR's
136+
# deploy cannot run concurrently with a teardown of its previous stage.
137+
concurrency:
138+
group: relay-preview-${{ matrix.number }}
139+
cancel-in-progress: false
140+
permissions:
141+
contents: read
142+
issues: write
143+
pull-requests: write
144+
environment:
145+
name: relay-preview-cleanup
146+
env:
147+
GH_TOKEN: ${{ github.token }}
148+
STAGE: pr-${{ matrix.number }}
149+
CLOUDFLARE_ACCOUNT_ID: ${{ vars.CLOUDFLARE_ACCOUNT_ID }}
150+
PLANETSCALE_ORGANIZATION: ${{ vars.PLANETSCALE_ORGANIZATION }}
151+
AXIOM_ORG_ID: ${{ vars.AXIOM_ORG_ID }}
152+
RELAY_API_ZONE_NAME: ${{ vars.RELAY_API_ZONE_NAME }}
153+
RELAY_TUNNEL_ZONE_NAME: ${{ vars.RELAY_TUNNEL_ZONE_NAME }}
154+
CLERK_PUBLISHABLE_KEY: ${{ vars.CLERK_PUBLISHABLE_KEY }}
155+
CLERK_JWT_AUDIENCE: ${{ vars.CLERK_JWT_AUDIENCE }}
156+
APNS_ENABLED: "false"
157+
ALCHEMY_TELEMETRY_DISABLED: "1"
158+
steps:
159+
# The lock above is taken before this runs, so the state read here is
160+
# current. An open PR, including one reopened since the listing, is left
161+
# alone. GitHub reports merged PRs as MERGED, so anything not OPEN counts.
162+
- name: Confirm the PR is not open
163+
id: eligible
164+
run: |
165+
state=$(gh pr view "${{ matrix.number }}" --repo "$GITHUB_REPOSITORY" \
166+
--json state --jq 'if .state == "OPEN" then "no" else "yes" end') \
167+
|| { echo "Could not read PR ${{ matrix.number }}" >&2; exit 1; }
168+
echo "eligible=$state" >> "$GITHUB_OUTPUT"
169+
[ "$state" = yes ] || echo "PR ${{ matrix.number }} is open again; leaving $STAGE alone."
170+
171+
- name: Checkout default branch
172+
if: steps.eligible.outputs.eligible == 'yes'
173+
uses: actions/checkout@v6
174+
with:
175+
ref: ${{ github.event.repository.default_branch }}
176+
sparse-checkout: |
177+
/*
178+
!/.repos/
179+
sparse-checkout-cone-mode: false
180+
181+
- name: Setup Vite+
182+
if: steps.eligible.outputs.eligible == 'yes'
183+
uses: voidzero-dev/setup-vp@v1
184+
with:
185+
node-version-file: package.json
186+
cache: true
187+
run-install: |
188+
args:
189+
- --filter=t3code-relay...
190+
191+
- name: Destroy preview stage
192+
if: steps.eligible.outputs.eligible == 'yes'
193+
run: vp run --filter t3code-relay destroy --stage "$STAGE" --yes --no-input
194+
env:
195+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
196+
PLANETSCALE_API_TOKEN_ID: ${{ secrets.PLANETSCALE_API_TOKEN_ID }}
197+
PLANETSCALE_API_TOKEN: ${{ secrets.PLANETSCALE_API_TOKEN }}
198+
AXIOM_TOKEN: ${{ secrets.AXIOM_TOKEN }}
199+
CLERK_SECRET_KEY: ${{ secrets.CLERK_SECRET_KEY }}
200+
201+
- name: Clear the teardown marker
202+
if: steps.eligible.outputs.eligible == 'yes'
203+
run: gh pr edit "${{ matrix.number }}" --repo "$GITHUB_REPOSITORY" --remove-label relay:preview

0 commit comments

Comments
 (0)