tests.yml 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. name: Tests
  2. on: [push]
  3. jobs:
  4. Composer:
  5. runs-on: ubuntu-latest
  6. steps:
  7. - name: Checkout
  8. uses: actions/checkout@v2
  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@v2
  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@v2
  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. # composer cache
  46. - name: Remove composer lock
  47. run: rm composer.lock
  48. - name: Get composer cache directory
  49. id: composer-cache
  50. run: echo "::set-output name=dir::$(composer config cache-files-dir)"
  51. # http://man7.org/linux/man-pages/man1/date.1.html
  52. # https://github.com/actions/cache#creating-a-cache-key
  53. - name: Get Date
  54. id: get-date
  55. run: |
  56. echo "::set-output name=date::$(/bin/date -u "+%Y%m%d")"
  57. shell: bash
  58. - name: Cache dependencies
  59. uses: actions/cache@v2
  60. with:
  61. path: ${{ steps.composer-cache.outputs.dir }}
  62. key: ${{ runner.os }}-composer-${{ steps.get-date.outputs.date }}-${{ hashFiles('**/composer.json') }}
  63. restore-keys: ${{ runner.os }}-composer-${{ steps.get-date.outputs.date }}-
  64. # composer installation
  65. - name: Setup PHPunit
  66. run: composer install -n
  67. - name: Install Google Cloud Storage
  68. run: composer require google/cloud-storage
  69. # testing
  70. - name: Run unit tests
  71. run: ../vendor/bin/phpunit --no-coverage
  72. working-directory: tst
  73. Mocha:
  74. runs-on: ubuntu-latest
  75. steps:
  76. - name: Checkout
  77. uses: actions/checkout@v2
  78. - name: Setup Node
  79. uses: actions/setup-node@v2
  80. with:
  81. node-version: '12'
  82. cache: 'npm'
  83. cache-dependency-path: 'js/package.json'
  84. - name: Setup Mocha
  85. run: npm install -g mocha
  86. - name: Setup Node modules
  87. run: npm install
  88. working-directory: js
  89. - name: Run unit tests
  90. run: mocha
  91. working-directory: js