Build and publish Eldorado documentation / build (pull_request) Successful in 30s
83 lines
4.8 KiB
JavaScript
83 lines
4.8 KiB
JavaScript
import {test} from 'node:test';
|
|
import {createHash} from 'node:crypto';
|
|
import assert from 'node:assert/strict';
|
|
import {readFileSync, existsSync, mkdtempSync, mkdirSync, writeFileSync, symlinkSync, unlinkSync, rmSync, readdirSync} from 'node:fs';
|
|
import {tmpdir} from 'node:os';
|
|
import {join, resolve} from 'node:path';
|
|
import {spawnSync} from 'node:child_process';
|
|
const read = p => readFileSync(p, 'utf8');
|
|
test('real build removes stale diagrams, keeps receipts private and rejects collisions', () => {
|
|
const root = mkdtempSync(join(tmpdir(), 'eldorado-diagrams-'));
|
|
try {
|
|
mkdirSync(join(root,'diagrams'));
|
|
symlinkSync(resolve('vendor'),join(root,'vendor'),'dir');
|
|
const spec = JSON.parse(read('diagrams/organization-structure.architecture.json'));
|
|
const writeSpec = name => {
|
|
spec.meta.output = `static/diagrams/${name}/index.html`;
|
|
writeFileSync(join(root,`diagrams/${name}.architecture.json`),JSON.stringify(spec));
|
|
};
|
|
const build = () => spawnSync(process.execPath,[resolve('scripts/build-diagrams.mjs')],{cwd:root,encoding:'utf8'});
|
|
writeSpec('old');
|
|
let result = build(); assert.equal(result.status,0,result.stderr);
|
|
assert(existsSync(join(root,'static/diagrams/old/index.html')));
|
|
assert(!readdirSync(join(root,'static/diagrams'),{recursive:true}).some(p=>p.endsWith('.delivery.json')));
|
|
unlinkSync(join(root,'diagrams/old.architecture.json'));
|
|
writeSpec('new');
|
|
result=build(); assert.equal(result.status,0,result.stderr);
|
|
assert(!existsSync(join(root,'static/diagrams/old')));
|
|
assert(!existsSync(join(root,'static/diagrams/old.json')));
|
|
writeFileSync(join(root,'diagrams/new.workflow.json'),JSON.stringify(spec));
|
|
result=build(); assert.notEqual(result.status,0);
|
|
assert(result.stderr.includes('Duplicate diagram output'));
|
|
} finally {rmSync(root,{recursive:true,force:true});}
|
|
});
|
|
test('vendored source matches the reviewed upstream snapshot', () => {
|
|
const checksums = JSON.parse(read('vendor/archify-checksums.json'));
|
|
for (const [path, hash] of Object.entries(checksums)) {
|
|
assert.equal(createHash('sha256').update(readFileSync(`vendor/archify/${path}`)).digest('hex'), hash, path);
|
|
}
|
|
});
|
|
test('three independent section menus and Structure first', () => {
|
|
const config = read('docusaurus.config.ts');
|
|
for (const section of ['Organization', 'Strategy', 'Contribution']) assert(config.includes(`label: '${section}'`));
|
|
assert(!config.includes("label: 'Documentation'"));
|
|
assert(!config.includes("label: 'Maintainer guide'"));
|
|
assert(read('sidebars/organization.ts').includes("organizationSidebar: ['structure']"));
|
|
for (const section of ['organization','strategy','contribution']) assert(config.includes(`id: '${section}'`));
|
|
});
|
|
test('Archify is pinned, licensed and rebuilt, not a remote embed', () => {
|
|
const provenance = JSON.parse(read('vendor/archify-provenance.json'));
|
|
assert.equal(provenance.commit, 'd5a1333d7447c866a765adac7d4d062f2f02e4d2');
|
|
assert(read('vendor/archify/LICENSE').includes('MIT License'));
|
|
const scripts = JSON.parse(read('package.json')).scripts;
|
|
assert(scripts.build.startsWith('pnpm diagrams:build'));
|
|
const wrapper = read('src/components/ArchifyDiagram/index.tsx');
|
|
assert(wrapper.includes('sandbox="allow-scripts allow-downloads"'));
|
|
assert(!wrapper.includes('allow-same-origin'));
|
|
assert(wrapper.includes('useBaseUrl'));
|
|
assert(wrapper.includes('showModal()') && wrapper.includes('onClose='));
|
|
assert(!wrapper.includes('target="_blank"'));
|
|
assert(wrapper.includes('Close full-screen diagram'));
|
|
});
|
|
test('organization research distinguishes evidence, advertised roles and assumptions', () => {
|
|
const page = read('docs/organization/structure.mdx');
|
|
assert(page.includes('2026-10-02') && page.includes('not a verified employee roster'));
|
|
assert(page.includes('Vladas Jurkevičius') && page.includes('Lukas Deksnys'));
|
|
assert(page.includes('Assumed') && page.includes('Publicly evidenced'));
|
|
assert(!page.includes('Illustrative integration example'));
|
|
const ledger = JSON.parse(read('research/organization/sources.json'));
|
|
const citations = [...page.split('## Sources')[0].matchAll(/\[(\d+)\]/g)].map(m => Number(m[1]));
|
|
assert(citations.length > 10);
|
|
for (const id of citations) assert(ledger.sources.some(s => s.id === id && s.quotes?.length), `Missing evidence ${id}`);
|
|
for (const name of ['organization-structure', 'organization-reporting']) {
|
|
const spec = JSON.parse(read(`diagrams/${name}.architecture.json`));
|
|
const ids = new Set(spec.components.map(n => n.id));
|
|
assert.equal(ids.size, spec.components.length);
|
|
for (const edge of spec.connections) {
|
|
assert(ids.has(edge.from) && ids.has(edge.to));
|
|
assert(edge.label.startsWith('J:') || edge.label.startsWith('A:'));
|
|
if (edge.label.startsWith('A:')) assert.equal(edge.variant, 'dashed');
|
|
}
|
|
}
|
|
});
|