name: CI

on:
  push:
  pull_request:
  workflow_dispatch:

jobs:
  all-php-versions:
    name: PHP ${{ matrix.php }}
    strategy:
      fail-fast: false
      matrix:
        php: ["8.1", "8.2", "8.3", "8.4", "8.5"]

    uses: ./.github/workflows/main-php-matrix.yml
    with:
      php: ${{ matrix.php }}
    secrets: inherit

  codestyle:
    name: Code Style checks
    runs-on: ubuntu-22.04
    strategy:
      fail-fast: false

    steps:
      - uses: actions/checkout@v6

      - name: Setup PHP and tools
        uses: shivammathur/setup-php@2.37.0
        with:
          php-version: 8.3
          tools: php-cs-fixer:3.75
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      - name: Run PHP-CS-Fixer
        run: php-cs-fixer fix --dry-run --diff --ansi

  shellcheck:
    name: ShellCheck
    runs-on: ubuntu-22.04
    strategy:
      fail-fast: false

    steps:
      - uses: actions/checkout@v6

      - name: Run ShellCheck
        uses: ludeeus/action-shellcheck@2.0.0

  translations:
    name: Translation checks
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v6

      - name: Setup PHP
        uses: shivammathur/setup-php@2.37.0
        with:
          php-version: 8.3

      - name: Verify translations
        run: php .github/workflows/verify-translations.php ${{ github.workspace }}/resources/translations