diff --git a/.github/workflows/javascript-build.yml b/.github/workflows/javascript-build.yml index 3c4e9a37..bf2c19b5 100644 --- a/.github/workflows/javascript-build.yml +++ b/.github/workflows/javascript-build.yml @@ -82,12 +82,11 @@ jobs: # checks packed consumers once per compiler (6 and 7), separately from `tooling`; the # public-types check runs once per compiler in `published-artifact` (same build recipe), # which also uploads the report, and `Build` waits for that job. - # `source`, `typescript-consumers`, and `storybook` build `@cratis/components` (and, for + # `source`, `typescript-consumers`, and `storybook-build` build `@cratis/components` (and, for # the latter two, the adapters) before checks that need packed/dist output - mirroring # what `run-task-on-workspaces.js ci` already did per workspace, and what every other job - # in this file already does in its own - # "Build the published artifact" step. Each of the three Storybook shards builds its own - # previews, then runs a deterministic partition of the story, manager, and viewport checks. + # in this file already does in its own "Build the published artifact" step. Storybook shards + # consume the producer's output, then run a deterministic partition of story, manager and viewport checks. source: needs: [changes] if: needs.changes.outputs.relevant == 'true' @@ -393,22 +392,17 @@ jobs: yarn workspace @cratis/components.designsystemet run build yarn verify-typescript-consumers --typescript ${{ matrix.typescript }} --skip-public-types - # The Storybook workspace is `private`, so `run-task-on-workspaces.js ci` always skipped - # it; its checks ran as their own steps at the end of the old `build` job instead, after - # that job's single step had already built `@cratis/components` and every adapter. This - # matrix rebuilds those same packages in each shard (build only, matching - # `typescript-consumers`) so each composed Storybook has the packed output it imports. All stories and auxiliary - # checks run exactly once across the three shards; preflight and index checks run in each. - storybook: + # Build and verify the composed Storybook once; transfer only its static output and prepared + # workspace exports. Consumers still verify indexes/isolation in run-story-matrix.mjs and run + # every story and auxiliary unit exactly once across the unchanged three-shard partition. + storybook-build: needs: [changes] if: needs.changes.outputs.relevant == 'true' - name: Storybook (shard ${{ matrix.shard }}/3) - strategy: - fail-fast: false - matrix: - shard: [1, 2, 3] + name: Build Storybook runs-on: ubuntu-latest timeout-minutes: 25 + permissions: + contents: read steps: - name: Checkout code @@ -467,6 +461,68 @@ jobs: working-directory: Source run: yarn verify-storybook-index + - name: Archive prepared Storybook output + run: | + tar -czf "$RUNNER_TEMP/storybook-build.tar.gz" \ + Source/storybook-static Source/dist Conformance/dist \ + Adapters/Mui/dist Adapters/PrimeReact/dist \ + Adapters/PrimeReact10/dist Adapters/Designsystemet/dist + + - name: Upload prepared Storybook output + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: storybook-build-${{ github.sha }} + path: ${{ runner.temp }}/storybook-build.tar.gz + if-no-files-found: error + compression-level: 0 + retention-days: 1 + + storybook: + needs: [changes, storybook-build] + if: needs.changes.outputs.relevant == 'true' + name: Storybook (shard ${{ matrix.shard }}/3) + strategy: + fail-fast: false + matrix: + shard: [1, 2, 3] + runs-on: ubuntu-latest + timeout-minutes: 25 + permissions: + contents: read + + steps: + - name: Checkout code + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - name: Setup node + uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 + with: + node-version: 24.x + registry-url: 'https://registry.npmjs.org' + + - name: Restore Yarn package cache + id: yarn-cache + uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + with: + path: .yarn/cache + key: ${{ runner.os }}-yarn-cache-v3-${{ hashFiles('yarn.lock', '.yarnrc.yml', '.yarn/releases/yarn-4.17.1.cjs') }} + restore-keys: | + ${{ runner.os }}-yarn-cache-v3- + + - name: Yarn install + run: yarn install --immutable + + - name: Download prepared Storybook output + uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0 + with: + name: storybook-build-${{ github.sha }} + path: ${{ runner.temp }}/storybook-build + + - name: Restore prepared Storybook output + run: tar -xzf "$RUNNER_TEMP/storybook-build/storybook-build.tar.gz" + - name: Cache Playwright browsers uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 with: @@ -561,6 +617,7 @@ jobs: - tooling - typescript-consumers - published-artifact + - storybook-build - storybook - verify-arc-consumers - verify-package-managers diff --git a/README.md b/README.md index 8bbc93db..2a00ee42 100644 --- a/README.md +++ b/README.md @@ -238,10 +238,18 @@ building, and each verification. Locally, export `NODE_OPTIONS="--max-old-space- and time each script in that chain from the repository root with `time yarn workspace @cratis/components run