tests.yml 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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. permissions:
  11. contents: read
  12. jobs:
  13. php-cs-fixer:
  14. runs-on: ubuntu-latest
  15. timeout-minutes: 10
  16. steps:
  17. - name: "Checkout"
  18. uses: actions/checkout@v4
  19. - name: "Setup PHP"
  20. uses: shivammathur/setup-php@v2
  21. with:
  22. php-version: '8.1'
  23. extensions: curl, openssl, mbstring
  24. ini-values: memory_limit=-1
  25. tools: pecl, composer, php-cs-fixer
  26. - name: Run PHP-CS-Fixer fix
  27. run: php-cs-fixer fix --dry-run --diff --ansi
  28. phpstan:
  29. runs-on: ubuntu-latest
  30. timeout-minutes: 10
  31. steps:
  32. - name: "Checkout"
  33. uses: actions/checkout@v4
  34. - name: "Setup PHP"
  35. uses: shivammathur/setup-php@v2
  36. with:
  37. php-version: '8.1'
  38. extensions: curl, openssl, mbstring
  39. ini-values: memory_limit=-1
  40. tools: composer
  41. - name: "Cache Composer packages"
  42. id: composer-cache
  43. uses: actions/cache@v3
  44. with:
  45. path: vendor
  46. key: ${{ runner.os }}-phpstan-${{ hashFiles('**/composer.lock') }}
  47. restore-keys: |
  48. ${{ runner.os }}-phpstan-
  49. - name: "Install Dependencies"
  50. run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
  51. - name: "Run phpstan"
  52. run: vendor/bin/phpstan analyse
  53. phpunit:
  54. name: "PHPUnit (PHP ${{ matrix.php }})"
  55. runs-on: ubuntu-latest
  56. timeout-minutes: 10
  57. strategy:
  58. matrix:
  59. include:
  60. - php: '8.1'
  61. - php: '8.2'
  62. - php: '8.3'
  63. steps:
  64. - name: "Checkout"
  65. uses: actions/checkout@v4
  66. - name: "Setup PHP"
  67. uses: shivammathur/setup-php@v2
  68. with:
  69. php-version: "${{ matrix.php }}"
  70. tools: pecl, composer
  71. extensions: curl, openssl, mbstring
  72. ini-values: memory_limit=-1
  73. - name: "Cache Composer packages"
  74. id: composer-cache
  75. uses: actions/cache@v3
  76. with:
  77. path: vendor
  78. key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
  79. restore-keys: |
  80. ${{ runner.os }}-php-
  81. - name: "Install Dependencies"
  82. run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
  83. - name: "Run PHPUnit Tests"
  84. run: |
  85. vendor/bin/phpunit tests/ --no-coverage
  86. build:
  87. name: "Build PHP Test (PHP ${{ matrix.php }} ${{ matrix.os }})"
  88. runs-on: ${{ matrix.os }}
  89. timeout-minutes: 120
  90. strategy:
  91. matrix:
  92. php:
  93. - "8.0"
  94. - "8.1"
  95. - "8.2"
  96. - "8.3"
  97. os:
  98. - ubuntu-latest
  99. - macos-latest
  100. - windows-latest
  101. - macos-14
  102. fail-fast: false
  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. tools: pecl, composer
  111. extensions: curl, openssl, mbstring
  112. ini-values: memory_limit=-1
  113. - name: "Use test token if exists"
  114. if: matrix.os != 'windows-latest'
  115. run: |
  116. if [ "${{ secrets.TEST_GH_TOKEN }}" != "" ]; then
  117. echo "GITHUB_TOKEN=${{ secrets.TEST_GH_TOKEN }}" >> $GITHUB_ENV
  118. fi
  119. - name: "Cache Composer packages"
  120. id: composer-cache
  121. uses: actions/cache@v3
  122. with:
  123. path: vendor
  124. key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
  125. restore-keys: |
  126. ${{ runner.os }}-php-
  127. # Cache downloaded source
  128. - id: cache-download
  129. uses: actions/cache@v3
  130. with:
  131. path: downloads
  132. key: php-${{ matrix.php }}-dependencies
  133. - name: "Install Dependencies"
  134. run: composer update -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
  135. - name: "Run Build Tests (doctor)"
  136. run: bin/spc doctor --auto-fix
  137. - name: "Run Build Tests (download)"
  138. uses: nick-fields/retry@v3
  139. with:
  140. timeout_minutes: 10
  141. max_attempts: 3
  142. retry_on: error
  143. command: |
  144. bin/spc download --for-extensions="$(php src/globals/test-extensions.php extensions)" --for-libs="$(php src/globals/test-extensions.php libs)" --with-php=${{ matrix.php }} --ignore-cache-sources=php-src --debug
  145. - name: "Run Build Tests (build)"
  146. run: bin/spc build "$(php src/globals/test-extensions.php extensions)" --with-libs="$(php src/globals/test-extensions.php libs)" --build-cli --build-micro --build-fpm --debug