main.yaml 3.8 KB

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