main.yml 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. name: main
  2. on: [ push, pull_request ]
  3. jobs:
  4. test:
  5. runs-on: ubuntu-latest
  6. strategy:
  7. matrix:
  8. experimental:
  9. - false
  10. php-version:
  11. - '7.2'
  12. - '7.3'
  13. - '7.4'
  14. - '8.0'
  15. include:
  16. - php-version: '8.1'
  17. experimental: true
  18. name: PHP ${{ matrix.php-version }}
  19. steps:
  20. - name: Checkout
  21. uses: actions/checkout@v2
  22. - name: Setup PHP, with composer and extensions
  23. uses: shivammathur/setup-php@v2
  24. with:
  25. php-version: ${{ matrix.php-version }}
  26. coverage: none
  27. - name: Get composer cache directory
  28. id: composer-cache
  29. run: echo "::set-output name=dir::$(composer config cache-files-dir)"
  30. - name: Cache composer dependencies
  31. uses: actions/cache@v2
  32. with:
  33. path: ${{ steps.composer-cache.outputs.dir }}
  34. key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
  35. restore-keys: ${{ runner.os }}-composer-
  36. - name: Delete composer lock file
  37. id: composer-lock
  38. if: ${{ matrix.php-version == '8.1' }}
  39. run: |
  40. echo "::set-output name=flags::--ignore-platform-reqs"
  41. - name: Install dependencies
  42. run: composer update --no-progress --prefer-dist --optimize-autoloader ${{ steps.composer-lock.outputs.flags }}
  43. - name: Setup problem matchers for PHP
  44. run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
  45. - name: Setup problem matchers for PHPUnit
  46. run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
  47. - name: "Run PHPUnit tests (Experimental: ${{ matrix.experimental }})"
  48. env:
  49. FAILURE_ACTION: "${{ matrix.experimental == true }}"
  50. run: vendor/bin/phpunit --verbose || $FAILURE_ACTION
  51. phpcs:
  52. runs-on: ubuntu-latest
  53. steps:
  54. - name: Checkout
  55. uses: actions/checkout@v2
  56. - name: Setup PHP, with composer and extensions
  57. uses: shivammathur/setup-php@v2
  58. with:
  59. php-version: 7.4
  60. coverage: none
  61. tools: cs2pr
  62. - name: Get composer cache directory
  63. id: composer-cache
  64. run: echo "::set-output name=dir::$(composer config cache-files-dir)"
  65. - name: Cache composer dependencies
  66. uses: actions/cache@v2
  67. with:
  68. path: ${{ steps.composer-cache.outputs.dir }}
  69. key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
  70. restore-keys: ${{ runner.os }}-composer-
  71. - name: Install dependencies
  72. run: composer install --no-progress --prefer-dist --optimize-autoloader
  73. - name: Code style with PHP_CodeSniffer
  74. run: ./vendor/bin/phpcs -q --report=checkstyle classes/src/ | cs2pr
  75. versions:
  76. runs-on: ubuntu-latest
  77. steps:
  78. - name: Checkout
  79. uses: actions/checkout@v2
  80. - name: Setup PHP, with composer and extensions
  81. uses: shivammathur/setup-php@v2
  82. with:
  83. php-version: 7.4
  84. coverage: none
  85. tools: cs2pr
  86. - name: Get composer cache directory
  87. id: composer-cache
  88. run: echo "::set-output name=dir::$(composer config cache-files-dir)"
  89. - name: Cache composer dependencies
  90. uses: actions/cache@v2
  91. with:
  92. path: ${{ steps.composer-cache.outputs.dir }}
  93. key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
  94. restore-keys: ${{ runner.os }}-composer-
  95. - name: Install dependencies
  96. run: composer install --no-progress --prefer-dist --optimize-autoloader
  97. - name: Code Version Compatibility check with PHP_CodeSniffer
  98. run: ./vendor/bin/phpcs -q --report-width=200 --report=summary,full classes/src/ --standard=PHPCompatibility --runtime-set testVersion 7.2-
  99. coverage:
  100. runs-on: ubuntu-latest
  101. steps:
  102. - name: Checkout
  103. uses: actions/checkout@v2
  104. - name: Setup PHP, with composer and extensions
  105. uses: shivammathur/setup-php@v2
  106. with:
  107. php-version: 7.4
  108. coverage: pcov
  109. - name: Get composer cache directory
  110. id: composer-cache
  111. run: echo "::set-output name=dir::$(composer config cache-files-dir)"
  112. - name: Cache composer dependencies
  113. uses: actions/cache@v2
  114. with:
  115. path: ${{ steps.composer-cache.outputs.dir }}
  116. key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
  117. restore-keys: ${{ runner.os }}-composer-
  118. - name: Install dependencies
  119. run: composer install --no-progress --prefer-dist --optimize-autoloader
  120. - name: Test Coverage
  121. run: ./vendor/bin/phpunit --verbose --coverage-text