ci.yml 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. - "8.3"
  26. include:
  27. - php-version: 8.2
  28. coverage: coverage
  29. steps:
  30. - name: Checkout
  31. uses: actions/checkout@v2
  32. - name: Setup PHP, with composer and extensions
  33. uses: shivammathur/setup-php@v2
  34. with:
  35. php-version: ${{ matrix.php-version }}
  36. extensions: dom
  37. coverage: xdebug
  38. env:
  39. update: true
  40. COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  41. - name: Setup Problem Matchers for PHPUnit
  42. run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
  43. - name: Get composer cache directory
  44. id: composer-cache
  45. run: echo "::set-output name=dir::$(composer config cache-files-dir)"
  46. - name: Cache composer dependencies
  47. uses: actions/cache@v1
  48. with:
  49. path: ${{ steps.composer-cache.outputs.dir }}
  50. key: ${{ matrix.php-version }}-composer-${{ hashFiles('**/composer.json') }}
  51. restore-keys: ${{ matrix.php-version }}-composer-
  52. - name: Install Composer
  53. uses: nick-invision/retry@v1
  54. with:
  55. timeout_minutes: 10
  56. max_attempts: 3
  57. command: composer update ${{ env.COMPOSER_FLAGS }}
  58. - name: composer validate
  59. run: composer validate --strict
  60. - name: Test with phpunit (with coverage)
  61. id: phpunit-coverage
  62. if: "matrix.coverage == 'coverage'"
  63. run: composer run test -- --verbose ${{ env.COVERAGE_FLAGS }}
  64. - name: Test with phpunit (without coverage)
  65. if: "matrix.coverage != 'coverage'"
  66. run: composer run test -- --verbose
  67. - name: Submit Coveralls
  68. if: steps.phpunit-coverage.outcome == 'success'
  69. uses: nick-invision/retry@v1
  70. with:
  71. timeout_minutes: 10
  72. max_attempts: 3
  73. command: |
  74. [[ -f vendor/bin/php-coveralls ]] && COVERALLS_PATH=vendor/bin/php-coveralls || COVERALLS_PATH=vendor/bin/coveralls
  75. [[ -n $COVERALLS_REPO_TOKEN ]] && php $COVERALLS_PATH -v --exclude-no-stmt || true
  76. env:
  77. COVERALLS_RUN_LOCALLY: 1
  78. COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}