name: Large testsuite (run manually before releases)

on: workflow_dispatch

jobs:
  php81:
    name: PHP 8.1
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-20.04, ubuntu-18.04, windows-2022, windows-2019, windows-2016, macos-11, macos-10.15]
        php: [8.1]

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

    - name: Validate composer.json and composer.lock
      run: composer validate --strict

    - name: Setup PHP
      uses: shivammathur/setup-php@v2
      with:
        php-version: ${{ matrix.php }}
        extensions: mbstring

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

    - name: Run test suite
      run: composer run-script test

  php80:
    name: PHP 8.0
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [windows-2022]
        php: [8.0]

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

    - name: Validate composer.json and composer.lock
      run: composer validate --strict

    - name: Setup PHP
      uses: shivammathur/setup-php@v2
      with:
        php-version: ${{ matrix.php }}
        extensions: mbstring

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

    - name: Run test suite
      run: composer run-script test

  php74:
    name: PHP 7.4
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-20.04, ubuntu-18.04, windows-2019, windows-2016]
        php: [7.4]

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

    - name: Validate composer.json and composer.lock
      run: composer validate --strict

    - name: Setup PHP
      uses: shivammathur/setup-php@v2
      with:
        php-version: ${{ matrix.php }}
        extensions: mbstring

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

    - name: Run test suite
      run: composer run-script test

  php73:
    name: PHP 7.3
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-20.04]
        php: [7.3]

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

    - name: Validate composer.json and composer.lock
      run: composer validate --strict

    - name: Setup PHP
      uses: shivammathur/setup-php@v2
      with:
        php-version: ${{ matrix.php }}
        extensions: mbstring

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

    - name: Run test suite
      run: composer run-script test

  php72:
    name: PHP 7.2
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-20.04]
        php: [7.2]

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

    - name: Validate composer.json and composer.lock
      run: composer validate --strict

    - name: Setup PHP
      uses: shivammathur/setup-php@v2
      with:
        php-version: ${{ matrix.php }}
        extensions: mbstring

    - name: Downgrade PHP unit to a version that supports PHP 7.2
      run: composer require "phpunit/phpunit:^8.0" --dev

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

    - name: Run test suite
      run: composer run-script test

  php71:
    name: PHP 7.1
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-20.04]
        php: [7.1]

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

    - name: Validate composer.json and composer.lock
      run: composer validate --strict

    - name: Setup PHP
      uses: shivammathur/setup-php@v2
      with:
        php-version: ${{ matrix.php }}
        extensions: mbstring

    - name: Downgrade PHP unit to a version that supports PHP 7.1
      run: composer require "phpunit/phpunit:^7.0" --dev

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

    - name: Run test suite
      run: composer run-script test


  php70:
    name: PHP 7.0
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-18.04]
        php: [7.0]

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

    - name: Validate composer.json and composer.lock
      run: composer validate --strict

    - name: Setup PHP
      uses: shivammathur/setup-php@v2
      with:
        php-version: ${{ matrix.php }}
        extensions: mbstring

    - name: Downgrade PHP unit to a version that supports PHP 7.1
      run: composer require "phpunit/phpunit:^6.0" --dev

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

    - name: Run test suite
      run: composer run-script test


  disabled:
    name: Disabled functions
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-20.04, windows-2019]
        php: [8.0, 7.4]

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

    - name: Validate composer.json and composer.lock
      run: composer validate --strict

    - name: Setup PHP (disable some functions)
      uses: shivammathur/setup-php@v2
      with:
        php-version: ${{ matrix.php }}
        extensions: mbstring
        # PS: I would have liked to test disabling ini_get, but then composer fails
        # composer alse needs proc_open, so I cannot test without that either
        ini-values: disable_functions="exec,passthru"

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

    - name: Run test suite
      run: composer run-script test

    - name: Re-setup PHP (disable other functions)
      uses: shivammathur/setup-php@v2
      with:
        php-version: ${{ matrix.php }}
        extensions: mbstring
        ini-values: disable_functions="exec"

    - name: Run test suite
      run: composer run-script test

    - name: Re-setup PHP (disable yet other functions)
      uses: shivammathur/setup-php@v2
      with:
        php-version: ${{ matrix.php }}
        extensions: mbstring
        ini-values: disable_functions="passthru"

    - name: Run test suite
      run: composer run-script test
