tests.yml 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. # https://help.github.com/en/categories/automating-your-workflow-with-github-actions
  2. # https://github.com/localheinz/php-library-template/blob/master/.github/workflows/continuous-integration.yml
  3. # https://github.com/sebastianbergmann/phpunit/blob/master/.github/workflows/ci.yml
  4. on:
  5. pull_request:
  6. push:
  7. branches:
  8. - master
  9. tags:
  10. - "**"
  11. name: "Continuous Integration"
  12. jobs:
  13. tests:
  14. name: "Unit Tests"
  15. runs-on: ubuntu-latest
  16. strategy:
  17. matrix:
  18. php-binary:
  19. - php7.2
  20. - php7.3
  21. - php7.4
  22. dependencies:
  23. - lowest
  24. - highest
  25. steps:
  26. - name: "Checkout"
  27. uses: actions/checkout@v1.1.0
  28. - name: "Install lowest dependencies with composer"
  29. if: matrix.dependencies == 'lowest'
  30. run: ${{ matrix.php-binary }} $(which composer) update --no-interaction --no-progress --no-suggest --prefer-lowest
  31. - name: "Install highest dependencies with composer"
  32. if: matrix.dependencies == 'highest'
  33. run: ${{ matrix.php-binary }} $(which composer) update --no-interaction --no-progress --no-suggest
  34. - name: "Run unit tests with phpunit"
  35. run: ${{ matrix.php-binary }} vendor/bin/phpunit --configuration=phpunit.xml --no-coverage
  36. code-coverage:
  37. name: "Code Coverage"
  38. runs-on: ubuntu-latest
  39. steps:
  40. - name: "Checkout"
  41. uses: actions/checkout@v1.1.0
  42. - name: "Install locked dependencies with composer"
  43. run: php7.4 $(which composer) install --no-interaction --no-progress --no-suggest
  44. - name: "Dump Xdebug filter with phpunit/phpunit"
  45. run: php7.4 vendor/bin/phpunit --configuration=phpunit.xml --dump-xdebug-filter=.build/phpunit/xdebug-filter.php
  46. - name: "Collect code coverage with Xdebug and phpunit/phpunit"
  47. run: php7.4 vendor/bin/phpunit --configuration=phpunit.xml --prepend=.build/phpunit/xdebug-filter.php
  48. - name: "Send code coverage report to Codecov.io"
  49. env:
  50. CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
  51. run: bash <(curl -s https://codecov.io/bash)