main.yml 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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. - '8.1'
  16. - '8.2'
  17. include:
  18. - php-version: 'nightly'
  19. experimental: true
  20. name: PHP ${{ matrix.php-version }}
  21. steps:
  22. - name: Checkout
  23. uses: actions/checkout@v3
  24. - name: Setup PHP, with composer and extensions
  25. uses: shivammathur/setup-php@v2
  26. with:
  27. php-version: ${{ matrix.php-version }}
  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: "Run PHPUnit tests (Experimental: ${{ matrix.experimental }})"
  51. env:
  52. FAILURE_ACTION: "${{ matrix.experimental == true }}"
  53. run: vendor/bin/phpunit --verbose || $FAILURE_ACTION
  54. phpcs:
  55. runs-on: ubuntu-latest
  56. steps:
  57. - name: Checkout
  58. uses: actions/checkout@v3
  59. - name: Setup PHP, with composer and extensions
  60. uses: shivammathur/setup-php@v2
  61. with:
  62. php-version: 7.4
  63. coverage: none
  64. tools: cs2pr
  65. - name: Get composer cache directory
  66. id: composer-cache
  67. run: echo "::set-output name=dir::$(composer config cache-files-dir)"
  68. - name: Cache composer dependencies
  69. uses: actions/cache@v3
  70. with:
  71. path: ${{ steps.composer-cache.outputs.dir }}
  72. key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
  73. restore-keys: ${{ runner.os }}-composer-
  74. - name: Install dependencies
  75. run: composer install --no-progress --prefer-dist --optimize-autoloader
  76. - name: Code style with PHP_CodeSniffer
  77. run: ./vendor/bin/phpcs -q --report=checkstyle classes/src/ | cs2pr
  78. versions:
  79. runs-on: ubuntu-latest
  80. steps:
  81. - name: Checkout
  82. uses: actions/checkout@v3
  83. - name: Setup PHP, with composer and extensions
  84. uses: shivammathur/setup-php@v2
  85. with:
  86. php-version: 7.4
  87. coverage: none
  88. tools: cs2pr
  89. - name: Get composer cache directory
  90. id: composer-cache
  91. run: echo "::set-output name=dir::$(composer config cache-files-dir)"
  92. - name: Cache composer dependencies
  93. uses: actions/cache@v3
  94. with:
  95. path: ${{ steps.composer-cache.outputs.dir }}
  96. key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
  97. restore-keys: ${{ runner.os }}-composer-
  98. - name: Install dependencies
  99. run: composer install --no-progress --prefer-dist --optimize-autoloader
  100. - name: Code Version Compatibility check with PHP_CodeSniffer
  101. run: ./vendor/bin/phpcs -q --report-width=200 --report=summary,full classes/src/ --standard=PHPCompatibility --runtime-set testVersion 7.2-
  102. coverage:
  103. runs-on: ubuntu-latest
  104. steps:
  105. - name: Checkout
  106. uses: actions/checkout@v3
  107. - name: Setup PHP, with composer and extensions
  108. uses: shivammathur/setup-php@v2
  109. with:
  110. php-version: 7.4
  111. coverage: pcov
  112. - name: Get composer cache directory
  113. id: composer-cache
  114. run: echo "::set-output name=dir::$(composer config cache-files-dir)"
  115. - name: Cache composer dependencies
  116. uses: actions/cache@v3
  117. with:
  118. path: ${{ steps.composer-cache.outputs.dir }}
  119. key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
  120. restore-keys: ${{ runner.os }}-composer-
  121. - name: Install dependencies
  122. run: composer install --no-progress --prefer-dist --optimize-autoloader
  123. - name: Test Coverage
  124. run: ./vendor/bin/phpunit --verbose --coverage-text