main.yaml 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. name: main
  2. on: [ push, pull_request ]
  3. jobs:
  4. test:
  5. runs-on: ubuntu-latest
  6. strategy:
  7. matrix:
  8. php-version:
  9. - '7.1'
  10. - '7.2'
  11. - '7.3'
  12. - '7.4'
  13. - '8.0'
  14. - '8.1'
  15. - '8.2'
  16. include:
  17. - php-version: 'nightly'
  18. experimental: true
  19. name: PHP ${{ matrix.php-version }}
  20. steps:
  21. - name: Checkout
  22. uses: actions/checkout@v3
  23. - name: Setup PHP, with composer and extensions
  24. uses: shivammathur/setup-php@v2
  25. with:
  26. php-version: ${{ matrix.php-version }}
  27. extensions: ctype, dom, gd, iconv, fileinfo, libxml, mbstring, simplexml, xml, xmlreader, xmlwriter, zip, zlib
  28. coverage: none
  29. - name: Get composer cache directory
  30. id: composer-cache
  31. run: echo "::set-output name=dir::$(composer config cache-files-dir)"
  32. - name: Cache composer dependencies
  33. uses: actions/cache@v3
  34. with:
  35. path: ${{ steps.composer-cache.outputs.dir }}
  36. key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
  37. restore-keys: ${{ runner.os }}-composer-
  38. - name: Delete composer lock file
  39. id: composer-lock
  40. if: ${{ matrix.php-version == '8.0' || matrix.php-version == '8.1' || matrix.php-version == '8.2' || matrix.php-version == 'nightly' }}
  41. run: |
  42. rm composer.lock
  43. echo "::set-output name=flags::--ignore-platform-reqs"
  44. - name: Install dependencies
  45. run: composer update --no-progress --prefer-dist --optimize-autoloader ${{ steps.composer-lock.outputs.flags }}
  46. - name: Setup problem matchers for PHP
  47. run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
  48. - name: Setup problem matchers for PHPUnit
  49. run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
  50. - name: Test with PHPUnit
  51. run: ./vendor/bin/phpunit
  52. phpcs:
  53. runs-on: ubuntu-latest
  54. steps:
  55. - name: Checkout
  56. uses: actions/checkout@v3
  57. - name: Setup PHP, with composer and extensions
  58. uses: shivammathur/setup-php@v2
  59. with:
  60. php-version: 7.4
  61. extensions: ctype, dom, gd, iconv, fileinfo, libxml, mbstring, simplexml, xml, xmlreader, xmlwriter, zip, zlib
  62. coverage: none
  63. tools: cs2pr
  64. - name: Get composer cache directory
  65. id: composer-cache
  66. run: echo "::set-output name=dir::$(composer config cache-files-dir)"
  67. - name: Cache composer dependencies
  68. uses: actions/cache@v3
  69. with:
  70. path: ${{ steps.composer-cache.outputs.dir }}
  71. key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
  72. restore-keys: ${{ runner.os }}-composer-
  73. - name: Install dependencies
  74. run: composer install --no-progress --prefer-dist --optimize-autoloader
  75. - name: Code style with PHP_CodeSniffer
  76. run: ./vendor/bin/phpcs -q --report=checkstyle | cs2pr --graceful-warnings --colorize
  77. coverage:
  78. runs-on: ubuntu-latest
  79. steps:
  80. - name: Checkout
  81. uses: actions/checkout@v3
  82. - name: Setup PHP, with composer and extensions
  83. uses: shivammathur/setup-php@v2
  84. with:
  85. php-version: 7.4
  86. extensions: ctype, dom, gd, iconv, fileinfo, libxml, mbstring, simplexml, xml, xmlreader, xmlwriter, zip, zlib
  87. coverage: pcov
  88. - name: Get composer cache directory
  89. id: composer-cache
  90. run: echo "::set-output name=dir::$(composer config cache-files-dir)"
  91. - name: Cache composer dependencies
  92. uses: actions/cache@v3
  93. with:
  94. path: ${{ steps.composer-cache.outputs.dir }}
  95. key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
  96. restore-keys: ${{ runner.os }}-composer-
  97. - name: Install dependencies
  98. run: composer install --no-progress --prefer-dist --optimize-autoloader
  99. - name: Coverage
  100. run: |
  101. ./vendor/bin/phpunit --coverage-text