tests.yml 3.3 KB

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