build.yml 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. name: build
  2. on:
  3. - push
  4. - pull_request
  5. jobs:
  6. tests:
  7. name: PHP ${{ matrix.php }} Test on ${{ matrix.os }}
  8. env:
  9. extensions: bz2, dom, iconv, fileinfo, openssl, xml, zlib
  10. key: cache-v1
  11. PHPUNIT_COVERAGE: 0
  12. PHP_INI: date.timezone='UTC', memory_limit=-1, opcache.enable=1, opcache.enable_cli=1
  13. strategy:
  14. matrix:
  15. os:
  16. - ubuntu-latest
  17. - windows-latest
  18. php:
  19. - '7.4'
  20. - '8.0'
  21. runs-on: ${{ matrix.os }}
  22. steps:
  23. -
  24. name: Checkout
  25. uses: actions/checkout@v1
  26. -
  27. name: Install linux dependencies
  28. if: matrix.os == 'ubuntu-latest'
  29. run: sudo apt-get install unzip p7zip-full
  30. -
  31. name: Install PHP with extensions
  32. uses: shivammathur/setup-php@v2
  33. with:
  34. php-version: 7.4
  35. extensions: ${{ env.extensions }}
  36. coverage: pcov
  37. ini-values: ${{ env.PHP_INI }}
  38. tools: composer:v2
  39. -
  40. name: Determine composer cache directory on Linux
  41. if: matrix.os == 'ubuntu-latest'
  42. run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV
  43. -
  44. name: Set coverage args
  45. if: matrix.os == 'ubuntu-latest' && matrix.php == '8.0'
  46. run: echo "PHPUNIT_COVERAGE=1" >> $GITHUB_ENV
  47. -
  48. name: Determine composer cache directory on Windows
  49. if: matrix.os == 'windows-latest'
  50. run: echo "COMPOSER_CACHE_DIR=~\AppData\Local\Composer" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
  51. -
  52. name: Cache composer dependencies
  53. uses: actions/cache@v2
  54. with:
  55. path: ${{ env.COMPOSER_CACHE_DIR }}
  56. key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
  57. restore-keys: php${{ matrix.php }}-composer-
  58. -
  59. name: Check PHP Version
  60. run: php -v
  61. -
  62. name: Check Composer Version
  63. run: composer -V
  64. -
  65. name: Check PHP Extensions
  66. run: php -m
  67. -
  68. name: Validate composer.json and composer.lock
  69. run: composer validate
  70. -
  71. name: Install dependencies with composer
  72. run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
  73. -
  74. name: Run tests with phpunit
  75. if: env.PHPUNIT_COVERAGE == 0
  76. run: vendor/bin/phpunit -v
  77. -
  78. name: Run tests with phpunit and coverage
  79. if: env.PHPUNIT_COVERAGE == 1
  80. run: vendor/bin/phpunit -v --coverage-clover=coverage.clover
  81. -
  82. name: Upload code coverage scrutinizer
  83. if: env.PHPUNIT_COVERAGE == 1
  84. run: |
  85. wget https://scrutinizer-ci.com/ocular.phar
  86. php ocular.phar code-coverage:upload --format=php-clover coverage.clover