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
42 changes: 16 additions & 26 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,21 @@ permissions:
contents: read
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm typecheck
- run: pnpm test
- run: pnpm build
- run: pnpm build:cli
uses: Grindstone-Systems/.github/.github/workflows/check.yml@main
with:
run: |
pnpm typecheck
pnpm test
pnpm build
pnpm build:cli
privacy:
# Plan acceptance: nothing leaves the origin, and processing and exports work offline.
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm build
- run: pnpm privacy:check
env:
CHROME_PATH: /usr/bin/google-chrome
uses: Grindstone-Systems/.github/.github/workflows/check.yml@main
with:
chrome: true
run: |
pnpm build
pnpm privacy:check
oic-profile:
# The listing, checked with OIC's own importer and Charter preflight.
uses: Grindstone-Systems/.github/.github/workflows/oic-profile.yml@main
32 changes: 5 additions & 27 deletions .github/workflows/deploy-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,8 @@ concurrency:
group: pages
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm test
# Served from https://<org>.github.io/<repo>/ unless a custom domain is set.
- run: pnpm build
env:
BASE: ${{ vars.PAGES_BASE || format('/{0}/', github.event.repository.name) }}
- uses: actions/upload-pages-artifact@v3
with:
path: dist
deploy:
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- id: deployment
uses: actions/deploy-pages@v4
pages:
uses: Grindstone-Systems/.github/.github/workflows/pages.yml@main
with:
test: pnpm test
build: pnpm build
4 changes: 2 additions & 2 deletions docs/OIC_LISTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ Documentation Toolkit is listed the same way as Visual Toolkit: the profile live
```bash
pnpm oic:media # regenerate the screenshots and logo (starts Vite, drives your Chrome)
pnpm oic:media evidence # or only shots whose name matches
pnpm oic:check # validate the profile against the catalog schema and the image limits
pnpm oic:check # check the profile with OIC's importer and Charter preflight
```

`oic:check` reads the schema from a sibling checkout of the website repo (`../open-industrial-collective/website/src/project-v2.schema.json`); set `OIC_SCHEMA` to use another path.
`oic:check` runs OIC's own profile check, the importer and Charter preflight a reviewer runs, from a cached clone of the public website repo (or the checkout in `OIC_WEBSITE`). `pnpm oic:check --ref HEAD` checks exactly what OIC would import, and its digest matches the reviewer's `fetch`. CI runs the same check through the `open-industrial-collective/website/profile-check` Action. A clean check is not an approval.

Keep claims accurate:
- Screenshots use the synthetic Riverbend sample. Say so; never use a customer's project.
Expand Down
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,12 @@
"@types/react": "^19.2.0",
"@types/react-dom": "^19.2.0",
"@vitejs/plugin-react": "^6.1.1",
"ajv": "^8.20.0",
"esbuild": "^0.25.10",
"puppeteer-core": "^25.12.0",
"tsx": "^4.20.0",
"typescript": "^5.9.3",
"vite": "^8.3.1",
"vitest": "^3.2.4",
"yaml": "^2.9.1"
"vitest": "^3.2.4"
},
"pnpm": {
"onlyBuiltDependencies": [
Expand Down
40 changes: 2 additions & 38 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

71 changes: 30 additions & 41 deletions scripts/oic-check.ts
Original file line number Diff line number Diff line change
@@ -1,53 +1,42 @@
/**
* Check the OIC listing before pushing: the profile against the catalog's v2
* schema, and every image against the catalog limits.
* Check the OIC listing with OIC's own importer and Charter preflight, the
* same code review runs (`profile:check` in open-industrial-collective/website).
*
* pnpm oic:check
* pnpm oic:check # the working tree; flags files not committed yet
* pnpm oic:check --ref HEAD # exactly what OIC would import from that commit
*
* The schema lives in the OIC website repo; point OIC_SCHEMA at a checkout's
* src/project-v2.schema.json if it isn't in the default sibling location.
* Uses the website checkout in OIC_WEBSITE if set, otherwise a cached shallow
* clone of the public website repo under node_modules/.cache. CI runs the same
* check through the profile-check Action.
*/
import { existsSync, readFileSync, statSync } from "node:fs";
import { execFileSync, spawnSync } from "node:child_process";
import { createHash } from "node:crypto";
import { existsSync, readFileSync, writeFileSync } from "node:fs";
import { fileURLToPath } from "node:url";
import Ajv from "ajv";
import { parse } from "yaml";
import { imageSize } from "../lib/render/image.ts";

const root = fileURLToPath(new URL("../.oic/", import.meta.url));
const schemaPath = process.env.OIC_SCHEMA ?? fileURLToPath(new URL("../../open-industrial-collective/website/src/project-v2.schema.json", import.meta.url));
const problems: string[] = [];
const repo = fileURLToPath(new URL("..", import.meta.url));
const run = (cmd: string, args: string[], cwd: string) => execFileSync(cmd, args, { cwd, stdio: ["ignore", "ignore", "inherit"] });

const profile = parse(readFileSync(`${root}project.yaml`, "utf8")) as { description?: { file?: string }; branding?: { logo?: Record<string, string> }; media?: { src?: string }[] };

if (existsSync(schemaPath)) {
const ajv = new Ajv({ allErrors: true, strict: false });
ajv.addFormat("https-url", /^https:\/\/[^\s/@:]+(?::[0-9]+)?(?:[/?#][^\s]*)?$/);
const validate = ajv.compile(JSON.parse(readFileSync(schemaPath, "utf8")));
if (!validate(profile)) for (const e of validate.errors ?? []) problems.push(`profile ${e.instancePath || "/"} ${e.message}`);
} else {
console.warn(`! Schema not found at ${schemaPath}; set OIC_SCHEMA to validate the profile.`);
}

const overview = profile.description?.file;
if (overview && statSync(`${root}${overview}`).size > 20 * 1024) problems.push(`${overview} is over 20 KB`);

const images = [profile.branding?.logo?.on_light, profile.branding?.logo?.on_dark, ...(profile.media ?? []).map((m) => m.src)].filter(Boolean) as string[];
for (const src of new Set(images)) {
const path = `${root}${src}`;
if (!existsSync(path)) {
problems.push(`${src} is missing`);
continue;
let website = process.env.OIC_WEBSITE;
if (!website) {
website = fileURLToPath(new URL("../node_modules/.cache/oic-website", import.meta.url));
if (!existsSync(`${website}/.git`)) run("git", ["clone", "-q", "--depth", "1", "https://github.com/open-industrial-collective/website.git", website], repo);
else {
run("git", ["fetch", "-q", "--depth", "1", "origin", "main"], website);
run("git", ["reset", "-q", "--hard", "FETCH_HEAD"], website);
}
// Install the importer's dependencies only when its lockfile changes.
const lock = createHash("sha256").update(readFileSync(`${website}/package-lock.json`)).digest("hex");
const stamp = `${website}/node_modules/.lock-hash`;
if (!existsSync(stamp) || readFileSync(stamp, "utf8") !== lock) {
run("npm", ["ci", "--no-audit", "--no-fund", "--ignore-scripts"], website);
writeFileSync(stamp, lock);
}
const bytes = new Uint8Array(readFileSync(path));
const size = imageSize(bytes);
if (bytes.length > 2 * 1024 * 1024) problems.push(`${src} is over 2 MB`);
if (!size) problems.push(`${src} isn't a PNG, JPEG or WebP`);
else if (size.width * size.height > 12_000_000) problems.push(`${src} is over 12 MP (${size.width}×${size.height})`);
}
if ((profile.media ?? []).length > 8) problems.push("more than 8 media items");

if (problems.length) {
console.error(`✗ OIC listing problems:\n${problems.map((p) => ` - ${p}`).join("\n")}`);
if (!existsSync(`${website}/scripts/check-profile.ts`)) {
console.error(`✗ ${website} has no profile check (scripts/check-profile.ts). Update that checkout, or point OIC_WEBSITE at one that has it.`);
process.exit(1);
}
console.log(`✓ OIC profile valid; ${new Set(images).size} images within limits.`);
const r = spawnSync("npm", ["run", "-s", "profile:check", "--", repo, ...process.argv.slice(2)], { cwd: website, stdio: "inherit" });
process.exit(r.status ?? 1);
Loading