name: qa-required

on:
  push:
    branches:
      - main
  pull_request:

jobs:
  qa-required:
    name: qa-required
    runs-on: ubuntu-latest
    env:
      COMPOSE_PROJECT_NAME: breadcrumb-ci

    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Create .env for CI
        run: cp .env.example .env

      - name: Start project services
        run: |
          docker compose up -d --force-recreate php db memcached
          sleep 20

      - name: Install Composer dependencies
        run: |
          docker compose exec -T php bash -c "cd /var/www && composer install --no-interaction --prefer-dist --optimize-autoloader"

      - name: Run DB migrations
        run: docker compose exec -T php php bin/console db:migrate

      - name: Install ripgrep
        run: sudo apt-get install -y ripgrep

      - name: Run required QA gates
        run: bin/qa-required.sh
