tests.yml 3.2 KB

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