ci.yml 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. name: Continuous integration
  2. on:
  3. pull_request: null
  4. push:
  5. branches:
  6. - main
  7. - develop
  8. jobs:
  9. lint:
  10. runs-on: ubuntu-20.04
  11. strategy:
  12. matrix:
  13. php-version: ['7.4']
  14. steps:
  15. - name: Checkout code
  16. uses: actions/checkout@v2
  17. - name: Use PHP
  18. uses: shivammathur/setup-php@v2
  19. with:
  20. php-version: ${{ matrix.php-version }}
  21. tools: composer
  22. extensions: swoole-4.5.9
  23. coverage: none
  24. - run: composer install --no-interaction --prefer-dist
  25. - run: composer cs
  26. static-analysis:
  27. runs-on: ubuntu-20.04
  28. strategy:
  29. matrix:
  30. php-version: ['7.4']
  31. steps:
  32. - name: Checkout code
  33. uses: actions/checkout@v2
  34. - name: Use PHP
  35. uses: shivammathur/setup-php@v2
  36. with:
  37. php-version: ${{ matrix.php-version }}
  38. tools: composer
  39. extensions: swoole-4.5.9
  40. coverage: none
  41. - run: composer install --no-interaction --prefer-dist
  42. - run: composer stan
  43. unit-tests:
  44. runs-on: ubuntu-20.04
  45. continue-on-error: ${{ matrix.php-version == '8.0' }}
  46. strategy:
  47. matrix:
  48. php-version: ['7.4', '8.0']
  49. steps:
  50. - name: Checkout code
  51. uses: actions/checkout@v2
  52. - name: Use PHP
  53. uses: shivammathur/setup-php@v2
  54. with:
  55. php-version: ${{ matrix.php-version }}
  56. tools: composer
  57. extensions: swoole-4.5.9
  58. coverage: pcov
  59. ini-values: pcov.directory=module
  60. - if: ${{ matrix.php-version == '8.0' }}
  61. run: composer install --no-interaction --prefer-dist --ignore-platform-req=php
  62. - if: ${{ matrix.php-version != '8.0' }}
  63. run: composer install --no-interaction --prefer-dist
  64. - run: composer test:unit:ci
  65. - uses: actions/upload-artifact@v2
  66. if: ${{ matrix.php-version == '7.4' }}
  67. with:
  68. name: coverage-unit
  69. path: |
  70. build/coverage-unit
  71. build/coverage-unit.cov
  72. db-tests-sqlite:
  73. runs-on: ubuntu-20.04
  74. strategy:
  75. matrix:
  76. php-version: ['7.4', '8.0']
  77. steps:
  78. - name: Checkout code
  79. uses: actions/checkout@v2
  80. - name: Use PHP
  81. uses: shivammathur/setup-php@v2
  82. with:
  83. php-version: ${{ matrix.php-version }}
  84. tools: composer
  85. extensions: swoole-4.5.9
  86. coverage: pcov
  87. ini-values: pcov.directory=module
  88. - if: ${{ matrix.php-version == '8.0' }}
  89. run: composer install --no-interaction --prefer-dist --ignore-platform-req=php
  90. - if: ${{ matrix.php-version != '8.0' }}
  91. run: composer install --no-interaction --prefer-dist
  92. - run: composer test:db:sqlite:ci
  93. - uses: actions/upload-artifact@v2
  94. if: ${{ matrix.php-version == '7.4' }}
  95. with:
  96. name: coverage-db
  97. path: |
  98. build/coverage-db
  99. build/coverage-db.cov
  100. db-tests-mysql:
  101. runs-on: ubuntu-20.04
  102. strategy:
  103. matrix:
  104. php-version: ['7.4', '8.0']
  105. steps:
  106. - name: Checkout code
  107. uses: actions/checkout@v2
  108. - name: Start database server
  109. run: docker-compose -f docker-compose.yml -f docker-compose.ci.yml up -d shlink_db
  110. - name: Use PHP
  111. uses: shivammathur/setup-php@v2
  112. with:
  113. php-version: ${{ matrix.php-version }}
  114. tools: composer
  115. extensions: swoole-4.5.9
  116. coverage: none
  117. - if: ${{ matrix.php-version == '8.0' }}
  118. run: composer install --no-interaction --prefer-dist --ignore-platform-req=php
  119. - if: ${{ matrix.php-version != '8.0' }}
  120. run: composer install --no-interaction --prefer-dist
  121. - run: composer test:db:mysql
  122. db-tests-maria:
  123. runs-on: ubuntu-20.04
  124. strategy:
  125. matrix:
  126. php-version: ['7.4', '8.0']
  127. steps:
  128. - name: Checkout code
  129. uses: actions/checkout@v2
  130. - name: Start database server
  131. run: docker-compose -f docker-compose.yml -f docker-compose.ci.yml up -d shlink_db_maria
  132. - name: Use PHP
  133. uses: shivammathur/setup-php@v2
  134. with:
  135. php-version: ${{ matrix.php-version }}
  136. tools: composer
  137. extensions: swoole-4.5.9
  138. coverage: none
  139. - if: ${{ matrix.php-version == '8.0' }}
  140. run: composer install --no-interaction --prefer-dist --ignore-platform-req=php
  141. - if: ${{ matrix.php-version != '8.0' }}
  142. run: composer install --no-interaction --prefer-dist
  143. - run: composer test:db:maria
  144. db-tests-postgres:
  145. runs-on: ubuntu-20.04
  146. strategy:
  147. matrix:
  148. php-version: ['7.4', '8.0']
  149. steps:
  150. - name: Checkout code
  151. uses: actions/checkout@v2
  152. - name: Start database server
  153. run: docker-compose -f docker-compose.yml -f docker-compose.ci.yml up -d shlink_db_postgres
  154. - name: Use PHP
  155. uses: shivammathur/setup-php@v2
  156. with:
  157. php-version: ${{ matrix.php-version }}
  158. tools: composer
  159. extensions: swoole-4.5.9
  160. coverage: none
  161. - if: ${{ matrix.php-version == '8.0' }}
  162. run: composer install --no-interaction --prefer-dist --ignore-platform-req=php
  163. - if: ${{ matrix.php-version != '8.0' }}
  164. run: composer install --no-interaction --prefer-dist
  165. - run: composer test:db:postgres
  166. db-tests-ms:
  167. runs-on: ubuntu-20.04
  168. strategy:
  169. matrix:
  170. php-version: ['7.4', '8.0']
  171. steps:
  172. - name: Checkout code
  173. uses: actions/checkout@v2
  174. - name: Install MSSQL ODBC
  175. run: sudo ./data/infra/ci/install-ms-odbc.sh
  176. - name: Start database server
  177. run: docker-compose -f docker-compose.yml -f docker-compose.ci.yml up -d shlink_db_ms
  178. - name: Use PHP
  179. uses: shivammathur/setup-php@v2
  180. with:
  181. php-version: ${{ matrix.php-version }}
  182. tools: composer
  183. extensions: swoole-4.5.9, pdo_sqlsrv-5.9.0beta2
  184. coverage: none
  185. - if: ${{ matrix.php-version == '8.0' }}
  186. run: composer install --no-interaction --prefer-dist --ignore-platform-req=php
  187. - if: ${{ matrix.php-version != '8.0' }}
  188. run: composer install --no-interaction --prefer-dist
  189. - name: Create test database
  190. run: docker-compose exec -T shlink_db_ms /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 'Passw0rd!' -Q "CREATE DATABASE shlink_test;"
  191. - run: composer test:db:ms
  192. api-tests:
  193. runs-on: ubuntu-20.04
  194. continue-on-error: ${{ matrix.php-version == '8.0' }}
  195. strategy:
  196. matrix:
  197. php-version: ['7.4', '8.0']
  198. steps:
  199. - name: Checkout code
  200. uses: actions/checkout@v2
  201. - name: Start database server
  202. run: docker-compose -f docker-compose.yml -f docker-compose.ci.yml up -d shlink_db
  203. - name: Use PHP
  204. uses: shivammathur/setup-php@v2
  205. with:
  206. php-version: ${{ matrix.php-version }}
  207. tools: composer
  208. extensions: swoole-4.5.9
  209. coverage: pcov
  210. ini-values: pcov.directory=module
  211. - if: ${{ matrix.php-version == '8.0' }}
  212. run: composer install --no-interaction --prefer-dist --ignore-platform-req=php
  213. - if: ${{ matrix.php-version != '8.0' }}
  214. run: composer install --no-interaction --prefer-dist
  215. - run: bin/test/run-api-tests.sh
  216. - uses: actions/upload-artifact@v2
  217. if: ${{ matrix.php-version == '7.4' }}
  218. with:
  219. name: coverage-api
  220. path: |
  221. build/coverage-api
  222. build/coverage-api.cov
  223. mutation-tests:
  224. needs:
  225. - unit-tests
  226. - db-tests-sqlite
  227. - api-tests
  228. runs-on: ubuntu-20.04
  229. strategy:
  230. matrix:
  231. php-version: ['7.4', '8.0']
  232. steps:
  233. - name: Checkout code
  234. uses: actions/checkout@v2
  235. - name: Use PHP
  236. uses: shivammathur/setup-php@v2
  237. with:
  238. php-version: ${{ matrix.php-version }}
  239. tools: composer
  240. extensions: swoole-4.5.9
  241. coverage: pcov
  242. ini-values: pcov.directory=module
  243. - if: ${{ matrix.php-version == '8.0' }}
  244. run: composer install --no-interaction --prefer-dist --ignore-platform-req=php
  245. - if: ${{ matrix.php-version != '8.0' }}
  246. run: composer install --no-interaction --prefer-dist
  247. - uses: actions/download-artifact@v2
  248. with:
  249. path: build
  250. - run: composer infect:ci
  251. upload-coverage:
  252. needs:
  253. - unit-tests
  254. - db-tests-sqlite
  255. - api-tests
  256. runs-on: ubuntu-20.04
  257. strategy:
  258. matrix:
  259. php-version: ['7.4']
  260. steps:
  261. - name: Checkout code
  262. uses: actions/checkout@v2
  263. - name: Use PHP
  264. uses: shivammathur/setup-php@v2
  265. with:
  266. php-version: ${{ matrix.php-version }}
  267. coverage: pcov
  268. ini-values: pcov.directory=module
  269. - uses: actions/download-artifact@v2
  270. with:
  271. path: build
  272. - run: mv build/coverage-unit/coverage-unit.cov build/coverage-unit.cov
  273. - run: mv build/coverage-db/coverage-db.cov build/coverage-db.cov
  274. - run: mv build/coverage-api/coverage-api.cov build/coverage-api.cov
  275. - run: wget https://phar.phpunit.de/phpcov-8.2.0.phar
  276. - run: php phpcov-8.2.0.phar merge build --clover build/clover.xml
  277. - name: Publish coverage
  278. uses: codecov/codecov-action@v1
  279. with:
  280. file: ./build/clover.xml
  281. delete-artifacts:
  282. needs:
  283. - mutation-tests
  284. - upload-coverage
  285. runs-on: ubuntu-20.04
  286. steps:
  287. - uses: geekyeggo/delete-artifact@v1
  288. with:
  289. name: |
  290. coverage-unit
  291. coverage-db
  292. coverage-api
  293. build-docker-image:
  294. runs-on: ubuntu-20.04
  295. steps:
  296. - name: Checkout code
  297. uses: actions/checkout@v2
  298. - uses: marceloprado/has-changed-path@v1
  299. id: changed-dockerfile
  300. with:
  301. paths: ./Dockerfile
  302. - if: ${{ steps.changed-dockerfile.outputs.changed == 'true' }}
  303. run: docker build -t shlink-docker-image:temp .
  304. - if: ${{ steps.changed-dockerfile.outputs.changed != 'true' }}
  305. run: echo "Dockerfile didn't change. Skipped"