tests.yml 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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: Setup PHPunit
  80. run: composer install -n
  81. - name: Install Google Cloud Storage
  82. run: composer require google/cloud-storage
  83. # testing
  84. - name: Run unit tests
  85. run: ../vendor/bin/phpunit --no-coverage --log-junit results.xml
  86. working-directory: tst
  87. - name: Upload Test Results
  88. if: always()
  89. uses: actions/upload-artifact@v4
  90. with:
  91. name: Test Results (PHP ${{ matrix.php-versions }})
  92. path: tst/results.xml
  93. Mocha:
  94. runs-on: ubuntu-latest
  95. steps:
  96. - name: Checkout
  97. uses: actions/checkout@v4
  98. - name: Setup Node
  99. uses: actions/setup-node@v4
  100. with:
  101. node-version: '20'
  102. cache: 'npm'
  103. cache-dependency-path: 'js/package-lock.json'
  104. - name: Setup Mocha
  105. run: npm install -g mocha
  106. - name: Setup Node modules
  107. run: npm ci
  108. working-directory: js
  109. - name: Run unit tests
  110. run: npm run ci-test
  111. working-directory: js
  112. - name: Upload Test Results
  113. if: always()
  114. uses: actions/upload-artifact@v4
  115. with:
  116. name: Test Results (Mocha)
  117. path: js/mocha-results.xml
  118. event_file:
  119. name: "Event File"
  120. runs-on: ubuntu-latest
  121. steps:
  122. - name: Upload
  123. uses: actions/upload-artifact@v4
  124. with:
  125. name: Event File
  126. path: ${{ github.event_path }}