mirror of
https://github.com/Studio-Saelix/sencho.git
synced 2026-08-07 01:14:14 +00:00
f2c13bf02d
The Playwright browser download (Chrome for Testing + Chrome Headless Shell + FFmpeg, ~170MB total) is the single largest cost in the start-app composite action. Observed in a recent E2E run: 4m15s to download cold vs ~10s on a warm cache. Across weekly cache evictions and the ~30% of runs that hit a cold cache, that is multiple action minutes per PR averaged over time, and several minutes of wall-time regression on any individual cold run. Split the existing `playwright install --with-deps chromium` step into two halves: 1. `playwright install-deps chromium` runs unconditionally because apt packages live under /var and are not preserved by actions/cache. This is fast (~10s). 2. `playwright install chromium` runs only when the browser cache under ~/.cache/ms-playwright misses. The cache key is pinned to the @playwright/test version read from the root package.json, so a future bump invalidates the cache automatically and the old browsers are replaced cleanly. Sharding (the other half of the original optimization plan) was evaluated and rejected. With ~80s of per-job setup and only ~60s of test time, 2-way sharding would roughly double action minutes while saving only ~5s of wall time on warm runs. The math only pencils out when test time significantly exceeds setup time, which is not the case for Sencho today. Revisit if the suite grows past ~5 minutes of pure test time.
120 lines
4.1 KiB
YAML
120 lines
4.1 KiB
YAML
name: Start Sencho App
|
|
description: >
|
|
Shared setup for integration jobs: installs deps, builds backend,
|
|
starts backend + frontend dev servers, waits for readiness,
|
|
and installs Playwright browsers.
|
|
|
|
inputs:
|
|
jwt-secret:
|
|
required: false
|
|
default: 'ci-test-secret-key-not-for-production'
|
|
compose-dir:
|
|
required: false
|
|
default: '/tmp/compose'
|
|
port:
|
|
required: false
|
|
default: '3000'
|
|
skip-backend-build:
|
|
description: >
|
|
When 'true', skip running `npm run build` in backend/ and assume the
|
|
caller has already materialized backend/dist (e.g. via download-artifact
|
|
from an upstream job that already built and verified it). Leave 'false'
|
|
for standalone invocations like the update-screenshots job that do not
|
|
run in a job graph with a prior build step.
|
|
required: false
|
|
default: 'false'
|
|
|
|
runs:
|
|
using: composite
|
|
steps:
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v6
|
|
with:
|
|
node-version: '20'
|
|
cache: 'npm'
|
|
cache-dependency-path: |
|
|
package-lock.json
|
|
backend/package-lock.json
|
|
frontend/package-lock.json
|
|
|
|
- name: Install root dependencies (Playwright)
|
|
shell: bash
|
|
run: npm ci
|
|
|
|
- name: Install backend dependencies
|
|
shell: bash
|
|
run: npm ci
|
|
working-directory: ./backend
|
|
|
|
- name: Build backend
|
|
if: inputs.skip-backend-build != 'true'
|
|
shell: bash
|
|
run: npm run build
|
|
working-directory: ./backend
|
|
|
|
- name: Install frontend dependencies
|
|
shell: bash
|
|
run: npm ci
|
|
working-directory: ./frontend
|
|
|
|
- name: Create compose directory and log dir
|
|
shell: bash
|
|
run: |
|
|
mkdir -p ${{ inputs.compose-dir }}
|
|
mkdir -p "${{ github.workspace }}/ci-logs"
|
|
|
|
# Log files live under $GITHUB_WORKSPACE so actions/upload-artifact@v4+ can
|
|
# include them alongside repo-relative paths like e2e/report/. Mixing those
|
|
# with /tmp paths makes '/' the common root and v4+ strips the absolute
|
|
# entries from the artifact. `stdbuf -oL -eL` forces line-buffered output
|
|
# so a crash doesn't lose the final few hundred lines to block buffering.
|
|
- name: Start backend
|
|
shell: bash
|
|
run: stdbuf -oL -eL node dist/index.js > "${{ github.workspace }}/ci-logs/backend.log" 2>&1 &
|
|
working-directory: ./backend
|
|
env:
|
|
JWT_SECRET: ${{ inputs.jwt-secret }}
|
|
COMPOSE_DIR: ${{ inputs.compose-dir }}
|
|
PORT: ${{ inputs.port }}
|
|
NODE_ENV: test
|
|
|
|
- name: Start frontend dev server
|
|
shell: bash
|
|
run: stdbuf -oL -eL npm run dev > "${{ github.workspace }}/ci-logs/frontend.log" 2>&1 &
|
|
working-directory: ./frontend
|
|
|
|
- name: Wait for services to be ready
|
|
shell: bash
|
|
run: npx wait-on http://localhost:${{ inputs.port }}/api/health http://localhost:5173 --timeout 30000
|
|
|
|
# Playwright bundles Chrome for Testing (~170MB) and FFmpeg. Downloading
|
|
# them on every E2E run is the single largest cost in this composite:
|
|
# observed ~4m15s cold vs ~10s warm when the path is cached. Cache the
|
|
# download under a key pinned to the @playwright/test version so a
|
|
# future bump invalidates automatically.
|
|
- name: Read Playwright version
|
|
id: playwright-version
|
|
shell: bash
|
|
run: |
|
|
version=$(node -p "require('./package.json').devDependencies['@playwright/test'].replace(/^[\^~]/, '')")
|
|
echo "version=$version" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Cache Playwright browsers
|
|
id: playwright-cache
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ~/.cache/ms-playwright
|
|
key: playwright-${{ runner.os }}-${{ steps.playwright-version.outputs.version }}
|
|
|
|
# OS deps are apt packages under /var, which actions/cache does not
|
|
# preserve, so they have to be reinstalled every run regardless of the
|
|
# browser cache state. It is fast (~10s).
|
|
- name: Install Playwright OS dependencies
|
|
shell: bash
|
|
run: npx playwright install-deps chromium
|
|
|
|
- name: Install Playwright browsers
|
|
if: steps.playwright-cache.outputs.cache-hit != 'true'
|
|
shell: bash
|
|
run: npx playwright install chromium
|