name: ci

on:
  push:
    branches: [main]
  pull_request:

permissions:
  contents: read

jobs:
  test-build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: '22'
          cache: npm
      # installs the lnurlcash-kit git dependency and builds its dist via the
      # package's prepare hook (standard npm runs prepare for git deps)
      - run: npm ci
      # src-pwa is its own package (register-service-worker types)
      - run: npm ci --prefix src-pwa
      - run: npm run typecheck
      - run: npx vitest run
      - run: npx quasar build -m pwa

  e2e:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: '22'
          cache: npm
      - run: npm ci
      - run: npm ci --prefix src-pwa
      # no system chromium on the runners: playwright.config.ts only forces an
      # executablePath when CHROMIUM_PATH or a system chromium exists, so the
      # bundled browser installed here is used
      - run: npx playwright install --with-deps chromium
      - run: npm run test:e2e
      - if: failure()
        uses: actions/upload-artifact@v4
        with:
          name: playwright-report
          path: |
            playwright-report/
            test-results/
          retention-days: 7
