diff --git a/.github/actions/start-app/action.yml b/.github/actions/start-app/action.yml index 2c26756c..6043d0d7 100644 --- a/.github/actions/start-app/action.yml +++ b/.github/actions/start-app/action.yml @@ -14,6 +14,15 @@ inputs: 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 @@ -38,6 +47,7 @@ runs: working-directory: ./backend - name: Build backend + if: inputs.skip-backend-build != 'true' shell: bash run: npm run build working-directory: ./backend diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ec383971..e4c0848f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -68,6 +68,17 @@ jobs: working-directory: ./backend run: npm audit --audit-level=high + # Hand the freshly-verified dist/ to the E2E job so it does not have to + # re-run `tsc` on the same source. retention-days is the minimum; this + # artifact is only needed for the downstream e2e job in the same run. + - name: Upload backend dist + uses: actions/upload-artifact@v7 + with: + name: backend-dist + path: backend/dist + retention-days: 1 + if-no-files-found: error + frontend: name: Frontend (Build, Lint) runs-on: ubuntu-latest @@ -158,8 +169,20 @@ jobs: - name: Checkout Code uses: actions/checkout@v6 + # Reuse the dist/ that the `backend` job produced and verified, instead + # of running `tsc` a second time against the same source tree. The + # composite action's `skip-backend-build` input short-circuits its build + # step when this artifact is already in place. + - name: Download backend dist + uses: actions/download-artifact@v7 + with: + name: backend-dist + path: backend/dist + - name: Start app & install Playwright uses: ./.github/actions/start-app + with: + skip-backend-build: 'true' - name: Run E2E tests run: npx playwright test