tests.yml 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. # https://help.github.com/en/categories/automating-your-workflow-with-github-actions
  2. # https://github.com/sebastianbergmann/phpunit/blob/master/.github/workflows/ci.yml
  3. on:
  4. - pull_request
  5. - push
  6. name: "Continuous Integration"
  7. jobs:
  8. static-code-analysis:
  9. name: "Static Code Analysis"
  10. runs-on: ubuntu-latest
  11. steps:
  12. - name: "Checkout"
  13. uses: actions/checkout@v2
  14. - name: "Install PHP"
  15. uses: shivammathur/setup-php@v2
  16. with:
  17. php-version: "7.4"
  18. coverage: none
  19. tools: pecl
  20. extensions: ast, gd, imagick, json, mbstring
  21. # ini-values:
  22. - name: "Update dependencies with composer"
  23. run: composer update --no-interaction --no-ansi --no-progress --no-suggest
  24. - name: "phan env"
  25. run: |
  26. echo "PHAN_ALLOW_XDEBUG=0" >> $GITHUB_ENV
  27. echo "PHAN_DISABLE_XDEBUG_WARN=1" >> $GITHUB_ENV
  28. - name: "Run phan"
  29. run: php vendor/bin/phan
  30. tests:
  31. name: "Unit Tests"
  32. runs-on: ${{ matrix.os }}
  33. strategy:
  34. fail-fast: false
  35. matrix:
  36. os:
  37. - ubuntu-latest
  38. - windows-latest
  39. php-version:
  40. - "7.4"
  41. - "8.0"
  42. steps:
  43. - name: "Configure git to avoid issues with line endings"
  44. if: matrix.os == 'windows-latest'
  45. run: git config --global core.autocrlf false
  46. - name: "Checkout"
  47. uses: actions/checkout@v2
  48. - name: "Install PHP with extensions"
  49. uses: shivammathur/setup-php@v2
  50. with:
  51. php-version: ${{ matrix.php-version }}
  52. coverage: pcov
  53. tools: pecl
  54. extensions: gd, imagick, json, mbstring
  55. # ini-values:
  56. - name: "Determine composer cache directory on Linux"
  57. if: matrix.os == 'ubuntu-latest'
  58. run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV
  59. - name: "Determine composer cache directory on Windows"
  60. if: matrix.os == 'windows-latest'
  61. run: echo "COMPOSER_CACHE_DIR=%LOCALAPPDATA%\Composer" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
  62. - name: "Cache dependencies installed with composer"
  63. uses: actions/cache@v2
  64. with:
  65. path: ${{ env.COMPOSER_CACHE_DIR }}
  66. key: php${{ matrix.php-version }}-composer-${{ hashFiles('**/composer.json') }}
  67. restore-keys: php${{ matrix.php-version }}-composer-
  68. - name: "Install dependencies with composer"
  69. run: composer update --no-ansi --no-interaction --no-progress --no-suggest
  70. - name: "Run tests with phpunit"
  71. run: php vendor/bin/phpunit --configuration=phpunit.xml
  72. - name: "Send code coverage report to Codecov.io"
  73. uses: codecov/codecov-action@v1
  74. with:
  75. token: ${{ secrets.CODECOV_TOKEN }}