Skip to content

Improve large-library duplicate scan safety #130

Improve large-library duplicate scan safety

Improve large-library duplicate scan safety #130

Workflow file for this run

name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
permissions:
contents: read
jobs:
test:
name: Unit & integration tests
runs-on: ubuntu-latest
env:
PLASMO_PUBLIC_PHOTOSWEEP_LICENSE_API_BASE_URL: https://photosweep-license-api-206538169327.us-west1.run.app
PLASMO_PUBLIC_PHOTOSWEEP_LICENSE_API_HOST_PERMISSION: https://photosweep-license-api-206538169327.us-west1.run.app/*
PLASMO_PUBLIC_PHOTOSWEEP_ALLOW_DEV_ENTITLEMENT: "0"
PLASMO_PUBLIC_PHOTOSWEEP_ENTITLEMENT_PUBLIC_KEY: ci-public-key-placeholder
# Hard cap so a stalled Playwright download fails in minutes, not the 6h default.
timeout-minutes: 20
steps:
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09
with:
submodules: recursive
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444
with:
# Node 22 LTS: Node 24.16.0 hangs forever extracting the Playwright
# browser zip (worked on 24.14.1; broke on a 24.x patch bump). See #123.
node-version: 22
cache: npm
- name: Install dependencies
run: npm ci
- name: Install GPTK dependencies
run: npm ci
working-directory: Google-Photos-Toolkit
# Unit tests (Vitest — pure JS, no browser)
- name: Unit tests
run: npm test
# Build extension (required before integration tests)
- name: Build extension for dev-entitlement integration tests
run: PLASMO_PUBLIC_PHOTOSWEEP_ALLOW_DEV_ENTITLEMENT=1 npm run build
# Integration tests require a headed browser; use Xvfb on Linux.
# Cache the browser binaries so we only hit the CDN when the Playwright
# version changes — keyed on the resolved @playwright/test version.
- name: Resolve Playwright version
id: pw-version
run: echo "version=$(node -p "require('@playwright/test/package.json').version")" >> "$GITHUB_OUTPUT"
- name: Cache Playwright browsers
id: pw-cache
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830
with:
path: ~/.cache/ms-playwright
key: playwright-${{ runner.os }}-${{ steps.pw-version.outputs.version }}
# System deps (apt) must be installed on every run; they aren't cached.
- name: Install Playwright system deps
run: npx playwright install-deps chromium
# Download the browser only on a cache miss. Wrap in timeout + retry:
# the CDN download intermittently stalls at 100%, which previously hung
# the job for the full 6h runner limit (see #123).
- name: Install Playwright browser
if: steps.pw-cache.outputs.cache-hit != 'true'
run: |
for attempt in 1 2 3; do
echo "::group::Playwright browser install (attempt $attempt)"
if timeout 300 npx playwright install chromium; then
echo "::endgroup::"
exit 0
fi
echo "::endgroup::"
echo "Attempt $attempt timed out or failed; retrying..."
done
echo "Playwright browser install failed after 3 attempts" >&2
exit 1
- name: Integration tests
run: xvfb-run --auto-servernum npm run test:integration
- name: Upload integration test results on failure
if: failure()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: integration-test-results
path: test-results/
bench:
name: Performance benchmarks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444
with:
node-version: 24
cache: npm
- name: Install dependencies
run: npm ci
- name: Run benchmarks
run: npx vitest bench --run --outputJson bench-output.json
# Restore the baseline recorded on the most recent main-branch push.
# restore-keys falls back to the latest matching entry when no exact hit.
- name: Restore baseline
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830
with:
path: tests/perf/bench-baseline.json
key: bench-baseline-${{ github.sha }}
restore-keys: bench-baseline-
- name: Check for regressions
run: node tools/check-bench.mjs
# Overwrite the baseline with current results and cache under this SHA.
# Only runs on main so PRs always compare against a known-good baseline.
- name: Update baseline
if: github.ref == 'refs/heads/main'
run: cp bench-output.json tests/perf/bench-baseline.json
- name: Save baseline
if: github.ref == 'refs/heads/main'
uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830
with:
path: tests/perf/bench-baseline.json
key: bench-baseline-${{ github.sha }}