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
63 changes: 55 additions & 8 deletions .github/workflows/javascript-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ jobs:
if: needs.changes.outputs.relevant == 'true'
runs-on: ubuntu-latest
timeout-minutes: 20
env:
NODE_OPTIONS: "--max-old-space-size=4096"

steps:
- name: Checkout code
Expand All @@ -118,13 +120,45 @@ jobs:
- name: Yarn install
run: yarn install --immutable

- name: Build JS/TS (Source)
run: |
export NODE_OPTIONS="--max-old-space-size=4096"
yarn workspace @cratis/components run ci:static
# Keep this order identical to Source's ci:static script; separate steps expose each phase's duration.
- name: Generate parts
run: yarn workspace @cratis/components run generate-parts

- name: Verify parts manifest
run: yarn workspace @cratis/components run verify-parts-manifest

- name: Verify public API documentation
run: yarn workspace @cratis/components run verify-api-docs

- name: Clean Source output
run: yarn workspace @cratis/components run clean

- name: Lint Source
run: yarn workspace @cratis/components run lint:ci

- name: Build Source
run: yarn workspace @cratis/components run build

- name: Typecheck stories
run: yarn workspace @cratis/components run typecheck-stories

- name: Build published Source artifact
run: yarn workspace @cratis/components run g:build

# Source's ci:static script also checks public API TSDoc, the packed CSS budgets, and that the
# built declarations match the committed api-surface.json snapshot.
- name: Verify renderer contracts
run: yarn workspace @cratis/components run verify-renderer-contracts

- name: Report package graph
run: yarn workspace @cratis/components run verify-package-graph-report

- name: Verify packed CSS
run: yarn workspace @cratis/components run verify-packed-css

- name: Verify source maps
run: yarn workspace @cratis/components run verify-source-maps

- name: Verify API surface
run: yarn workspace @cratis/components run verify-api-surface

# Informational: which exports this change removes, changes, or adds compared with the
# latest published release. Release intent stays with the semver label and the reviewer.
Expand Down Expand Up @@ -409,9 +443,22 @@ jobs:
yarn workspace @cratis/components.primereact10 run build
yarn workspace @cratis/components.designsystemet run build

- name: Verify renderer Storybook type, inventory, specs, and peer isolation
# Keep this order identical to Storybook's ci:preflight script for comparable phase timings.
- name: Verify renderer Storybook inventory
working-directory: Storybook
run: yarn verify-inventory

- name: Typecheck renderer Storybook
working-directory: Storybook
run: yarn typecheck

- name: Test renderer Storybook preflight specs
working-directory: Storybook
run: yarn test

- name: Verify renderer Storybook peer isolation
working-directory: Storybook
run: yarn ci:preflight
run: yarn verify-isolation

- name: Build composed renderer Storybook
run: yarn workspace @cratis/components build-storybook
Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,20 @@ build). CI additionally checks packed exports, public types under TypeScript 6 a
production tree shaking, and external consumer/package-manager matrices; `yarn ci` does not
replace those jobs.

For phase timings in the JavaScript Build workflow, open the `source` job's 13 steps from
"Generate parts" through "Verify API surface". They run the unchanged `Source/package.json`
`ci:static` chain in order, with separate durations for lint, story typechecking, artifact
building, and each verification. Locally, export `NODE_OPTIONS="--max-old-space-size=4096"`
and time each script in that chain from the repository root with
`time yarn workspace @cratis/components run <script>`; do not also run `ci:static` in that sequence.

Each "Storybook (shard N/3)" job exposes the four preflight steps from "Verify renderer
Storybook inventory" through "Verify renderer Storybook peer isolation" before "Build composed
renderer Storybook". After building the packages that Storybook imports, reproduce the preflight
from `Storybook/` with `time yarn verify-inventory`, `time yarn typecheck`, `time yarn test`, and
`time yarn verify-isolation`, in that order. "Install Storybook browser" and "Test assigned
Storybook units" remain separate steps for browser provisioning and story-test timings.

For root and package README changes, verify the exact files explicitly:

```bash
Expand Down
71 changes: 71 additions & 0 deletions scripts/javascript-build-gate.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,77 @@ test('published-artifact runs every packed-artifact check from one build per leg
assert.doesNotMatch(block, /continue-on-error/);
});

const sourceStaticScripts = [
'generate-parts', 'verify-parts-manifest', 'verify-api-docs', 'clean', 'lint:ci', 'build',
'typecheck-stories', 'g:build', 'verify-renderer-contracts', 'verify-package-graph-report',
'verify-packed-css', 'verify-source-maps', 'verify-api-surface',
];
const sourceStaticNames = [
'Generate parts', 'Verify parts manifest', 'Verify public API documentation', 'Clean Source output',
'Lint Source', 'Build Source', 'Typecheck stories', 'Build published Source artifact',
'Verify renderer contracts', 'Report package graph', 'Verify packed CSS', 'Verify source maps',
'Verify API surface',
];
const storybookPreflightScripts = ['verify-inventory', 'typecheck', 'test', 'verify-isolation'];
const storybookPreflightNames = [
'Verify renderer Storybook inventory', 'Typecheck renderer Storybook',
'Test renderer Storybook preflight specs', 'Verify renderer Storybook peer isolation',
];

function workflowSteps(block) {
return [...block.matchAll(/^ - name: (.+)\n([\s\S]*?)(?=^ - name: |$(?![\s\S]))/gm)]
.map(([, name, body]) => ({ name, body }));
}

function assertStepCommands(steps, names, commands) {
assert.deepEqual(steps.map(step => step.name), names);
assert.deepEqual(steps.map(step => step.body.match(/^ run: (.+)$/m)?.[1]), commands);
for (const step of steps) {
assert.doesNotMatch(step.body, /^ (?:if|continue-on-error):/m, step.name);
assert.equal([...step.body.matchAll(/^ run:/gm)].length, 1, step.name);
}
}

test('Source exposes every ci:static phase once in order with the same heap limit', () => {
const steps = workflowSteps(jobs.source);
const install = steps.findIndex(step => step.name === 'Yarn install');
const report = steps.findIndex(step => step.name === 'Report public API changes against the latest release');
assert.ok(install >= 0 && report > install);
assert.equal(report, steps.length - 1);
assert.equal(sourceStaticScripts.length, 13);
assertStepCommands(steps.slice(install + 1, report), sourceStaticNames,
sourceStaticScripts.map(script => `yarn workspace @cratis/components run ${script}`));
assert.match(steps[report].body, /^ run: yarn workspace @cratis\/components run report-api-compatibility$/m);
assert.match(jobs.source, /^ env:\n NODE_OPTIONS: "--max-old-space-size=4096"$/m);
assert.equal(jobs.source.split('NODE_OPTIONS').length - 1, 1);
assert.doesNotMatch(jobs.source, /^ (?:working-directory:|run: .*ci:static)/m);
});

test('the local Source ci:static chain remains identical to the visible CI phases', () => {
const sourcePackage = JSON.parse(readFileSync(new URL('../Source/package.json', import.meta.url), 'utf8'));
assert.equal(sourcePackage.scripts['ci:static'], sourceStaticScripts.map(script => `yarn ${script}`).join(' && '));
});

test('Storybook exposes each preflight phase once before the composed build', () => {
const steps = workflowSteps(jobs.storybook);
const packages = steps.findIndex(step => step.name === 'Build packages the composed Storybook imports');
const build = steps.findIndex(step => step.name === 'Build composed renderer Storybook');
assert.ok(packages >= 0 && build > packages);
const preflight = steps.slice(packages + 1, build);
assert.equal(storybookPreflightScripts.length, 4);
assertStepCommands(preflight, storybookPreflightNames, storybookPreflightScripts.map(script => `yarn ${script}`));
for (const step of preflight) {
assert.match(step.body, /^ working-directory: Storybook$/m, step.name);
}
assert.doesNotMatch(jobs.storybook, /^ run: .*ci:preflight/m);
});

test('the local Storybook preflight chain remains identical to the visible CI phases', () => {
const storybookPackage = JSON.parse(readFileSync(new URL('../Storybook/package.json', import.meta.url), 'utf8'));
assert.equal(storybookPackage.scripts['ci:preflight'],
storybookPreflightScripts.map(script => `yarn ${script}`).join(' && '));
});

test('the Yarn package cache is restore-only with exactly one saver', () => {
const restore = 'uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9';
const key = "key: ${{ runner.os }}-yarn-cache-v3-${{ hashFiles('yarn.lock', '.yarnrc.yml', '.yarn/releases/yarn-4.17.1.cjs') }}";
Expand Down
Loading