tests.yml 7.0 KB

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