ci.yml 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. name: "Continuous Integration"
  2. on:
  3. push:
  4. paths-ignore:
  5. - 'README.md'
  6. pull_request:
  7. paths-ignore:
  8. - 'README.md'
  9. env:
  10. COMPOSER_FLAGS: "--ansi --no-interaction --no-progress --prefer-dist"
  11. COVERAGE_FLAGS: "--coverage-text --coverage-clover build/logs/clover.xml"
  12. jobs:
  13. tests:
  14. name: PHP ${{ matrix.php-version }}
  15. runs-on: ubuntu-latest
  16. strategy:
  17. matrix:
  18. php-version:
  19. - "7.2"
  20. - "7.3"
  21. - "7.4"
  22. - "8.0"
  23. - "8.1"
  24. - "8.2"
  25. include:
  26. - php-version: 8.1
  27. coverage: coverage
  28. steps:
  29. - name: Checkout
  30. uses: actions/checkout@v2
  31. - name: Setup PHP, with composer and extensions
  32. uses: shivammathur/setup-php@v2
  33. with:
  34. php-version: ${{ matrix.php-version }}
  35. extensions: dom
  36. coverage: xdebug
  37. env:
  38. update: true
  39. COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  40. - name: Setup Problem Matchers for PHPUnit
  41. run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
  42. - name: Get composer cache directory
  43. id: composer-cache
  44. run: echo "::set-output name=dir::$(composer config cache-files-dir)"
  45. - name: Cache composer dependencies
  46. uses: actions/cache@v1
  47. with:
  48. path: ${{ steps.composer-cache.outputs.dir }}
  49. key: ${{ matrix.php-version }}-composer-${{ hashFiles('**/composer.json') }}
  50. restore-keys: ${{ matrix.php-version }}-composer-
  51. - name: Install Composer
  52. uses: nick-invision/retry@v1
  53. with:
  54. timeout_minutes: 10
  55. max_attempts: 3
  56. command: composer update ${{ env.COMPOSER_FLAGS }}
  57. - name: composer validate
  58. run: composer validate --strict
  59. - name: Test with phpunit (with coverage)
  60. id: phpunit-coverage
  61. if: "matrix.coverage == 'coverage'"
  62. run: composer run test -- --verbose ${{ env.COVERAGE_FLAGS }}
  63. - name: Test with phpunit (without coverage)
  64. if: "matrix.coverage != 'coverage'"
  65. run: composer run test -- --verbose
  66. - name: Submit Coveralls
  67. if: steps.phpunit-coverage.outcome == 'success'
  68. uses: nick-invision/retry@v1
  69. with:
  70. timeout_minutes: 10
  71. max_attempts: 3
  72. command: |
  73. [[ -f vendor/bin/php-coveralls ]] && COVERALLS_PATH=vendor/bin/php-coveralls || COVERALLS_PATH=vendor/bin/coveralls
  74. [[ -n $COVERALLS_REPO_TOKEN ]] && php $COVERALLS_PATH -v --exclude-no-stmt || true
  75. env:
  76. COVERALLS_RUN_LOCALLY: 1
  77. COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}