name: CI

on:
  push:
  pull_request:

jobs:
  tests:
    name: Tests (PHP ${{ matrix.php }})
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        php:
          - 8.0
          - 7.4
          - 7.3
          - 7.2
          - 7.1
    steps:
      - uses: actions/checkout@v2
      - uses: shivammathur/setup-php@v2
        with:
          php-version: ${{ matrix.php }}
      - run: |
          # install 'libuv'
          mkdir libuv
          curl -L https://github.com/libuv/libuv/archive/v1.6.1.tar.gz | tar xzf -
          cd libuv-1.6.1 && ./autogen.sh && ./configure --prefix=$(readlink -f `pwd`/../libuv) && make && make install
          cd ..

          # install 'php-uv'
          phpize && ./configure --with-uv=$(readlink -f `pwd`/libuv)
          make
          sudo make install
          echo "extension = uv.so" >> $(php -r 'echo php_ini_loaded_file();')
      - run: php run-tests.php -p `which php` --offline --show-diff --set-timeout 120
