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