ci.yml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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. env:
  19. PHAN_ALLOW_XDEBUG: 0
  20. PHAN_DISABLE_XDEBUG_WARN: 1
  21. strategy:
  22. fail-fast: true
  23. matrix:
  24. php-version:
  25. - "8.2"
  26. - "8.3"
  27. - "8.4"
  28. # - "8.5"
  29. steps:
  30. - name: "Checkout"
  31. uses: actions/checkout@v5
  32. - name: "Install PHP"
  33. uses: shivammathur/setup-php@v2
  34. with:
  35. php-version: ${{ matrix.php-version }}
  36. extensions: ast, ${{ env.PHP_EXTENSIONS }}
  37. ini-values: ${{ env.PHP_INI_VALUES }}
  38. coverage: none
  39. - name: "Install dependencies with composer"
  40. uses: ramsey/composer-install@v3
  41. - name: "Run phan"
  42. run: php vendor/bin/phan --target-php-version=${{ matrix.php-version }}
  43. - name: "Run PHP_CodeSniffer"
  44. run: php vendor/bin/phpcs -v
  45. # - name: "Run PHPStan"
  46. # run: php vendor/bin/phpstan
  47. tests:
  48. name: "Unit Tests"
  49. needs: static-code-analysis
  50. runs-on: ${{ matrix.os }}
  51. strategy:
  52. fail-fast: false
  53. matrix:
  54. os:
  55. - ubuntu-latest
  56. - windows-latest
  57. php-version:
  58. - "8.2"
  59. - "8.3"
  60. - "8.4"
  61. # - "8.5"
  62. steps:
  63. - name: "Checkout"
  64. uses: actions/checkout@v5
  65. - name: "Install PHP with extensions"
  66. uses: shivammathur/setup-php@v2
  67. with:
  68. php-version: ${{ matrix.php-version }}
  69. extensions: ${{ env.PHP_EXTENSIONS }}
  70. ini-values: ${{ env.PHP_INI_VALUES }}
  71. coverage: pcov
  72. tools: pecl
  73. - name: "Install dependencies with composer"
  74. uses: ramsey/composer-install@v3
  75. - name: "Run tests with PHPUnit"
  76. run: php vendor/bin/phpunit --colors=always --configuration=phpunit.xml.dist
  77. - name: "Send code coverage report to Codecov.io"
  78. uses: codecov/codecov-action@v4
  79. with:
  80. token: ${{ secrets.CODECOV_TOKEN }}
  81. files: .build/coverage/clover.xml
  82. - name: "Send code coverage report to Codacy"
  83. uses: codacy/codacy-coverage-reporter-action@v1
  84. with:
  85. project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
  86. coverage-reports: .build/coverage/clover.xml
  87. build-docs:
  88. name: "Build and publish API docs"
  89. if: github.ref_name == 'main'
  90. runs-on: ubuntu-latest
  91. steps:
  92. - name: "Checkout sources"
  93. uses: actions/checkout@v5
  94. - name: "Install PHP"
  95. uses: shivammathur/setup-php@v2
  96. with:
  97. php-version: "8.4"
  98. extensions: ${{ env.PHP_EXTENSIONS }}
  99. ini-values: ${{ env.PHP_INI_VALUES }}
  100. coverage: none
  101. tools: phpDocumentor
  102. - name: "Build API docs"
  103. run: phpdoc --config=phpdoc.xml.dist
  104. - name: "Publish API docs to branch gh-pages"
  105. uses: JamesIves/github-pages-deploy-action@v4
  106. with:
  107. branch: gh-pages
  108. folder: .build/phpdocs
  109. clean: true
  110. build-manual:
  111. name: "Build and publish user manual"
  112. if: github.ref_name == 'main'
  113. runs-on: ubuntu-latest
  114. steps:
  115. - name: "Checkout sources"
  116. uses: actions/checkout@v5
  117. - name: "Install PHP"
  118. uses: shivammathur/setup-php@v2
  119. with:
  120. php-version: "8.4"
  121. extensions: ${{ env.PHP_EXTENSIONS }}
  122. ini-values: ${{ env.PHP_INI_VALUES }}
  123. coverage: none
  124. - name: "Install dependencies with composer"
  125. uses: ramsey/composer-install@v3
  126. - name: "Install Sphinx"
  127. run: pip install sphinx myst-parser sphinx-rtd-theme
  128. - name: "Build QROptions doc"
  129. run: php docs/qroptions-doc.php
  130. - name: "Build manual"
  131. run: |
  132. cd docs
  133. make html
  134. - name: "Publish user manual to branch readthedocs"
  135. uses: JamesIves/github-pages-deploy-action@v4
  136. with:
  137. branch: readthedocs
  138. folder: .build/sphinx/html
  139. clean: true