ci.yml 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions
  2. # https://github.com/sebastianbergmann/phpunit/blob/main/.github/workflows/ci.yaml
  3. on:
  4. push:
  5. branches:
  6. - main
  7. pull_request:
  8. branches:
  9. - main
  10. name: "Continuous Integration"
  11. env:
  12. PHP_EXTENSIONS: fileinfo, gd, imagick, json, mbstring
  13. PHP_INI_VALUES: memory_limit=-1, error_reporting=-1, display_errors=On
  14. jobs:
  15. static-code-analysis:
  16. name: "Static Code Analysis"
  17. runs-on: ubuntu-latest
  18. strategy:
  19. fail-fast: true
  20. matrix:
  21. php-version:
  22. - "8.2"
  23. - "8.3"
  24. env:
  25. PHAN_ALLOW_XDEBUG: 0
  26. PHAN_DISABLE_XDEBUG_WARN: 1
  27. steps:
  28. - name: "Checkout"
  29. uses: actions/checkout@v4
  30. - name: "Install PHP"
  31. uses: shivammathur/setup-php@v2
  32. with:
  33. php-version: ${{ matrix.php-version }}
  34. extensions: ${{ env.PHP_EXTENSIONS }}
  35. ini-values: ${{ env.PHP_INI_VALUES }}
  36. coverage: none
  37. - name: "Install dependencies with composer"
  38. uses: ramsey/composer-install@v3
  39. - name: "Run PHPStan"
  40. run: php vendor/bin/phpstan
  41. - name: "Run PHP_CodeSniffer"
  42. run: php vendor/bin/phpstan
  43. tests:
  44. name: "Unit Tests"
  45. needs: static-code-analysis
  46. runs-on: ${{ matrix.os }}
  47. strategy:
  48. fail-fast: false
  49. matrix:
  50. os:
  51. - ubuntu-latest
  52. - windows-latest
  53. php-version:
  54. - "8.2"
  55. - "8.3"
  56. steps:
  57. - name: "Checkout"
  58. uses: actions/checkout@v4
  59. - name: "Install PHP with extensions"
  60. uses: shivammathur/setup-php@v2
  61. with:
  62. php-version: ${{ matrix.php-version }}
  63. extensions: ${{ env.PHP_EXTENSIONS }}
  64. ini-values: ${{ env.PHP_INI_VALUES }}
  65. coverage: pcov
  66. tools: pecl
  67. - name: "Install dependencies with composer"
  68. uses: ramsey/composer-install@v3
  69. - name: "Run tests with PHPUnit"
  70. run: php vendor/bin/phpunit --colors=always --configuration=phpunit.xml.dist
  71. - name: "Send code coverage report to Codecov.io"
  72. uses: codecov/codecov-action@v4
  73. with:
  74. token: ${{ secrets.CODECOV_TOKEN }}
  75. files: .build/coverage/clover.xml
  76. - name: "Send code coverage report to Codacy"
  77. uses: codacy/codacy-coverage-reporter-action@v1
  78. with:
  79. project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
  80. coverage-reports: .build/coverage/clover.xml
  81. build-docs:
  82. name: "Build and publish API docs"
  83. if: github.ref_name == 'main'
  84. runs-on: ubuntu-latest
  85. steps:
  86. - name: "Checkout sources"
  87. uses: actions/checkout@v4
  88. - name: "Install PHP"
  89. uses: shivammathur/setup-php@v2
  90. with:
  91. php-version: "8.3"
  92. extensions: ${{ env.PHP_EXTENSIONS }}
  93. ini-values: ${{ env.PHP_INI_VALUES }}
  94. coverage: none
  95. tools: phpDocumentor
  96. - name: "Build API docs"
  97. run: phpdoc --config=phpdoc.xml.dist
  98. - name: "Publish API docs to branch gh-pages"
  99. uses: JamesIves/github-pages-deploy-action@v4
  100. with:
  101. branch: gh-pages
  102. folder: .build/phpdocs
  103. clean: true
  104. build-manual:
  105. name: "Build and publish user manual"
  106. if: github.ref_name == 'main'
  107. runs-on: ubuntu-latest
  108. steps:
  109. - name: "Checkout sources"
  110. uses: actions/checkout@v4
  111. - name: "Install PHP"
  112. uses: shivammathur/setup-php@v2
  113. with:
  114. php-version: "8.3"
  115. extensions: ${{ env.PHP_EXTENSIONS }}
  116. ini-values: ${{ env.PHP_INI_VALUES }}
  117. coverage: none
  118. - name: "Install Sphinx"
  119. run: pip install sphinx myst-parser sphinx-rtd-theme
  120. - name: "Install dependencies with composer"
  121. uses: ramsey/composer-install@v3
  122. - name: "Build QROptions doc"
  123. run: php docs/qroptions-doc.php
  124. - name: "Build manual"
  125. run: |
  126. cd docs
  127. make html
  128. - name: "Publish user manual to branch readthedocs"
  129. uses: JamesIves/github-pages-deploy-action@v4
  130. with:
  131. branch: readthedocs
  132. folder: .build/sphinx/html
  133. clean: true