tests.yml 7.2 KB

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