From 1c003efb39eb65fc3010a30cae5979a2908e9111 Mon Sep 17 00:00:00 2001 From: IEvangelist <7679720+IEvangelist@users.noreply.github.com> Date: Mon, 2 Nov 2026 12:37:34 -0600 Subject: [PATCH 1/3] Add controlled Bun runtime and CI artifact performance experiments Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .../frontend-runtime-experiments.yml | 251 ++++++++++++++++++ src/frontend/config/build-timing.mjs | 1 + .../scripts/benchmark-test-runtimes.mjs | 98 +++++++ .../unit/build-performance.vitest.test.ts | 16 ++ 4 files changed, 366 insertions(+) create mode 100644 .github/workflows/frontend-runtime-experiments.yml create mode 100644 src/frontend/scripts/benchmark-test-runtimes.mjs diff --git a/.github/workflows/frontend-runtime-experiments.yml b/.github/workflows/frontend-runtime-experiments.yml new file mode 100644 index 0000000000..86f56429f2 --- /dev/null +++ b/.github/workflows/frontend-runtime-experiments.yml @@ -0,0 +1,251 @@ +name: Frontend runtime experiments + +on: + pull_request: + paths: + - .github/workflows/frontend-runtime-experiments.yml + - src/frontend/scripts/benchmark-test-runtimes.mjs + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: frontend-runtime-experiments-${{ github.event.pull_request.number || github.run_id }} + cancel-in-progress: true + +jobs: + tests: + name: Compare test runtimes + runs-on: ubuntu-latest + timeout-minutes: 15 + defaults: + run: + working-directory: src/frontend + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 + with: + bun-version-file: src/frontend/package.json + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + with: + node-version: 24.x + - run: bun install --frozen-lockfile + - name: Prepare generated types + env: + ASTRO_TELEMETRY_DISABLED: 1 + run: | + bun run git-env + bunx astro sync + - name: Compare identical suites + env: + BENCHMARK_OUT: ${{ runner.temp }}/test-runtimes + run: | + bun --version + node scripts/benchmark-test-runtimes.mjs + - name: Upload runtime results and failure logs + if: ${{ always() }} + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: test-runtime-experiment + path: ${{ runner.temp }}/test-runtimes + retention-days: 7 + + installs: + name: Compare installation layouts + runs-on: ubuntu-latest + timeout-minutes: 10 + defaults: + run: + working-directory: src/frontend + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 + with: + bun-version-file: src/frontend/package.json + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + with: + node-version: 24.x + - name: Benchmark cold and warm linking without touching shared caches + env: + BUN_INSTALL_CACHE_DIR: ${{ runner.temp }}/bun-install-experiment + ASTRO_TELEMETRY_DISABLED: 1 + run: | + set -euo pipefail + mkdir -p "$RUNNER_TEMP/install-results" + for layout in hoisted isolated global; do + linker="$layout" + global_store=0 + if [[ "$layout" == global ]]; then + linker=isolated + global_store=1 + fi + for round in 0 1 2; do + # Only remove this job's generated dependency directory, never the shared Bun cache. + rm -rf node_modules + BUN_INSTALL_GLOBAL_STORE="$global_store" /usr/bin/time -v \ + bun install --frozen-lockfile --linker "$linker" \ + > "$RUNNER_TEMP/install-results/$layout-$round.log" 2>&1 + done + bun run git-env + bunx astro sync > "$RUNNER_TEMP/install-results/$layout-sync.log" 2>&1 + bun run test:unit:contracts > "$RUNNER_TEMP/install-results/$layout-contracts.log" 2>&1 + du -sh node_modules >> "$RUNNER_TEMP/install-results/$layout-size.log" + done + git diff --exit-code -- bun.lock package.json bunfig.toml patches + - name: Upload install timings and compatibility results + if: ${{ always() }} + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: install-layout-experiment + path: ${{ runner.temp }}/install-results + retention-days: 7 + + artifact: + name: Measure whole-site archive + runs-on: ubuntu-latest + timeout-minutes: 15 + permissions: + actions: read + contents: read + steps: + - name: Select successful main artifact + env: + GH_TOKEN: ${{ github.token }} + GH_REPO: ${{ github.repository }} + run: | + set -euo pipefail + run_id=$(gh run list --workflow ci.yml --branch main --status success --limit 1 --json databaseId --jq '.[0].databaseId') + test -n "$run_id" + echo "BASELINE_RUN=$run_id" >> "$GITHUB_ENV" + echo "### Artifact input: main CI run $run_id" >> "$GITHUB_STEP_SUMMARY" + - name: Download unchanged production output + env: + GH_TOKEN: ${{ github.token }} + GH_REPO: ${{ github.repository }} + run: gh run download "$BASELINE_RUN" --name frontend-dist --dir dist + - name: Measure cross-file compression and lossless extraction + run: | + set -euo pipefail + /usr/bin/time -v -o archive-time.txt tar -I 'zstd -T2 -3' -cf frontend-dist.tar.zst -C dist . + mkdir extracted + /usr/bin/time -v -o extract-time.txt tar --zstd -xf frontend-dist.tar.zst -C extracted + diff -qr dist extracted + du -sb dist frontend-dist.tar.zst > sizes.txt + { + echo '### Lossless tar + zstd artifact experiment' + echo 'Full production output; no route, asset, or test coverage removed.' + echo '```' + cat sizes.txt + grep 'Elapsed\|Maximum resident' archive-time.txt extract-time.txt + echo '```' + } >> "$GITHUB_STEP_SUMMARY" + - name: Upload precompressed site + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: frontend-archive-experiment + path: frontend-dist.tar.zst + compression-level: 0 + retention-days: 1 + - name: Upload archive measurements + if: ${{ always() }} + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: archive-experiment-metrics + path: | + sizes.txt + archive-time.txt + extract-time.txt + retention-days: 7 + + artifact-download: + name: Measure archive download and extraction + needs: artifact + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 + with: + name: frontend-archive-experiment + - name: Extract full site + run: | + mkdir dist + /usr/bin/time -v tar --zstd -xf frontend-dist.tar.zst -C dist + test -f dist/index.html + + build: + name: Profile Bun build (transpiler cache ${{ matrix.cache }}) + runs-on: ${{ github.repository_owner == 'microsoft' && '8-core-ubuntu-latest' || 'ubuntu-latest' }} + timeout-minutes: 20 + strategy: + fail-fast: false + matrix: + cache: [disabled, enabled] + defaults: + run: + working-directory: src/frontend + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + fetch-depth: 0 + persist-credentials: false + - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 + with: + bun-version-file: src/frontend/package.json + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + with: + node-version: 24.x + - run: bun install --frozen-lockfile + - name: Restore same Astro state as the control build + uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + with: + path: src/frontend/node_modules/.astro + key: astro-build-${{ runner.os }}-${{ hashFiles('src/frontend/bun.lock', 'src/frontend/astro.config.mjs', 'src/frontend/patches/*.patch') }}-${{ github.sha }} + restore-keys: | + astro-build-${{ runner.os }}-${{ hashFiles('src/frontend/bun.lock', 'src/frontend/astro.config.mjs', 'src/frontend/patches/*.patch') }}- + - name: Restore Bun transpiler cache + id: transpiler + if: ${{ matrix.cache == 'enabled' }} + uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + with: + path: ${{ runner.temp }}/bun-transpiler + key: bun-transpiler-experiment-${{ runner.os }}-${{ hashFiles('src/frontend/package.json', 'src/frontend/bun.lock') }}-${{ github.sha }} + restore-keys: | + bun-transpiler-experiment-${{ runner.os }}-${{ hashFiles('src/frontend/package.json', 'src/frontend/bun.lock') }}- + - name: Profile production build on Bun, not Node + env: + ASTRO_TELEMETRY_DISABLED: 1 + NODE_OPTIONS: --max-old-space-size=8192 + BUILD_TIMING: 1 + BUILD_TIMING_OUT: ${{ runner.temp }}/build-profile/timing.jsonl + BUILD_TIMING_LABEL: ${{ matrix.cache }} + BUILD_METRICS_DIR: ${{ runner.temp }}/build-profile + BUN_RUNTIME_TRANSPILER_CACHE_PATH: ${{ matrix.cache == 'enabled' && format('{0}/bun-transpiler', runner.temp) || '0' }} + run: | + set -euo pipefail + mkdir -p "$RUNNER_TEMP/build-profile" + bun run git-env + bun run compute-skill-digests + /usr/bin/time -v -o "$RUNNER_TEMP/build-profile/resources.txt" \ + bun --cpu-prof --cpu-prof-dir="$RUNNER_TEMP/build-profile" \ + ./node_modules/astro/bin/astro.mjs build --mode production \ + 2>&1 | tee "$RUNNER_TEMP/build-profile/build.log" + node scripts/measure-build-output.mjs + git diff --exit-code + - name: Save experiment-only transpiler cache + if: ${{ matrix.cache == 'enabled' && steps.transpiler.outputs.cache-hit != 'true' }} + uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + with: + path: ${{ runner.temp }}/bun-transpiler + key: ${{ steps.transpiler.outputs.cache-primary-key }} + - name: Upload Bun profiles and output inventories + if: ${{ always() }} + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: bun-build-profile-${{ matrix.cache }} + path: ${{ runner.temp }}/build-profile + retention-days: 7 diff --git a/src/frontend/config/build-timing.mjs b/src/frontend/config/build-timing.mjs index 64648882de..0b94d25d6c 100644 --- a/src/frontend/config/build-timing.mjs +++ b/src/frontend/config/build-timing.mjs @@ -76,6 +76,7 @@ export default function buildTiming() { /** @type {Record} */ const meta = { nodeVersion: process.version, + bunVersion: process.versions.bun ?? null, platform: process.platform, arch: process.arch, cpuCount: undefined, diff --git a/src/frontend/scripts/benchmark-test-runtimes.mjs b/src/frontend/scripts/benchmark-test-runtimes.mjs new file mode 100644 index 0000000000..5a2b112ac7 --- /dev/null +++ b/src/frontend/scripts/benchmark-test-runtimes.mjs @@ -0,0 +1,98 @@ +import { spawn } from 'node:child_process'; +import { createHash } from 'node:crypto'; +import { appendFile, mkdir, readFile, writeFile } from 'node:fs/promises'; +import { join, resolve } from 'node:path'; + +const output = resolve(process.env.BENCHMARK_OUT ?? '.runtime-benchmark'); +await mkdir(output, { recursive: true }); + +async function run(name, executable, args, round) { + const start = performance.now(); + const child = spawn(executable, args, { + env: { ...process.env, ASTRO_TELEMETRY_DISABLED: '1', NO_COLOR: '1' }, + stdio: ['ignore', 'pipe', 'pipe'], + }); + let log = ''; + child.stdout.on('data', (data) => { log += data; }); + child.stderr.on('data', (data) => { log += data; }); + const code = await new Promise((accept, reject) => { + child.once('error', reject); + child.once('close', accept); + }); + const result = { name, round, code, milliseconds: performance.now() - start }; + await writeFile(join(output, `${name}-${round}.log`), log); + console.log(JSON.stringify(result)); + return result; +} + +const results = []; +const vitest = './node_modules/vitest/vitest.mjs'; +const selected = [ + 'tests/unit/locale-routes.vitest.test.ts', + 'tests/unit/browser-storage.vitest.test.ts', +]; +let baseline; +let baselineFailed = false; +for (let round = 0; round < 4; round++) { + // Alternate order; don't mix the warmup or CPU-profiled run into warm timings. + const runtimes = round % 2 ? ['bun', 'node'] : ['node', 'bun']; + for (const runtime of runtimes) { + const report = join(output, `${runtime}-vitest-${round}.json`); + const result = await run(`${runtime}-vitest`, runtime, [ + ...(round === 3 ? ['--cpu-prof', `--cpu-prof-dir=${output}`] : []), + vitest, 'run', '--config', 'vitest.config.ts', '--reporter=json', `--outputFile=${report}`, + ], round); + if (result.code === 0) { + const json = JSON.parse(await readFile(report, 'utf8')); + result.counts = { + tests: json.numTotalTests, + passed: json.numPassedTests, + pending: json.numPendingTests, + failed: json.numFailedTests, + }; + result.tests = json.testResults.flatMap((file) => + file.assertionResults.map((test) => [file.name, test.fullName, test.status]) + ).sort((a, b) => JSON.stringify(a).localeCompare(JSON.stringify(b))); + if (runtime === 'node') { + baseline ??= result; + if (JSON.stringify(result.tests) !== JSON.stringify(baseline.tests)) baselineFailed = true; + } else { + result.matchesNode = baseline !== undefined && + JSON.stringify(result.tests) === JSON.stringify(baseline.tests); + } + } else if (runtime === 'node') baselineFailed = true; + results.push(result); + } +} + +// Probe both mock/global restoration and plain TS. This is not a full-suite migration. +for (const runtime of ['node', 'bun']) { + const result = await run(`${runtime}-subset`, runtime, runtime === 'node' + ? [vitest, 'run', '--config', 'vitest.config.ts', ...selected] + : ['test', ...selected, '--timeout', '30000'], 0); + if (runtime === 'node' && result.code !== 0) baselineFailed = true; + results.push(result); +} + +const summary = { + commit: process.env.GITHUB_SHA, + lockfileSha256: createHash('sha256').update(await readFile('bun.lock')).digest('hex'), + node: process.version, + results, +}; +await writeFile(join(output, 'results.json'), JSON.stringify(summary, null, 2)); +if (process.env.GITHUB_STEP_SUMMARY) { + await appendFile(process.env.GITHUB_STEP_SUMMARY, [ + '## Test runtime experiment', + '', + 'Same checkout, lockfile, Vitest config and thread pool. Round 0 is warmup; round 3 is CPU-profiled.', + 'Native Bun is a compatibility probe only, not a replacement correctness gate.', + '', + '| Variant | Round | Exit | Seconds | Same test identities/statuses as Node |', + '| --- | --- | --- | --- | --- |', + ...results.map((r) => + `| ${r.name} | ${r.round} | ${r.code} | ${(r.milliseconds / 1000).toFixed(2)} | ${r.matchesNode ?? '-'} |`), + '', + ].join('\n')); +} +if (baselineFailed || !baseline) throw new Error('Node control failed or changed test identities; do not interpret timings.'); diff --git a/src/frontend/tests/unit/build-performance.vitest.test.ts b/src/frontend/tests/unit/build-performance.vitest.test.ts index 925cc657d6..f2f96017de 100644 --- a/src/frontend/tests/unit/build-performance.vitest.test.ts +++ b/src/frontend/tests/unit/build-performance.vitest.test.ts @@ -118,6 +118,22 @@ test('all frontend workflow checkouts disable persisted credentials', async () = } }); +test('runtime experiments preserve existing gates and profile the actual Bun runtime', async () => { + const workflow = (await readFile(new URL('../../../../.github/workflows/frontend-runtime-experiments.yml', import.meta.url), 'utf8')).replace(/\r\n/g, '\n'); + const benchmark = await readFile(new URL('../../scripts/benchmark-test-runtimes.mjs', import.meta.url), 'utf8'); + expect(workflow).not.toContain('pull_request_target'); + expect(workflow).not.toContain('continue-on-error'); + expect(workflow).not.toContain('secrets.'); + expect(workflow).toContain('bun --cpu-prof --cpu-prof-dir='); + expect(workflow).toContain('cache: [disabled, enabled]'); + expect(workflow).toContain('diff -qr dist extracted'); + expect(workflow).toContain('git diff --exit-code -- bun.lock package.json bunfig.toml patches'); + expect(benchmark).toContain("['node', 'bun']"); + expect(benchmark).toContain("'--config', 'vitest.config.ts'"); + expect(benchmark).toContain('test.fullName, test.status'); + expect(benchmark).toContain("throw new Error('Node control failed"); +}); + test('timing reports distinguish generated pages from asset URLs', async () => { const directory = await mkdtemp(join(tmpdir(), 'aspire-timing-report-')); directories.push(directory); From 4beca050bdb730f3d59c6985cd7d052a6a752d3a Mon Sep 17 00:00:00 2001 From: IEvangelist <7679720+IEvangelist@users.noreply.github.com> Date: Mon, 2 Nov 2026 13:03:55 -0600 Subject: [PATCH 2/3] Expand measured trials to latest Bun and browser worker counts Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .../frontend-runtime-experiments.yml | 141 ++++++++++++++---- .../scripts/benchmark-test-runtimes.mjs | 12 +- 2 files changed, 118 insertions(+), 35 deletions(-) diff --git a/.github/workflows/frontend-runtime-experiments.yml b/.github/workflows/frontend-runtime-experiments.yml index 86f56429f2..9219fe96d9 100644 --- a/.github/workflows/frontend-runtime-experiments.yml +++ b/.github/workflows/frontend-runtime-experiments.yml @@ -6,6 +6,11 @@ on: - .github/workflows/frontend-runtime-experiments.yml - src/frontend/scripts/benchmark-test-runtimes.mjs workflow_dispatch: + inputs: + baseline_run: + description: Successful CI run whose site output is used unchanged + type: string + default: "41465710789" permissions: contents: read @@ -16,9 +21,13 @@ concurrency: jobs: tests: - name: Compare test runtimes + name: Compare test runtimes (Bun ${{ matrix.bun }}) runs-on: ubuntu-latest timeout-minutes: 15 + strategy: + fail-fast: false + matrix: + bun: [1.4.3, 1.4.4] defaults: run: working-directory: src/frontend @@ -28,7 +37,7 @@ jobs: persist-credentials: false - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 with: - bun-version-file: src/frontend/package.json + bun-version: ${{ matrix.bun }} - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version: 24.x @@ -49,14 +58,18 @@ jobs: if: ${{ always() }} uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: - name: test-runtime-experiment + name: test-runtime-experiment-${{ matrix.bun }} path: ${{ runner.temp }}/test-runtimes retention-days: 7 installs: - name: Compare installation layouts + name: Compare installation layout (${{ matrix.layout }}) runs-on: ubuntu-latest timeout-minutes: 10 + strategy: + fail-fast: false + matrix: + layout: [hoisted, isolated, global] defaults: run: working-directory: src/frontend @@ -74,34 +87,43 @@ jobs: env: BUN_INSTALL_CACHE_DIR: ${{ runner.temp }}/bun-install-experiment ASTRO_TELEMETRY_DISABLED: 1 + LAYOUT: ${{ matrix.layout }} run: | set -euo pipefail mkdir -p "$RUNNER_TEMP/install-results" - for layout in hoisted isolated global; do - linker="$layout" - global_store=0 - if [[ "$layout" == global ]]; then - linker=isolated - global_store=1 - fi - for round in 0 1 2; do - # Only remove this job's generated dependency directory, never the shared Bun cache. - rm -rf node_modules - BUN_INSTALL_GLOBAL_STORE="$global_store" /usr/bin/time -v \ - bun install --frozen-lockfile --linker "$linker" \ - > "$RUNNER_TEMP/install-results/$layout-$round.log" 2>&1 - done - bun run git-env - bunx astro sync > "$RUNNER_TEMP/install-results/$layout-sync.log" 2>&1 - bun run test:unit:contracts > "$RUNNER_TEMP/install-results/$layout-contracts.log" 2>&1 - du -sh node_modules >> "$RUNNER_TEMP/install-results/$layout-size.log" + linker="$LAYOUT" + global_store=0 + if [[ "$LAYOUT" == global ]]; then + linker=isolated + global_store=1 + fi + for round in 0 1 2; do + # Only remove this job's generated dependency directory, never the shared Bun cache. + rm -rf node_modules + BUN_INSTALL_GLOBAL_STORE="$global_store" /usr/bin/time -v \ + bun install --frozen-lockfile --linker "$linker" \ + > "$RUNNER_TEMP/install-results/$LAYOUT-$round.log" 2>&1 done + node --input-type=module -e ' + import { readdirSync, realpathSync } from "node:fs"; + import { join, sep } from "node:path"; + const store = join(process.env.BUN_INSTALL_CACHE_DIR, "links") + sep; + const entries = process.env.LAYOUT === "hoisted" ? [] : readdirSync("node_modules/.bun"); + const shared = entries.filter(name => realpathSync(join("node_modules/.bun", name)).startsWith(store)); + console.log(JSON.stringify({ layout: process.env.LAYOUT, sharedEntries: shared.length })); + if (process.env.LAYOUT === "global" && shared.length === 0) + throw new Error("No global-store links found; the requested setting may be unsupported."); + ' > "$RUNNER_TEMP/install-results/$LAYOUT-links.log" 2>&1 + bun run git-env + bunx astro sync > "$RUNNER_TEMP/install-results/$LAYOUT-sync.log" 2>&1 + bun run test:unit:contracts > "$RUNNER_TEMP/install-results/$LAYOUT-contracts.log" 2>&1 + du -sh node_modules >> "$RUNNER_TEMP/install-results/$LAYOUT-size.log" git diff --exit-code -- bun.lock package.json bunfig.toml patches - name: Upload install timings and compatibility results if: ${{ always() }} uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: - name: install-layout-experiment + name: install-layout-experiment-${{ matrix.layout }} path: ${{ runner.temp }}/install-results retention-days: 7 @@ -117,17 +139,20 @@ jobs: env: GH_TOKEN: ${{ github.token }} GH_REPO: ${{ github.repository }} + BASELINE_INPUT: ${{ inputs.baseline_run || '41465710789' }} run: | set -euo pipefail - run_id=$(gh run list --workflow ci.yml --branch main --status success --limit 1 --json databaseId --jq '.[0].databaseId') - test -n "$run_id" - echo "BASELINE_RUN=$run_id" >> "$GITHUB_ENV" - echo "### Artifact input: main CI run $run_id" >> "$GITHUB_STEP_SUMMARY" + [[ "$BASELINE_INPUT" =~ ^[0-9]+$ ]] + [[ "$(gh run view "$BASELINE_INPUT" --json conclusion --jq .conclusion)" == success ]] + echo "BASELINE_RUN=$BASELINE_INPUT" >> "$GITHUB_ENV" + echo "### Artifact input: main CI run $BASELINE_INPUT" >> "$GITHUB_STEP_SUMMARY" - name: Download unchanged production output - env: - GH_TOKEN: ${{ github.token }} - GH_REPO: ${{ github.repository }} - run: gh run download "$BASELINE_RUN" --name frontend-dist --dir dist + uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 + with: + github-token: ${{ github.token }} + run-id: ${{ env.BASELINE_RUN }} + name: frontend-dist + path: dist - name: Measure cross-file compression and lossless extraction run: | set -euo pipefail @@ -177,6 +202,60 @@ jobs: /usr/bin/time -v tar --zstd -xf frontend-dist.tar.zst -C dist test -f dist/index.html + browser: + name: Browser worker experiment (${{ matrix.workers }}) + needs: artifact + runs-on: ubuntu-latest + timeout-minutes: 25 + strategy: + fail-fast: false + matrix: + workers: [2, 4] + defaults: + run: + working-directory: src/frontend + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 + with: + bun-version-file: src/frontend/package.json + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + with: + node-version: 24.x + - run: bun install --frozen-lockfile + - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 + with: + name: frontend-archive-experiment + path: src/frontend + - name: Extract same complete site for both variants + run: | + mkdir dist + tar --zstd -xf frontend-dist.tar.zst -C dist + - run: bun run playwright install --with-deps chromium + - name: Compare identical desktop shard with unchanged timeouts and retries + env: + ASTRO_TELEMETRY_DISABLED: 1 + PLAYWRIGHT_JSON_OUTPUT_NAME: worker-results.json + WORKERS: ${{ matrix.workers }} + run: | + /usr/bin/time -v -o worker-resources.txt \ + bun run playwright test --project=desktop-chromium --shard=1/2 \ + --workers="$WORKERS" --reporter=blob,github,junit,list,json + - name: Upload worker results including retries and failures + if: ${{ always() }} + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: browser-worker-experiment-${{ matrix.workers }} + path: | + src/frontend/worker-results.json + src/frontend/worker-resources.txt + src/frontend/blob-report + src/frontend/test-results + compression-level: 0 + retention-days: 7 + build: name: Profile Bun build (transpiler cache ${{ matrix.cache }}) runs-on: ${{ github.repository_owner == 'microsoft' && '8-core-ubuntu-latest' || 'ubuntu-latest' }} diff --git a/src/frontend/scripts/benchmark-test-runtimes.mjs b/src/frontend/scripts/benchmark-test-runtimes.mjs index 5a2b112ac7..21bdae3525 100644 --- a/src/frontend/scripts/benchmark-test-runtimes.mjs +++ b/src/frontend/scripts/benchmark-test-runtimes.mjs @@ -1,5 +1,6 @@ import { spawn } from 'node:child_process'; import { createHash } from 'node:crypto'; +import { existsSync } from 'node:fs'; import { appendFile, mkdir, readFile, writeFile } from 'node:fs/promises'; import { join, resolve } from 'node:path'; @@ -42,7 +43,7 @@ for (let round = 0; round < 4; round++) { ...(round === 3 ? ['--cpu-prof', `--cpu-prof-dir=${output}`] : []), vitest, 'run', '--config', 'vitest.config.ts', '--reporter=json', `--outputFile=${report}`, ], round); - if (result.code === 0) { + if (existsSync(report)) { const json = JSON.parse(await readFile(report, 'utf8')); result.counts = { tests: json.numTotalTests, @@ -53,14 +54,17 @@ for (let round = 0; round < 4; round++) { result.tests = json.testResults.flatMap((file) => file.assertionResults.map((test) => [file.name, test.fullName, test.status]) ).sort((a, b) => JSON.stringify(a).localeCompare(JSON.stringify(b))); - if (runtime === 'node') { + if (runtime === 'node' && result.code === 0) { baseline ??= result; if (JSON.stringify(result.tests) !== JSON.stringify(baseline.tests)) baselineFailed = true; - } else { + } else if (runtime === 'bun') { result.matchesNode = baseline !== undefined && JSON.stringify(result.tests) === JSON.stringify(baseline.tests); } - } else if (runtime === 'node') baselineFailed = true; + } else if (result.code === 0) { + throw new Error(`${runtime} exited successfully without its required JSON report.`); + } + if (runtime === 'node' && result.code !== 0) baselineFailed = true; results.push(result); } } From 6c9c915fb97f42728e0cc8def0497dc732cb4456 Mon Sep 17 00:00:00 2001 From: IEvangelist <7679720+IEvangelist@users.noreply.github.com> Date: Mon, 2 Nov 2026 13:07:08 -0600 Subject: [PATCH 3/3] Move browsable artifact publishing off the browser-test critical path Keep the original frontend-dist HTML artifact and PR comment, while transporting the full site once as tar+zstd for E2E and publication. Preserve failed-build output and require publication in the frontend gate. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .github/workflows/frontend-build.yml | 89 ++++++++++++++----- .../frontend-runtime-experiments.yml | 1 + .../unit/build-performance.vitest.test.ts | 19 +++- 3 files changed, 81 insertions(+), 28 deletions(-) diff --git a/.github/workflows/frontend-build.yml b/.github/workflows/frontend-build.yml index 8cf5761b5c..6e50d8cba0 100644 --- a/.github/workflows/frontend-build.yml +++ b/.github/workflows/frontend-build.yml @@ -6,7 +6,6 @@ on: node_version: description: Node.js version required: true - default: "24.x" type: string pull_number: description: Pull request number when available @@ -157,10 +156,59 @@ jobs: if-no-files-found: warn retention-days: 7 - # Upload before the dist sanity-check so the artifact is always - # available for debugging, even when the check step fails. - # Note: `uses` actions ignore the job-level working-directory, - # so the path is repo-root-relative (src/frontend/dist). + - name: Check dist + run: | + test -f dist/index.html || { echo "::error::Frontend build incomplete: dist/index.html missing"; exit 1; } + + # Compress across files: the site contains thousands of similar pages. + # Publish browsable HTML on another runner so E2E doesn't wait for its upload. + - name: Package complete site for transport + run: tar -I 'zstd -T2 -3' -cf frontend-dist.tar.zst -C dist . + + - name: Upload E2E transport artifact + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: frontend-e2e-dist + path: src/frontend/frontend-dist.tar.zst + if-no-files-found: error + retention-days: 7 + compression-level: 0 + + - name: Preserve partial output after a failed build + if: ${{ failure() }} + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: frontend-dist + path: src/frontend/dist + if-no-files-found: warn + retention-days: 7 + compression-level: 1 + + publish: + name: Publish browsable frontend artifact + needs: build + runs-on: ubuntu-latest + defaults: + run: + working-directory: src/frontend + steps: + - name: Download complete site + uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 + with: + name: frontend-e2e-dist + path: src/frontend + + - name: Extract complete site + run: | + mkdir -p dist + tar --zstd -xf frontend-dist.tar.zst -C dist + test -f dist/index.html || { echo "::error::Extracted frontend site has no index.html"; exit 1; } + + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + with: + node-version: ${{ inputs.node_version }} + + # Preserve the HTML layout consumed by GitHub Artifacts Explorer and the PR comment. - name: Upload build artifact id: upload_build_artifact if: ${{ always() }} @@ -261,20 +309,6 @@ jobs: >/dev/null fi - - name: Check dist - run: | - if [ ! -d "dist" ]; then - echo "Frontend build failed - dist directory not found" - exit 1 - fi - - if [ ! -f "dist/index.html" ]; then - echo "Frontend build incomplete - index.html not found" - exit 1 - fi - - ls -la dist - validation: name: Frontend validation runs-on: ubuntu-latest @@ -339,8 +373,14 @@ jobs: - name: Download dist artifact uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 with: - name: frontend-dist - path: src/frontend/dist + name: frontend-e2e-dist + path: src/frontend + + - name: Extract complete site + run: | + mkdir -p dist + tar --zstd -xf frontend-dist.tar.zst -C dist + test -f dist/index.html || { echo "::error::Extracted frontend site has no index.html"; exit 1; } - name: Install Playwright Chromium run: bun run playwright install --with-deps chromium @@ -451,19 +491,20 @@ jobs: frontend-gate: name: Frontend gate if: ${{ always() }} - needs: [build, validation, e2e, report] + needs: [build, publish, validation, e2e, report] runs-on: ubuntu-latest steps: - name: Require all frontend checks env: BUILD: ${{ needs.build.result }} + PUBLISH: ${{ needs.publish.result }} VALIDATION: ${{ needs.validation.result }} E2E: ${{ needs.e2e.result }} REPORT: ${{ needs.report.result }} run: | - for result in "$BUILD" "$VALIDATION" "$E2E" "$REPORT"; do + for result in "$BUILD" "$PUBLISH" "$VALIDATION" "$E2E" "$REPORT"; do if [[ "$result" != "success" ]]; then - echo "::error::Every frontend job must succeed (build=$BUILD validation=$VALIDATION e2e=$E2E report=$REPORT)." + echo "::error::Every frontend job must succeed (build=$BUILD publish=$PUBLISH validation=$VALIDATION e2e=$E2E report=$REPORT)." exit 1 fi done diff --git a/.github/workflows/frontend-runtime-experiments.yml b/.github/workflows/frontend-runtime-experiments.yml index 9219fe96d9..7c2cf01c33 100644 --- a/.github/workflows/frontend-runtime-experiments.yml +++ b/.github/workflows/frontend-runtime-experiments.yml @@ -2,6 +2,7 @@ name: Frontend runtime experiments on: pull_request: + types: [opened, reopened] paths: - .github/workflows/frontend-runtime-experiments.yml - src/frontend/scripts/benchmark-test-runtimes.mjs diff --git a/src/frontend/tests/unit/build-performance.vitest.test.ts b/src/frontend/tests/unit/build-performance.vitest.test.ts index f2f96017de..897d4075a9 100644 --- a/src/frontend/tests/unit/build-performance.vitest.test.ts +++ b/src/frontend/tests/unit/build-performance.vitest.test.ts @@ -61,13 +61,24 @@ test('frontend workflow keeps validation parallel and every shard required', asy expect(job('e2e')).toContain('--shard=${{ matrix.shard }}/2'); expect(job('e2e')).toContain('frontend-blob-report-${{ matrix.project }}-${{ matrix.shard }}'); expect(job('e2e')).toContain('frontend-test-results-${{ matrix.project }}-${{ matrix.shard }}'); - expect(job('frontend-gate')).toContain('needs: [build, validation, e2e, report]'); - expect(job('frontend-gate')).toContain('for result in "$BUILD" "$VALIDATION" "$E2E" "$REPORT"'); + expect(job('frontend-gate')).toContain('needs: [build, publish, validation, e2e, report]'); + expect(job('frontend-gate')).toContain('for result in "$BUILD" "$PUBLISH" "$VALIDATION" "$E2E" "$REPORT"'); expect(job('frontend-gate')).toContain('if [[ "$result" != "success" ]]'); expect(job('frontend-gate')).toContain('exit 1'); expect(job('report')).toContain('pattern: frontend-blob-report-*'); - expect(job('build')).toContain('name: frontend-dist'); - expect(job('build')).toContain('path: src/frontend/dist'); + expect(job('build')).toContain('name: frontend-e2e-dist'); + expect(job('build')).toContain("tar -I 'zstd -T2 -3' -cf frontend-dist.tar.zst -C dist ."); + expect(job('build')).toContain('name: Preserve partial output after a failed build'); + expect(job('build')).toContain('if: ${{ failure() }}'); + expect(job('publish')).toContain('needs: build'); + expect(job('publish')).toContain('name: frontend-dist'); + expect(job('publish')).toContain('path: src/frontend/dist'); + expect(job('publish')).toContain('marker=\'\''); + expect(job('e2e')).toContain('name: frontend-e2e-dist'); + for (const consumer of ['publish', 'e2e']) { + expect(job(consumer)).toContain('tar --zstd -xf frontend-dist.tar.zst -C dist'); + expect(job(consumer)).toContain('test -f dist/index.html'); + } expect(job('build')).toContain('./node_modules/astro/bin/astro.mjs build --mode production'); });