Açıklama Yok

ci.yml 8.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. # IRIS Source Code
  2. # Copyright (C) 2023 - DFIR-IRIS
  3. # contact@dfir-iris.org
  4. #
  5. # This program is free software; you can redistribute it and/or
  6. # modify it under the terms of the GNU Lesser General Public
  7. # License as published by the Free Software Foundation; either
  8. # version 3 of the License, or (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. # Lesser General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU Lesser General Public License
  16. # along with this program; if not, write to the Free Software Foundation,
  17. # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  18. name: Continuous Integration
  19. on: [push, pull_request]
  20. jobs:
  21. static-checks:
  22. name: Static analyis checks
  23. runs-on: ubuntu-22.04
  24. steps:
  25. - name: Check out iris
  26. uses: actions/checkout@v4
  27. - name: Check code with ruff
  28. uses: astral-sh/ruff-action@v2
  29. with:
  30. args: check --output-format=github
  31. src: ./source
  32. build-docker-db:
  33. name: Build docker db
  34. runs-on: ubuntu-22.04
  35. steps:
  36. - name: Check out iris
  37. uses: actions/checkout@v4
  38. - name: Set up Docker Buildx
  39. uses: docker/setup-buildx-action@v3
  40. - name: Build and export
  41. uses: docker/build-push-action@v6
  42. with:
  43. context: docker/db
  44. tags: iriswebapp_db:develop
  45. outputs: type=docker,dest=${{ runner.temp }}/iriswebapp_db.tar
  46. cache-from: type=gha
  47. cache-to: type=gha,mode=max
  48. - name: Upload artifact
  49. uses: actions/upload-artifact@v4
  50. with:
  51. name: iriswebapp_db
  52. path: ${{ runner.temp }}/iriswebapp_db.tar
  53. build-docker-nginx:
  54. name: Build docker nginx
  55. runs-on: ubuntu-22.04
  56. steps:
  57. - name: Check out iris
  58. uses: actions/checkout@v4
  59. - name: Set up Docker Buildx
  60. uses: docker/setup-buildx-action@v3
  61. - name: Build and export
  62. uses: docker/build-push-action@v6
  63. with:
  64. context: docker/nginx
  65. tags: iriswebapp_nginx:develop
  66. build-args: |
  67. NGINX_CONF_GID=1234
  68. NGINX_CONF_FILE=nginx.conf
  69. outputs: type=docker,dest=${{ runner.temp }}/iriswebapp_nginx.tar
  70. cache-from: type=gha
  71. cache-to: type=gha,mode=max
  72. - name: Upload artifact
  73. uses: actions/upload-artifact@v4
  74. with:
  75. name: iriswebapp_nginx
  76. path: ${{ runner.temp }}/iriswebapp_nginx.tar
  77. build-docker-app:
  78. name: Build docker app
  79. runs-on: ubuntu-22.04
  80. steps:
  81. - name: Check out iris
  82. uses: actions/checkout@v4
  83. - name: Set up Docker Buildx
  84. uses: docker/setup-buildx-action@v3
  85. - name: Build and export
  86. uses: docker/build-push-action@v6
  87. with:
  88. context: .
  89. file: docker/webApp/Dockerfile
  90. tags: iriswebapp_app:develop
  91. outputs: type=docker,dest=${{ runner.temp }}/iriswebapp_app.tar
  92. cache-from: type=gha
  93. cache-to: type=gha,mode=max
  94. - name: Upload artifact
  95. uses: actions/upload-artifact@v4
  96. with:
  97. name: iriswebapp_app
  98. path: ${{ runner.temp }}/iriswebapp_app.tar
  99. build-graphql-documentation:
  100. name: Generate graphQL documentation
  101. runs-on: ubuntu-22.04
  102. needs:
  103. - build-docker-db
  104. - build-docker-nginx
  105. - build-docker-app
  106. steps:
  107. - name: Download artifacts
  108. uses: actions/download-artifact@v4
  109. with:
  110. pattern: iriswebapp_*
  111. path: ${{ runner.temp }}
  112. merge-multiple: true
  113. - name: Load docker images
  114. run: |
  115. docker load --input ${{ runner.temp }}/iriswebapp_db.tar
  116. docker load --input ${{ runner.temp }}/iriswebapp_nginx.tar
  117. docker load --input ${{ runner.temp }}/iriswebapp_app.tar
  118. - name: Check out iris
  119. uses: actions/checkout@v4
  120. - name: Start development server
  121. run: |
  122. # Even though, we use --env-file option when running docker compose, this is still necessary, because the compose has a env_file attribute :(
  123. # TODO should move basic.env file, which is in directory tests, up. It's used in several places. Maybe, rename it into dev.env
  124. cp tests/data/basic.env .env
  125. docker compose --file docker-compose.dev.yml --env-file tests/data/basic.env up --detach
  126. - name: Generate GraphQL documentation
  127. run: |
  128. npx spectaql@^3.0.2 source/spectaql/config.yml
  129. - name: Stop development server
  130. run: |
  131. docker compose down
  132. - uses: actions/upload-artifact@v4
  133. with:
  134. name: GraphQL DFIR-IRIS documentation
  135. path: public
  136. if-no-files-found: error
  137. test-api:
  138. name: Test API
  139. runs-on: ubuntu-22.04
  140. needs:
  141. - build-docker-db
  142. - build-docker-nginx
  143. - build-docker-app
  144. steps:
  145. - name: Download artifacts
  146. uses: actions/download-artifact@v4
  147. with:
  148. pattern: iriswebapp_*
  149. path: ${{ runner.temp }}
  150. merge-multiple: true
  151. - name: Load docker images
  152. run: |
  153. docker load --input ${{ runner.temp }}/iriswebapp_db.tar
  154. docker load --input ${{ runner.temp }}/iriswebapp_nginx.tar
  155. docker load --input ${{ runner.temp }}/iriswebapp_app.tar
  156. - name: Check out iris
  157. uses: actions/checkout@v4
  158. - name: Start development server
  159. run: |
  160. # Even though, we use --env-file option when running docker compose, this is still necessary, because the compose has a env_file attribute :(
  161. # TODO should move basic.env file, which is in directory tests, up. It's used in several places. Maybe, rename it into dev.env
  162. cp tests/data/basic.env .env
  163. docker compose --file docker-compose.dev.yml up --detach
  164. - name: Run tests
  165. working-directory: tests
  166. run: |
  167. python -m venv venv
  168. source venv/bin/activate
  169. pip install -r requirements.txt
  170. PYTHONUNBUFFERED=true python -m unittest --verbose
  171. - name: Stop development server
  172. run: |
  173. docker compose down
  174. test-e2e:
  175. name: End to end tests
  176. runs-on: ubuntu-22.04
  177. needs:
  178. - build-docker-db
  179. - build-docker-nginx
  180. - build-docker-app
  181. steps:
  182. - name: Download artifacts
  183. uses: actions/download-artifact@v4
  184. with:
  185. pattern: iriswebapp_*
  186. path: ${{ runner.temp }}
  187. merge-multiple: true
  188. - name: Load docker images
  189. run: |
  190. docker load --input ${{ runner.temp }}/iriswebapp_db.tar
  191. docker load --input ${{ runner.temp }}/iriswebapp_nginx.tar
  192. docker load --input ${{ runner.temp }}/iriswebapp_app.tar
  193. - name: Check out iris
  194. uses: actions/checkout@v4
  195. - uses: actions/setup-node@v4
  196. with:
  197. node-version: 20
  198. cache: npm
  199. cache-dependency-path: |
  200. ui/package-lock.json
  201. e2e/package-lock.json
  202. - name: Build ui to be mounted in development docker
  203. working-directory: ui
  204. run: |
  205. npm ci
  206. npm run build
  207. - name: Install e2e dependencies
  208. working-directory: e2e
  209. run: npm ci
  210. - name: Install playwright dependencies
  211. working-directory: e2e
  212. run: npx playwright install chromium firefox
  213. - name: Start development server
  214. run: |
  215. # TODO should move basic.env file, which is in directory tests, up. It's used in several places. Maybe, rename it into dev.env
  216. cp tests/data/basic.env .env
  217. docker compose --file docker-compose.dev.yml up --detach
  218. - name: Run end to end tests
  219. working-directory: e2e
  220. run: npx playwright test
  221. - name: Stop development server
  222. run: |
  223. docker compose down
  224. - uses: actions/upload-artifact@v4
  225. if: ${{ always() }}
  226. with:
  227. name: playwright-report
  228. path: e2e/playwright-report/