continuous-integration.yml 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. # GitHub Actions Documentation: https://docs.github.com/en/actions
  2. name: "build"
  3. on:
  4. push:
  5. branches:
  6. - "*.x"
  7. tags:
  8. - "*"
  9. pull_request:
  10. branches:
  11. - "*.x"
  12. # Cancels all previous workflow runs for the same branch that have not yet completed.
  13. concurrency:
  14. # The concurrency group contains the workflow name and the branch name.
  15. group: ${{ github.workflow }}-${{ github.ref }}
  16. cancel-in-progress: true
  17. env:
  18. COMPOSER_ROOT_VERSION: "1.99.99"
  19. jobs:
  20. coding-standards:
  21. name: "Coding standards"
  22. runs-on: "ubuntu-latest"
  23. steps:
  24. - name: "Checkout repository"
  25. uses: "actions/checkout@v4"
  26. - name: "Install PHP"
  27. uses: "shivammathur/setup-php@v2"
  28. with:
  29. php-version: "latest"
  30. coverage: "none"
  31. - name: "Install dependencies (Composer)"
  32. uses: "ramsey/composer-install@v2"
  33. - name: "Check syntax (php-parallel-lint)"
  34. run: "composer lint -- --colors"
  35. - name: "Check coding standards (PHP_CodeSniffer)"
  36. run: "./vendor/bin/phpcs --colors"
  37. static-analysis:
  38. name: "Static analysis"
  39. runs-on: "ubuntu-latest"
  40. steps:
  41. - name: "Checkout repository"
  42. uses: "actions/checkout@v4"
  43. - name: "Install PHP"
  44. uses: "shivammathur/setup-php@v2"
  45. with:
  46. php-version: "latest"
  47. coverage: "none"
  48. - name: "Install dependencies (Composer)"
  49. uses: "ramsey/composer-install@v2"
  50. - name: "Statically analyze code (PHPStan)"
  51. run: "composer phpstan -- --ansi"
  52. - name: "Statically analyze code (Psalm)"
  53. run: "composer psalm -- --shepherd"
  54. benchmark:
  55. name: "Benchmark"
  56. needs: ["coding-standards", "static-analysis"]
  57. runs-on: "ubuntu-latest"
  58. strategy:
  59. fail-fast: false
  60. matrix:
  61. php-version:
  62. - "8.0"
  63. - "8.1"
  64. - "8.2"
  65. - "8.3"
  66. steps:
  67. - name: "Checkout repository"
  68. uses: "actions/checkout@v4"
  69. - name: "Install dependencies (apt)"
  70. run: |
  71. sudo apt-get update
  72. sudo apt-get -y install libsodium-dev uuid-dev
  73. - name: "Install PHP"
  74. uses: "shivammathur/setup-php@v2"
  75. with:
  76. php-version: "${{ matrix.php-version }}"
  77. extensions: bcmath, gmp, sodium, uuid
  78. coverage: "none"
  79. ini-values: "memory_limit=-1"
  80. - name: "Install dependencies (Composer)"
  81. uses: "ramsey/composer-install@v2"
  82. - name: "Run PHPBench"
  83. run: "composer phpbench -- --ansi"
  84. code-coverage:
  85. name: "Code coverage"
  86. needs: ["coding-standards", "static-analysis"]
  87. runs-on: "ubuntu-latest"
  88. steps:
  89. - name: "Checkout repository"
  90. uses: "actions/checkout@v4"
  91. - name: "Install dependencies (apt)"
  92. run: |
  93. sudo apt-get update
  94. sudo apt-get -y install libsodium-dev uuid-dev
  95. - name: "Install PHP"
  96. uses: "shivammathur/setup-php@v2"
  97. with:
  98. php-version: "latest"
  99. extensions: bcmath, gmp, sodium, uuid
  100. coverage: "pcov"
  101. ini-values: "memory_limit=-1"
  102. - name: "Install dependencies (Composer)"
  103. uses: "ramsey/composer-install@v2"
  104. with:
  105. dependency-versions: "${{ matrix.dependencies }}"
  106. - name: "Run unit tests (PHPUnit)"
  107. run: "./vendor/bin/phpunit --verbose --colors=always --coverage-text --coverage-clover build/logs/clover.xml"
  108. - name: "Publish coverage report to Codecov"
  109. uses: "codecov/codecov-action@v3.1.4"
  110. unit-tests:
  111. name: "Unit Tests"
  112. needs: ["code-coverage"]
  113. runs-on: ${{ matrix.operating-system }}
  114. strategy:
  115. fail-fast: false
  116. matrix:
  117. php-version:
  118. - "8.0"
  119. - "8.1"
  120. - "8.2"
  121. - "8.3"
  122. operating-system:
  123. - "ubuntu-latest"
  124. - "windows-latest"
  125. steps:
  126. - name: "Configure Git (for Windows)"
  127. if: ${{ matrix.operating-system == 'windows-latest' }}
  128. run: |
  129. git config --system core.autocrlf false
  130. git config --system core.eol lf
  131. - name: "Checkout repository"
  132. uses: "actions/checkout@v4"
  133. - name: "Install dependencies (apt)"
  134. if: ${{ matrix.operating-system == 'ubuntu-latest' }}
  135. run: |
  136. sudo apt-get update
  137. sudo apt-get -y install libsodium-dev uuid-dev
  138. - name: "Install PHP"
  139. uses: "shivammathur/setup-php@v2"
  140. with:
  141. php-version: "${{ matrix.php-version }}"
  142. extensions: bcmath, gmp, sodium, uuid
  143. coverage: "none"
  144. ini-values: "memory_limit=-1"
  145. - name: "Install dependencies (Composer)"
  146. uses: "ramsey/composer-install@v2"
  147. with:
  148. composer-options: "${{ matrix.composer-options }}"
  149. - name: "Run unit tests (PHPUnit)"
  150. run: "./vendor/bin/phpunit --verbose --colors=always --no-coverage"