Fix Iroh relay policy Vercel deployment (#8118)
* Add regression coverage for Vercel build inputs * Fix Iroh relay policy Vercel deployment * Update relay catalog workflow paths * Make relay retry test deterministic * Fix Iroh authorization test module import * Account for Iroh test import --------- Co-authored-by: cmux reload-cloud <[email protected]>
This commit is contained in:
co-authored by
cmux reload-cloud
parent
85ded20f53
commit
cf18c5918f
@@ -276,7 +276,7 @@ jobs:
|
||||
run: bun install --frozen-lockfile
|
||||
|
||||
- name: Validate managed relay catalog
|
||||
run: bun ../scripts/generate-managed-iroh-relay-catalog.ts --check
|
||||
run: bun tools/generate-managed-iroh-relay-catalog.ts --check
|
||||
|
||||
- name: Typecheck
|
||||
run: bun run typecheck
|
||||
|
||||
@@ -20,14 +20,14 @@ on:
|
||||
paths:
|
||||
- "workers/presence/**"
|
||||
- "config/iroh/managed-relay-catalog.json"
|
||||
- "scripts/generate-managed-iroh-relay-catalog.ts"
|
||||
- "web/tools/generate-managed-iroh-relay-catalog.ts"
|
||||
- ".github/workflows/presence.yml"
|
||||
push:
|
||||
branches: [main]
|
||||
paths:
|
||||
- "workers/presence/**"
|
||||
- "config/iroh/managed-relay-catalog.json"
|
||||
- "scripts/generate-managed-iroh-relay-catalog.ts"
|
||||
- "web/tools/generate-managed-iroh-relay-catalog.ts"
|
||||
- ".github/workflows/presence.yml"
|
||||
|
||||
permissions:
|
||||
|
||||
+5
-4
@@ -231,10 +231,11 @@ struct CmxIrohRelayCredentialCoordinatorTests {
|
||||
endpointIdentity: fixture.identity
|
||||
)
|
||||
|
||||
#expect(
|
||||
await clockEvents.next()
|
||||
== .sleep(fixture.now.addingTimeInterval(600))
|
||||
)
|
||||
guard case let .sleep(deadline) = await clockEvents.next() else {
|
||||
Issue.record("Expected the relay retry sleep")
|
||||
return
|
||||
}
|
||||
#expect(deadline == fixture.now.addingTimeInterval(600))
|
||||
#expect(await endpoint.observedRelayUpdates().isEmpty)
|
||||
await coordinator.deactivate()
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import CMUXMobileCore
|
||||
import CmuxIrohTransport
|
||||
import Foundation
|
||||
@preconcurrency import Network
|
||||
import Testing
|
||||
|
||||
+2
-2
@@ -4,8 +4,8 @@
|
||||
"agent-session-web:test": "bun test webviews/src/agent-session/shared/*.test.ts",
|
||||
"biome:check": "biome check .",
|
||||
"feed-tui": "bun Resources/feed-tui/index.ts",
|
||||
"iroh:relay-catalog:check": "bun scripts/generate-managed-iroh-relay-catalog.ts --check",
|
||||
"iroh:relay-catalog:generate": "bun scripts/generate-managed-iroh-relay-catalog.ts"
|
||||
"iroh:relay-catalog:check": "bun web/tools/generate-managed-iroh-relay-catalog.ts --check",
|
||||
"iroh:relay-catalog:generate": "bun web/tools/generate-managed-iroh-relay-catalog.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@opentui/core": "^0.1.106",
|
||||
|
||||
+2
-2
@@ -5,8 +5,8 @@
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "exec bash scripts/dev-local.sh",
|
||||
"build": "bun ../scripts/generate-managed-iroh-relay-catalog.ts --check && next build && bun tools/build-docs-search.mjs",
|
||||
"vercel-build": "bun ../scripts/generate-managed-iroh-relay-catalog.ts --check && VERCEL_PREVIEW_COMMENTS_ENABLED=0 next build && bun tools/build-docs-search.mjs",
|
||||
"build": "bun tools/generate-managed-iroh-relay-catalog.ts --check && next build && bun tools/build-docs-search.mjs",
|
||||
"vercel-build": "bun tools/generate-managed-iroh-relay-catalog.ts --check && VERCEL_PREVIEW_COMMENTS_ENABLED=0 next build && bun tools/build-docs-search.mjs",
|
||||
"search:index": "bun tools/build-docs-search.mjs",
|
||||
"cloud-vm:env:audit": "bun scripts/cloud-vm/audit-vercel-env.mjs",
|
||||
"cloud-vm:migrate": "bun scripts/cloud-vm/migrate-vercel-aurora-iam.mjs",
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* Fleet rotations are add-before-remove. Bump sequence and add first, deploy
|
||||
* both server consumers, wait one signed-policy lifetime, then bump sequence
|
||||
* again and remove. Run scripts/generate-managed-iroh-relay-catalog.ts after
|
||||
* again and remove. Run web/tools/generate-managed-iroh-relay-catalog.ts after
|
||||
* every edit. Signing keys and relay credentials never belong in this file.
|
||||
*/
|
||||
export const MANAGED_IROH_RELAY_CATALOG = {
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import { expect, test } from "bun:test";
|
||||
import { existsSync } from "node:fs";
|
||||
import { dirname, resolve, sep } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
import packageJSON from "../package.json";
|
||||
|
||||
test("keeps relay catalog validation inside the Vercel project", () => {
|
||||
const webRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
||||
const buildCommand = packageJSON.scripts["vercel-build"];
|
||||
const scriptPath = buildCommand.match(
|
||||
/bun\s+(\S*generate-managed-iroh-relay-catalog\.ts)\s+--check/,
|
||||
)?.[1];
|
||||
|
||||
expect(scriptPath).toBeDefined();
|
||||
const resolvedScript = resolve(webRoot, scriptPath!);
|
||||
expect(resolvedScript.startsWith(`${webRoot}${sep}`)).toBe(true);
|
||||
expect(existsSync(resolvedScript)).toBe(true);
|
||||
});
|
||||
+7
-7
@@ -1,4 +1,4 @@
|
||||
import { mkdir } from "node:fs/promises";
|
||||
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
||||
import { dirname, resolve } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
@@ -15,7 +15,7 @@ type Catalog = {
|
||||
readonly relays: readonly Relay[];
|
||||
};
|
||||
|
||||
const repositoryRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
||||
const repositoryRoot = resolve(dirname(fileURLToPath(import.meta.url)), "../..");
|
||||
const sourcePath = resolve(repositoryRoot, "config/iroh/managed-relay-catalog.json");
|
||||
const outputPaths = [
|
||||
resolve(repositoryRoot, "web/services/relay/generated/managedRelayCatalog.ts"),
|
||||
@@ -86,7 +86,7 @@ function generatedSource(catalog: Catalog): string {
|
||||
*
|
||||
* Fleet rotations are add-before-remove. Bump sequence and add first, deploy
|
||||
* both server consumers, wait one signed-policy lifetime, then bump sequence
|
||||
* again and remove. Run scripts/generate-managed-iroh-relay-catalog.ts after
|
||||
* again and remove. Run web/tools/generate-managed-iroh-relay-catalog.ts after
|
||||
* every edit. Signing keys and relay credentials never belong in this file.
|
||||
*/
|
||||
export const MANAGED_IROH_RELAY_CATALOG = ${JSON.stringify(catalog, null, 2)} as const;
|
||||
@@ -98,14 +98,14 @@ export const MANAGED_IROH_RELAY_URLS = MANAGED_IROH_RELAY_CATALOG.relays.map(
|
||||
`;
|
||||
}
|
||||
|
||||
const catalog = validatedCatalog(await Bun.file(sourcePath).json());
|
||||
const catalog = validatedCatalog(JSON.parse(await readFile(sourcePath, "utf8")));
|
||||
const expected = generatedSource(catalog);
|
||||
const checkOnly = Bun.argv.includes("--check");
|
||||
const checkOnly = process.argv.includes("--check");
|
||||
let drifted = false;
|
||||
|
||||
for (const outputPath of outputPaths) {
|
||||
if (checkOnly) {
|
||||
const current = await Bun.file(outputPath).text().catch(() => "");
|
||||
const current = await readFile(outputPath, "utf8").catch(() => "");
|
||||
if (current !== expected) {
|
||||
console.error(`generated managed relay catalog is stale: ${outputPath}`);
|
||||
drifted = true;
|
||||
@@ -113,7 +113,7 @@ for (const outputPath of outputPaths) {
|
||||
continue;
|
||||
}
|
||||
await mkdir(dirname(outputPath), { recursive: true });
|
||||
await Bun.write(outputPath, expected);
|
||||
await writeFile(outputPath, expected, "utf8");
|
||||
console.log(`generated ${outputPath}`);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
"deploy": "wrangler deploy",
|
||||
"test": "bun test",
|
||||
"typecheck": "tsgo --noEmit && tsgo --noEmit -p tsconfig.test.json",
|
||||
"relay-catalog:check": "bun ../../scripts/generate-managed-iroh-relay-catalog.ts --check",
|
||||
"relay-catalog:check": "bun ../../web/tools/generate-managed-iroh-relay-catalog.ts --check",
|
||||
"check": "bun run relay-catalog:check && bun run typecheck && bun test && wrangler deploy --dry-run --outdir dist"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* Fleet rotations are add-before-remove. Bump sequence and add first, deploy
|
||||
* both server consumers, wait one signed-policy lifetime, then bump sequence
|
||||
* again and remove. Run scripts/generate-managed-iroh-relay-catalog.ts after
|
||||
* again and remove. Run web/tools/generate-managed-iroh-relay-catalog.ts after
|
||||
* every edit. Signing keys and relay credentials never belong in this file.
|
||||
*/
|
||||
export const MANAGED_IROH_RELAY_CATALOG = {
|
||||
|
||||
Reference in New Issue
Block a user