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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"scripts": {
"toolchain:check": "node scripts/check-node-toolchain.mjs",
"install:all": "npm ci --prefix backend && npm ci --prefix frontend && npm ci --prefix website",
"install:all": "node scripts/install-all.mjs",
"test": "npm run test:workflow-sources && npm run test:public-content && npm run test:release-manifest && npm run test:operations && npm run test:evaluation && npm run test:final && npm run test:baseline && npm run test:chat --prefix backend && npm run test:legal-sources --prefix backend && npm run test:security --prefix backend",
"test:evaluation": "node --test tests/evaluation/*.test.mjs && node scripts/evaluate-ontario.mjs --check && node scripts/check-professional-validation.mjs && node scripts/check-release-readiness.mjs",
"evaluate:ontario": "node scripts/evaluate-ontario.mjs",
Expand Down
55 changes: 55 additions & 0 deletions scripts/install-all.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { spawnSync } from "node:child_process";
import { rmSync } from "node:fs";

const workspaces = ["backend", "frontend", "website"];
const maxAttempts = 3;
const npmCommand = process.platform === "win32" ? "npm.cmd" : "npm";

const pause = (milliseconds) =>
new Promise((resolve) => setTimeout(resolve, milliseconds));

for (const workspace of workspaces) {
let installed = false;
let lastStatus = 1;

for (let attempt = 1; attempt <= maxAttempts; attempt += 1) {
console.log(
`Installing ${workspace} dependencies (attempt ${attempt}/${maxAttempts})...`,
);

const result = spawnSync(npmCommand, ["ci", "--prefix", workspace], {
env: process.env,
stdio: "inherit",
});

if (result.error) {
console.error(`Failed to start npm for ${workspace}:`, result.error);
}

lastStatus = result.status ?? 1;
if (lastStatus === 0) {
installed = true;
break;
}

if (attempt < maxAttempts) {
console.warn(
`${workspace} dependency installation failed; cleaning node_modules before retry.`,
);
rmSync(`${workspace}/node_modules`, {
force: true,
maxRetries: 3,
recursive: true,
retryDelay: 250,
});
await pause(attempt * 2_000);
}
}

if (!installed) {
console.error(
`${workspace} dependency installation failed after ${maxAttempts} attempts.`,
);
process.exit(lastStatus);
}
}
7 changes: 5 additions & 2 deletions tests/baseline/ross-website-contract.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@ const json = (path) => JSON.parse(read(path));
test("the public website is a separate build target", () => {
const rootPackage = json("package.json");
const websitePackage = json("website/package.json");
const installer = read("scripts/install-all.mjs");
assert.equal(existsSync(resolve(root, "website/.openai/hosting.json")), true);
assert.equal(
existsSync(resolve(root, "website/build/sites-vite-plugin.ts")),
true,
);
assert.equal(websitePackage.name, "ross-ontario");
assert.match(rootPackage.scripts["install:all"], /--prefix website/);
assert.match(rootPackage.scripts["install:all"], /scripts\/install-all\.mjs/);
assert.match(installer, /\["backend", "frontend", "website"\]/);
assert.match(installer, /\["ci", "--prefix", workspace\]/);
assert.match(rootPackage.scripts.build, /build:website/);
assert.match(rootPackage.scripts.lint, /lint:website/);
assert.match(rootPackage.scripts.check, /test:website/);
Expand Down Expand Up @@ -87,7 +90,7 @@ test("the website scaffold exposes every governed public route", () => {
"readiness",
];
for (const key of requiredKeys) {
assert.match(content, new RegExp(`[\"']?${key}[\"']?\\s*:`), key);
assert.match(content, new RegExp(`["']?${key}["']?\\s*:`), key);
}

const route = read("website/app/[...slug]/page.tsx");
Expand Down