name: CI

on:
  push:
    branches: ['release/*']
  pull_request:
    branches: [main]

jobs:
  ci:
    runs-on: docker
    container:
      image: catthehacker/ubuntu:act-latest
    steps:
      - uses: https://data.forgejo.org/actions/checkout@v4

      - name: Set up PHP
        uses: https://github.com/shivammathur/setup-php@v2
        with:
          php-version: '8.3'
          extensions: pdo_sqlite, mbstring, xml, dom
          coverage: none

      - name: Cache Composer dependencies
        uses: https://data.forgejo.org/actions/cache@v4
        with:
          path: ~/.composer/cache
          key: composer-${{ hashFiles('composer.lock') }}
          restore-keys: composer-

      - name: Install dependencies
        run: composer install --no-interaction --prefer-dist

      - name: Prepare environment
        run: cp .env.testing .env

      - name: Lint
        run: vendor/bin/pint --test

      - name: Static analysis
        run: vendor/bin/phpstan analyse --memory-limit=1G

      - name: Tests
        run: php -d memory_limit=512M vendor/bin/phpunit
