Files
sencho/.github/actions/start-app/action.yml
T
Anso b27bc07f82 ci: reuse backend dist/ in E2E instead of rebuilding (#488)
The backend CI job already runs `tsc` against backend/src/ and only
marks the job green after build + tests + lint + audit all pass. The
E2E job then checked out the same source and ran the same tsc again
inside the start-app composite.

Upload backend/dist/ as a 1-day retention artifact at the end of the
backend job, download it in the E2E job before invoking the composite,
and gate the composite's "Build backend" step on a new
`skip-backend-build` input. The update-screenshots job (which also
uses the composite but has no upstream backend job) leaves the input
at its default of 'false' and continues to build from source.

Savings are modest (~10-15s per E2E run, on top of what setup-node's
~/.npm cache already buys us) but the real win is the contract:
the dist/ that E2E exercises is now byte-for-byte the same artifact
that the backend job verified, eliminating a whole class of "works
in backend job, breaks in E2E" drift.
2026-04-10 14:39:55 -04:00

93 lines
2.9 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
- name: Install Playwright browsers
shell: bash
run: npx playwright install --with-deps chromium