tests.yml 7.1 KB

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