1
0

tests.yml 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. name: Tests
  2. on:
  3. push:
  4. pull_request:
  5. branches: [ master ]
  6. workflow_dispatch:
  7. permissions: {}
  8. jobs:
  9. Composer:
  10. runs-on: ubuntu-latest
  11. steps:
  12. - name: Checkout
  13. uses: actions/checkout@v7
  14. with:
  15. persist-credentials: false
  16. - name: Validate composer.json and composer.lock
  17. run: composer validate
  18. - name: Install dependencies
  19. run: composer install --prefer-dist --no-dev
  20. PHPunit:
  21. name: PHP ${{ matrix.php-versions }} unit tests
  22. runs-on: ubuntu-latest
  23. # https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs#handling-failures
  24. continue-on-error: "${{ matrix.experimental }}"
  25. strategy:
  26. matrix:
  27. php-versions: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5']
  28. experimental: [false]
  29. include:
  30. - php-versions: '8.6' # development release, things can break
  31. experimental: true
  32. env:
  33. extensions: gd, sqlite3
  34. extensions-cache-key-name: phpextensions
  35. steps:
  36. # let's get started!
  37. - name: Checkout
  38. uses: actions/checkout@v7
  39. with:
  40. persist-credentials: false
  41. # cache PHP extensions
  42. - name: Setup cache environment
  43. id: extcache
  44. uses: shivammathur/cache-extensions@v1
  45. with:
  46. php-version: ${{ matrix.php-versions }}
  47. extensions: ${{ env.extensions }}
  48. key: ${{ runner.os }}-${{ env.extensions-cache-key }}
  49. - name: Cache extensions
  50. uses: actions/cache@v6
  51. with:
  52. path: ${{ steps.extcache.outputs.dir }}
  53. key: ${{ steps.extcache.outputs.key }}
  54. restore-keys: ${{ runner.os }}-${{ env.extensions-cache-key }}
  55. - name: Setup PHP
  56. uses: shivammathur/setup-php@v2
  57. with:
  58. php-version: ${{ matrix.php-versions }}
  59. extensions: ${{ env.extensions }}
  60. # Setup GitHub CI PHP problem matchers
  61. # https://github.com/shivammathur/setup-php#problem-matchers
  62. - name: Setup problem matchers for PHP
  63. run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
  64. - name: Setup problem matchers for PHPUnit
  65. run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
  66. # composer cache
  67. - name: Remove composer lock
  68. run: rm composer.lock
  69. - name: Get composer cache directory
  70. id: composer-cache
  71. run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
  72. # http://man7.org/linux/man-pages/man1/date.1.html
  73. # https://github.com/actions/cache#creating-a-cache-key
  74. - name: Get Date
  75. id: get-date
  76. run: echo "date=$(/bin/date -u "+%Y%m%d")" >> $GITHUB_OUTPUT
  77. shell: bash
  78. - name: Cache dependencies
  79. uses: actions/cache@v6
  80. with:
  81. path: "${{ steps.composer-cache.outputs.dir }}"
  82. key: "${{ runner.os }}-composer-${{ steps.get-date.outputs.date }}-${{ hashFiles('**/composer.json') }}"
  83. restore-keys: "${{ runner.os }}-composer-${{ steps.get-date.outputs.date }}-"
  84. # composer installation
  85. - name: Unset platform requirement
  86. run: composer config --unset platform
  87. - name: Setup PHPunit
  88. run: composer install -n
  89. - name: Install Google Cloud Storage
  90. run: composer require google/cloud-storage
  91. # testing
  92. - name: Run unit tests
  93. run: ../vendor/bin/phpunit --no-coverage --log-junit results.xml
  94. working-directory: tst
  95. - name: Upload Test Results
  96. if: always()
  97. uses: actions/upload-artifact@v7
  98. with:
  99. name: Test Results (PHP ${{ matrix.php-versions }})
  100. path: tst/results.xml
  101. PHPunitConfigCombinations:
  102. name: PHP configuration combination unit tests
  103. runs-on: ubuntu-latest
  104. env:
  105. php-version: '8.5'
  106. extensions: gd, sqlite3
  107. extensions-cache-key-name: phpextensions
  108. steps:
  109. # let's get started!
  110. - name: Checkout
  111. uses: actions/checkout@v7
  112. with:
  113. persist-credentials: false
  114. # cache PHP extensions
  115. - name: Setup cache environment
  116. id: extcache
  117. uses: shivammathur/cache-extensions@v1
  118. with:
  119. php-version: ${{ env.php-version }}
  120. extensions: ${{ env.extensions }}
  121. key: ${{ runner.os }}-${{ env.extensions-cache-key }}
  122. - name: Cache extensions
  123. uses: actions/cache@v6
  124. with:
  125. path: ${{ steps.extcache.outputs.dir }}
  126. key: ${{ steps.extcache.outputs.key }}
  127. restore-keys: ${{ runner.os }}-${{ env.extensions-cache-key }}
  128. - name: Setup PHP
  129. uses: shivammathur/setup-php@v2
  130. with:
  131. php-version: ${{ env.php-version }}
  132. extensions: ${{ env.extensions }}
  133. # Setup GitHub CI PHP problem matchers
  134. # https://github.com/shivammathur/setup-php#problem-matchers
  135. - name: Setup problem matchers for PHP
  136. run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
  137. - name: Setup problem matchers for PHPUnit
  138. run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
  139. # composer cache
  140. - name: Remove composer lock
  141. run: rm composer.lock
  142. - name: Get composer cache directory
  143. id: composer-cache
  144. run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
  145. # http://man7.org/linux/man-pages/man1/date.1.html
  146. # https://github.com/actions/cache#creating-a-cache-key
  147. - name: Get Date
  148. id: get-date
  149. run: echo "date=$(/bin/date -u "+%Y%m%d")" >> $GITHUB_OUTPUT
  150. shell: bash
  151. - name: Cache dependencies
  152. uses: actions/cache@v6
  153. with:
  154. path: "${{ steps.composer-cache.outputs.dir }}"
  155. key: "${{ runner.os }}-composer-${{ steps.get-date.outputs.date }}-${{ hashFiles('**/composer.json') }}"
  156. restore-keys: "${{ runner.os }}-composer-${{ steps.get-date.outputs.date }}-"
  157. # composer installation
  158. - name: Unset platform requirement
  159. run: composer config --unset platform
  160. - name: Setup PHPunit
  161. run: composer install -n
  162. - name: Install Google Cloud Storage
  163. run: composer require google/cloud-storage
  164. # testing
  165. - name: Generate configuration combination unit tests
  166. run: bin/configuration-test-generator
  167. - name: Run unit tests
  168. run: ../vendor/bin/phpunit --no-coverage --log-junit results.xml ConfigurationCombinationsTest.php
  169. working-directory: tst
  170. - name: Upload Test Results
  171. if: always()
  172. uses: actions/upload-artifact@v7
  173. with:
  174. name: Test Results
  175. path: tst/results.xml
  176. Mocha:
  177. runs-on: ubuntu-latest
  178. steps:
  179. - name: Checkout
  180. uses: actions/checkout@v7
  181. with:
  182. persist-credentials: false
  183. - name: Setup Node
  184. uses: actions/setup-node@v7
  185. with:
  186. node-version: '22'
  187. cache: 'npm'
  188. cache-dependency-path: 'js/package-lock.json'
  189. - name: Setup Mocha
  190. run: npm install -g mocha
  191. - name: Setup Node modules
  192. run: npm ci
  193. working-directory: js
  194. - name: Run unit tests
  195. run: npm run ci-test
  196. working-directory: js
  197. - name: Upload Test Results
  198. if: always()
  199. uses: actions/upload-artifact@v7
  200. with:
  201. name: Test Results (Mocha)
  202. path: js/mocha-results.xml
  203. event_file:
  204. name: "Event File"
  205. runs-on: ubuntu-latest
  206. steps:
  207. - name: Upload
  208. uses: actions/upload-artifact@v7
  209. with:
  210. name: Event File
  211. path: "${{ github.event_path }}"