tests.yml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. name: Tests
  2. on:
  3. push:
  4. workflow_dispatch:
  5. jobs:
  6. Composer:
  7. runs-on: ubuntu-latest
  8. # https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs#handling-failures
  9. continue-on-error: "${{ matrix.experimental }}"
  10. steps:
  11. - name: Checkout
  12. uses: actions/checkout@v4
  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 on ${{ matrix.operating-system }}
  19. runs-on: ubuntu-latest
  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']
  24. experimental: [false]
  25. include:
  26. - php-versions: '8.4' # 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. Mocha:
  96. runs-on: ubuntu-latest
  97. steps:
  98. - name: Checkout
  99. uses: actions/checkout@v4
  100. - name: Setup Node
  101. uses: actions/setup-node@v4
  102. with:
  103. node-version: '20'
  104. cache: 'npm'
  105. cache-dependency-path: 'js/package-lock.json'
  106. - name: Setup Mocha
  107. run: npm install -g mocha
  108. - name: Setup Node modules
  109. run: npm ci
  110. working-directory: js
  111. - name: Run unit tests
  112. run: npm run ci-test
  113. working-directory: js
  114. - name: Upload Test Results
  115. if: always()
  116. uses: actions/upload-artifact@v4
  117. with:
  118. name: Test Results (Mocha)
  119. path: js/mocha-results.xml
  120. event_file:
  121. name: "Event File"
  122. runs-on: ubuntu-latest
  123. steps:
  124. - name: Upload
  125. uses: actions/upload-artifact@v4
  126. with:
  127. name: Event File
  128. path: "${{ github.event_path }}"