name: Tests concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: ${{ github.event_name == 'pull_request' }} on: push: branches: [main] paths: - ".github/workflows/test.yml" - "api/**" - "web/**" pull_request: branches: [main] paths: - ".github/workflows/test.yml" - "api/**" - "web/**" env: CARGO_TERM_COLOR: always jobs: backend: name: Backend tests runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - uses: Swatinem/rust-cache@v2 with: workspaces: api - name: Run tests working-directory: api run: cargo test frontend-unit: name: Frontend unit tests runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: 24 cache: npm cache-dependency-path: web/package-lock.json - name: Install dependencies working-directory: web run: npm ci - name: Run tests working-directory: web run: npx vitest run e2e: name: E2E tests runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - uses: Swatinem/rust-cache@v2 with: workspaces: api - uses: actions/setup-node@v4 with: node-version: 24 cache: npm cache-dependency-path: web/package-lock.json - name: Install frontend dependencies working-directory: web run: npm ci - name: Install Playwright browsers working-directory: web run: npx playwright install --with-deps chromium - name: Build frontend working-directory: web run: npm run build-only - name: Build backend working-directory: api run: cargo build --release --features test-support - name: Start backend env: TMDB_API_KEY: ${{ secrets.TMDB_API_KEY || 'test' }} MDBLIST_API_KEY: ${{ secrets.MDBLIST_API_KEY || 'test' }} FANART_API_KEY: ${{ secrets.FANART_API_KEY || 'test' }} OMDB_API_KEY: ${{ secrets.OMDB_API_KEY || '' }} JWT_SECRET: abababababababababababababababababababababababababababababababab LISTEN_ADDR: 0.0.0.0:3333 COOKIE_SECURE: "false" CACHE_DIR: /tmp/openposterdb-e2e DB_DIR: /tmp/openposterdb-e2e STATIC_DIR: web/dist run: | mkdir -p "$CACHE_DIR" api/target/release/openposterdb-api & for i in $(seq 1 30); do if curl -sf http://127.0.0.1:3333/api/auth/status > /dev/null 2>&1; then echo "Backend ready" break fi sleep 1 done - name: Run E2E tests working-directory: web env: CI: true run: npx playwright test --project=setup --project=chromium --project=live - uses: actions/upload-artifact@v4 if: ${{ !cancelled() }} with: name: playwright-report path: web/playwright-report/ retention-days: 7