ci.yml 4.1 KB

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