tests.yml 7.0 KB

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