name: Blackbox Tests

on:
  pull_request:
    branches:
      - main
    paths:
      - api/**
      - tests-blackbox/**
      - packages/shared/**
      - package.json
      - pnpm-lock.yaml
      - .github/workflows/blackbox-pr.yml

concurrency:
  group: blackbox-pr-${{ github.ref }}
  cancel-in-progress: true

env:
  NODE_OPTIONS: --max_old_space_size=6144

jobs:
  test:
    name: SQLite Only
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v3

      - name: Prepare
        uses: ./.github/actions/prepare

      - name: Prune Dependencies
        run: find . -type d -name node_modules -prune -exec rm -rf {} \;

      - name: Install Production Dependencies
        run: pnpm install --prod

      - name: Install Root Dev Dependencies
        run: pnpm install -w --dev

      - name: Start Services
        run: docker compose -f tests-blackbox/docker-compose.yml up auth-saml -d --quiet-pull --wait

      - name: Run Tests
        run: TEST_DB=sqlite3 pnpm run -w test:blackbox
