tests.yml 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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 on ${{ matrix.operating-system }}
  17. runs-on: ubuntu-latest
  18. continue-on-error: ${{ matrix.experimental }}
  19. strategy:
  20. matrix:
  21. php-versions: ['7.3', '7.4', '8.0', '8.1', '8.2', '8.3']
  22. experimental: [false]
  23. include:
  24. - php-versions: '8.4' # development release, things can break
  25. experimental: true
  26. env:
  27. extensions: gd, sqlite3
  28. extensions-cache-key-name: phpextensions
  29. steps:
  30. # let's get started!
  31. - name: Checkout
  32. uses: actions/checkout@v4
  33. # cache PHP extensions
  34. - name: Setup cache environment
  35. id: extcache
  36. uses: shivammathur/cache-extensions@v1
  37. with:
  38. php-version: ${{ matrix.php-versions }}
  39. extensions: ${{ env.extensions }}
  40. key: ${{ runner.os }}-${{ env.extensions-cache-key }}
  41. - name: Cache extensions
  42. uses: actions/cache@v4
  43. with:
  44. path: ${{ steps.extcache.outputs.dir }}
  45. key: ${{ steps.extcache.outputs.key }}
  46. restore-keys: ${{ runner.os }}-${{ env.extensions-cache-key }}
  47. - name: Setup PHP
  48. uses: shivammathur/setup-php@v2
  49. with:
  50. php-version: ${{ matrix.php-versions }}
  51. extensions: ${{ env.extensions }}
  52. # Setup GitHub CI PHP problem matchers
  53. # https://github.com/shivammathur/setup-php#problem-matchers
  54. - name: Setup problem matchers for PHP
  55. run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
  56. - name: Setup problem matchers for PHPUnit
  57. run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
  58. # composer cache
  59. - name: Remove composer lock
  60. run: rm composer.lock
  61. - name: Get composer cache directory
  62. id: composer-cache
  63. run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
  64. # http://man7.org/linux/man-pages/man1/date.1.html
  65. # https://github.com/actions/cache#creating-a-cache-key
  66. - name: Get Date
  67. id: get-date
  68. run: echo "date=$(/bin/date -u "+%Y%m%d")" >> $GITHUB_OUTPUT
  69. shell: bash
  70. - name: Cache dependencies
  71. uses: actions/cache@v4
  72. with:
  73. path: ${{ steps.composer-cache.outputs.dir }}
  74. key: ${{ runner.os }}-composer-${{ steps.get-date.outputs.date }}-${{ hashFiles('**/composer.json') }}
  75. restore-keys: ${{ runner.os }}-composer-${{ steps.get-date.outputs.date }}-
  76. # composer installation
  77. - name: Setup PHPunit
  78. run: composer install -n
  79. - name: Install Google Cloud Storage
  80. run: composer require google/cloud-storage
  81. # testing
  82. - name: Run unit tests
  83. run: ../vendor/bin/phpunit --no-coverage
  84. working-directory: tst
  85. Mocha:
  86. runs-on: ubuntu-latest
  87. steps:
  88. - name: Checkout
  89. uses: actions/checkout@v4
  90. - name: Setup Node
  91. uses: actions/setup-node@v4
  92. with:
  93. node-version: '20'
  94. cache: 'npm'
  95. cache-dependency-path: 'js/package-lock.json'
  96. - name: Setup Mocha
  97. run: npm install -g mocha
  98. - name: Setup Node modules
  99. run: npm ci
  100. working-directory: js
  101. - name: Run unit tests
  102. run: npm test
  103. working-directory: js