tests.yml 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. # 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 "::set-output name=dir::$(composer config cache-files-dir)"
  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: |
  62. echo "::set-output name=date::$(/bin/date -u "+%Y%m%d")"
  63. shell: bash
  64. - name: Cache dependencies
  65. uses: actions/cache@v2
  66. with:
  67. path: ${{ steps.composer-cache.outputs.dir }}
  68. key: ${{ runner.os }}-composer-${{ steps.get-date.outputs.date }}-${{ hashFiles('**/composer.json') }}
  69. restore-keys: ${{ runner.os }}-composer-${{ steps.get-date.outputs.date }}-
  70. # composer installation
  71. - name: Setup PHPunit
  72. run: composer install -n
  73. - name: Install Google Cloud Storage
  74. run: composer require google/cloud-storage
  75. # testing
  76. - name: Run unit tests
  77. run: ../vendor/bin/phpunit --no-coverage
  78. working-directory: tst
  79. Mocha:
  80. runs-on: ubuntu-latest
  81. steps:
  82. - name: Checkout
  83. uses: actions/checkout@v2
  84. - name: Setup Node
  85. uses: actions/setup-node@v2
  86. with:
  87. node-version: '12'
  88. cache: 'npm'
  89. cache-dependency-path: 'js/package.json'
  90. - name: Setup Mocha
  91. run: npm install -g mocha
  92. - name: Setup Node modules
  93. run: npm install
  94. working-directory: js
  95. - name: Run unit tests
  96. run: mocha
  97. working-directory: js