diff --git a/.github/scripts/fetch-seerrng-files.sh b/.github/scripts/fetch-seerrng-files.sh new file mode 100755 index 0000000..9056b0b --- /dev/null +++ b/.github/scripts/fetch-seerrng-files.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +# Copies the SeerrNG files Lumen builds against (src/, server/, config/, package.json, +# tsconfig.json) from the commit named in UPSTREAM into the workspace root. +set -euo pipefail +sha="$(tr -d '[:space:]' < UPSTREAM)" +[[ "$sha" =~ ^[0-9a-f]{40}$ ]] || { echo "UPSTREAM does not hold a commit id"; exit 1; } +up="${RUNNER_TEMP:-/tmp}/seerrng-upstream" +rm -rf "$up" +git init -q "$up" +git -C "$up" remote add origin https://github.com/snapetech-org/seerrng.git +git -C "$up" sparse-checkout set --no-cone /src/ /server/ /config/ /package.json /tsconfig.json +git -C "$up" fetch -q --depth 1 --filter=blob:none origin "$sha" +git -C "$up" checkout -q FETCH_HEAD +cp -r "$up/src" "$up/server" "$up/config" "$up/package.json" "$up/tsconfig.json" "${GITHUB_WORKSPACE:-$PWD}/" +echo "Using snapetech-org/seerrng@${sha::8}" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0c6e7fb..b430115 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,46 +1,94 @@ -# Builds Lumen and runs its type check, unit tests and browser tests (desktop, iPhone, -# Android and tablet) for every pull request that touches lumen/, and after each sync. +# Builds Lumen and runs its type check, unit tests and browser tests (desktop, phone and +# tablet) for every pull request that touches lumen/, and after each sync. +# +# Lumen imports a few SeerrNG files from outside lumen/ (the @app and @server aliases, shared +# translations, the issue constants), and its image build copies them in. This repo only +# mirrors lumen/, so each job first fetches src/, server/, config/ and the root package.json +# and tsconfig.json from the SeerrNG commit named in UPSTREAM, the one lumen/ was synced from. +# +# The browser suite runs in four shards so each one finishes well inside the job limit. name: Lumen tests on: pull_request: paths: - 'lumen/**' + - 'UPSTREAM' - '.github/workflows/test.yml' + - '.github/scripts/fetch-seerrng-files.sh' push: branches: [main] paths: - 'lumen/**' + - 'UPSTREAM' workflow_dispatch: permissions: contents: read jobs: - test: - runs-on: ubuntu-latest - defaults: - run: - working-directory: lumen + checks: + name: Type check, build, unit and image tests + runs-on: ubuntu-24.04 + timeout-minutes: 30 steps: - uses: actions/checkout@v4 - + with: + persist-credentials: false + - name: Fetch the SeerrNG files Lumen builds against + run: bash .github/scripts/fetch-seerrng-files.sh - uses: actions/setup-node@v4 with: - node-version: 24 + node-version-file: package.json cache: npm cache-dependency-path: lumen/package-lock.json + - name: Install Lumen dependencies + working-directory: lumen + run: npm ci --ignore-scripts + - name: Type check + working-directory: lumen + run: npx tsc --noEmit -p . + - name: Build Lumen + working-directory: lumen + run: npm run build + - name: Unit, image and proxy tests + working-directory: lumen + run: npm test - - run: npm ci - - run: npx tsc --noEmit -p . - - run: npm run build - - run: npm test - - run: npx playwright install --with-deps chromium webkit - - run: npx playwright test - + browser: + name: Browser tests (shard ${{ matrix.shard }}/4) + runs-on: ubuntu-24.04 + timeout-minutes: 75 + strategy: + fail-fast: false + matrix: + shard: [1, 2, 3, 4] + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + - name: Fetch the SeerrNG files Lumen builds against + run: bash .github/scripts/fetch-seerrng-files.sh + - uses: actions/setup-node@v4 + with: + node-version-file: package.json + cache: npm + cache-dependency-path: lumen/package-lock.json + - name: Install Lumen dependencies + working-directory: lumen + run: npm ci --ignore-scripts + - name: Build Lumen + working-directory: lumen + run: npm run build + - name: Install Chromium + working-directory: lumen + run: npx --no-install playwright install --with-deps chromium + - name: Browser tests in desktop, phone and tablet viewports + working-directory: lumen + run: npm run test:browser -- --workers=2 --shard=${{ matrix.shard }}/4 - uses: actions/upload-artifact@v4 if: failure() with: - name: playwright-results + name: playwright-results-${{ matrix.shard }} path: lumen/test-results retention-days: 7