name: "Continuous Integration (32bit)"

on:
  push:
    branches:
      - main
    paths-ignore:
      - 'doc/**'

env:
  COMPOSER_FLAGS: "--ansi --no-interaction --no-progress --prefer-dist"
  COMPOSER_UPDATE_FLAGS: ""

permissions:
  contents: read

jobs:
  tests:
    name: "CI"

    runs-on: ubuntu-latest
    container: shivammathur/node:latest-i386

    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

      - uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # 2.36.0
        with:
          coverage: "none"
          extensions: "intl, zip"
          ini-values: "memory_limit=-1, phar.readonly=0, error_reporting=E_ALL, display_errors=On, display_startup_errors=On"
          php-version: "8.4"
          tools: composer

      - name: "Install dependencies from composer.lock using composer binary provided by system"
        run: "composer install ${{ env.COMPOSER_FLAGS }}"

      - name: "Run install again using composer binary from source"
        run: "bin/composer install ${{ env.COMPOSER_FLAGS }}"

      - name: "Make source binary the one used by default"
        run: |
          echo -e "$(pwd)/bin\n$(cat $GITHUB_PATH)" > $GITHUB_PATH
          echo -e "COMPOSER_BINARY=$(pwd)/bin/composer" >> $GITHUB_ENV
          git config --global --add safe.directory $(pwd)

      - name: "Prepare git environment"
        run: "git config --global user.name composer && git config --global user.email composer@example.com"

      - name: "Run tests"
        run: "vendor/bin/simple-phpunit --verbose"
