ci.yml 4.3 KB

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