tests.yml 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. name: Tests
  2. on:
  3. push:
  4. branches:
  5. - main
  6. paths:
  7. - 'src/globals/test-extensions.php'
  8. pull_request:
  9. branches: [ "main" ]
  10. paths:
  11. - 'src/**'
  12. - 'config/**'
  13. - '.github/workflows/tests.yml'
  14. - 'bin/**'
  15. - 'composer.json'
  16. - 'box.json'
  17. - '.php-cs-fixer.php'
  18. permissions:
  19. contents: read
  20. env:
  21. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  22. jobs:
  23. php-cs-fixer:
  24. runs-on: ubuntu-latest
  25. timeout-minutes: 10
  26. steps:
  27. - name: "Checkout"
  28. uses: actions/checkout@v4
  29. - name: "Setup PHP"
  30. uses: shivammathur/setup-php@v2
  31. with:
  32. php-version: '8.1'
  33. extensions: curl, openssl, mbstring
  34. ini-values: memory_limit=-1
  35. tools: pecl, composer, php-cs-fixer
  36. - name: Run PHP-CS-Fixer fix
  37. run: php-cs-fixer fix --dry-run --diff --ansi
  38. phpstan:
  39. runs-on: ubuntu-latest
  40. timeout-minutes: 10
  41. steps:
  42. - name: "Checkout"
  43. uses: actions/checkout@v4
  44. - name: "Setup PHP"
  45. uses: shivammathur/setup-php@v2
  46. with:
  47. php-version: '8.1'
  48. extensions: curl, openssl, mbstring
  49. ini-values: memory_limit=-1
  50. tools: composer
  51. - name: "Cache Composer packages"
  52. id: composer-cache
  53. uses: actions/cache@v4
  54. with:
  55. path: vendor
  56. key: ${{ runner.os }}-phpstan-${{ hashFiles('**/composer.lock') }}
  57. restore-keys: |
  58. ${{ runner.os }}-phpstan-
  59. - name: "Install Dependencies"
  60. run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
  61. - name: "Run phpstan"
  62. run: vendor/bin/phpstan analyse
  63. phpunit:
  64. name: "PHPUnit (PHP ${{ matrix.php }})"
  65. runs-on: ubuntu-latest
  66. timeout-minutes: 10
  67. strategy:
  68. matrix:
  69. include:
  70. - php: '8.1'
  71. - php: '8.2'
  72. - php: '8.3'
  73. - php: '8.4'
  74. steps:
  75. - name: "Checkout"
  76. uses: actions/checkout@v4
  77. - name: "Setup PHP"
  78. uses: shivammathur/setup-php@v2
  79. with:
  80. php-version: "${{ matrix.php }}"
  81. tools: pecl, composer
  82. extensions: curl, openssl, mbstring
  83. ini-values: memory_limit=-1
  84. - name: "Cache Composer packages"
  85. id: composer-cache
  86. uses: actions/cache@v4
  87. with:
  88. path: vendor
  89. key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
  90. restore-keys: |
  91. ${{ runner.os }}-php-
  92. - name: "Install Dependencies"
  93. run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
  94. - name: "Run PHPUnit Tests"
  95. run: |
  96. SPC_NO_MUSL_PATH=yes vendor/bin/phpunit tests/ --no-coverage
  97. define-matrix:
  98. name: "Define Matrix"
  99. runs-on: ubuntu-latest
  100. outputs:
  101. php: ${{ steps.gendef.outputs.php }}
  102. os: ${{ steps.gendef.outputs.os }}
  103. steps:
  104. - name: "Checkout"
  105. uses: actions/checkout@v4
  106. - name: "Setup PHP"
  107. uses: shivammathur/setup-php@v2
  108. with:
  109. php-version: 8.2
  110. - name: Define
  111. id: gendef
  112. run: |
  113. PHP_VERSIONS=$(php src/globals/test-extensions.php php)
  114. OS_VERSIONS=$(php src/globals/test-extensions.php os)
  115. echo 'php='"$PHP_VERSIONS" >> "$GITHUB_OUTPUT"
  116. echo 'os='"$OS_VERSIONS" >> "$GITHUB_OUTPUT"
  117. build:
  118. name: "Build PHP Test (PHP ${{ matrix.php }} ${{ matrix.os }})"
  119. runs-on: ${{ matrix.os }}
  120. needs: define-matrix
  121. timeout-minutes: 120
  122. strategy:
  123. matrix:
  124. php: ${{ fromJSON(needs.define-matrix.outputs.php) }}
  125. os: ${{ fromJSON(needs.define-matrix.outputs.os) }}
  126. fail-fast: false
  127. steps:
  128. - name: "Checkout"
  129. uses: actions/checkout@v4
  130. - name: "Setup PHP"
  131. uses: shivammathur/setup-php@v2
  132. with:
  133. php-version: 8.2
  134. tools: pecl, composer
  135. extensions: curl, openssl, mbstring
  136. ini-values: memory_limit=-1
  137. env:
  138. phpts: nts
  139. - name: "Cache composer packages"
  140. id: composer-cache
  141. uses: actions/cache@v4
  142. with:
  143. path: vendor
  144. key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
  145. restore-keys: |
  146. ${{ runner.os }}-php-
  147. # Cache downloaded source
  148. - id: cache-download
  149. uses: actions/cache@v4
  150. with:
  151. path: downloads
  152. key: php-dependencies-${{ matrix.os }}
  153. - name: "Install Dependencies"
  154. run: composer update -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
  155. - name: "Run Build Tests (doctor)"
  156. run: bin/spc doctor --auto-fix --debug
  157. - name: "Prepare UPX for Windows"
  158. if: matrix.os == 'windows-latest'
  159. run: |
  160. bin/spc install-pkg upx
  161. echo "UPX_CMD=$(php src/globals/test-extensions.php upx)" >> $env:GITHUB_ENV
  162. - name: "Prepare UPX for Linux"
  163. if: matrix.os == 'ubunut-latest'
  164. run: |
  165. bin/spc install-pkg upx
  166. echo "UPX_CMD=$(php src/globals/test-extensions.php upx)" >> $GITHUB_ENV
  167. - name: "Run Build Tests (download)"
  168. run: php src/globals/test-extensions.php download_cmd ${{ matrix.os }} ${{ matrix.php }}
  169. - name: "Run Build Tests (build)"
  170. run: php src/globals/test-extensions.php build_cmd ${{ matrix.os }} ${{ matrix.php }}
  171. - name: "Run Build Tests (build - embed for non-windows)"
  172. if: matrix.os != 'windows-latest'
  173. run: php src/globals/test-extensions.php build_embed_cmd ${{ matrix.os }} ${{ matrix.php }}