tests.yml 7.1 KB

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