server.yml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  1. # Server build and tests
  2. name: Server
  3. on:
  4. workflow_dispatch: # allows manual triggering
  5. inputs:
  6. sha:
  7. description: 'Commit SHA1 to build'
  8. required: false
  9. type: string
  10. slow_tests:
  11. description: 'Run slow tests'
  12. required: true
  13. type: boolean
  14. push:
  15. branches:
  16. - master
  17. paths: ['.github/workflows/server.yml', '**/CMakeLists.txt', '**/Makefile', '**/*.h', '**/*.hpp', '**/*.c', '**/*.cpp', '**/*.cu', '**/*.swift', '**/*.m', 'tools/server/**.*']
  18. pull_request:
  19. types: [opened, synchronize, reopened]
  20. paths: ['.github/workflows/server.yml', '**/CMakeLists.txt', '**/Makefile', '**/*.h', '**/*.hpp', '**/*.c', '**/*.cpp', '**/*.cu', '**/*.swift', '**/*.m', 'tools/server/**.*']
  21. env:
  22. LLAMA_LOG_COLORS: 1
  23. LLAMA_LOG_PREFIX: 1
  24. LLAMA_LOG_TIMESTAMPS: 1
  25. LLAMA_LOG_VERBOSITY: 10
  26. concurrency:
  27. group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref || github.run_id }}
  28. cancel-in-progress: true
  29. jobs:
  30. server:
  31. runs-on: ubuntu-latest
  32. strategy:
  33. matrix:
  34. sanitizer: [ADDRESS, UNDEFINED] # THREAD is broken
  35. build_type: [RelWithDebInfo]
  36. include:
  37. - build_type: Release
  38. sanitizer: ""
  39. fail-fast: false # While -DLLAMA_SANITIZE_THREAD=ON is broken
  40. steps:
  41. - name: Dependencies
  42. id: depends
  43. run: |
  44. sudo apt-get update
  45. sudo apt-get -y install \
  46. build-essential \
  47. xxd \
  48. git \
  49. cmake \
  50. curl \
  51. wget \
  52. language-pack-en \
  53. libcurl4-openssl-dev
  54. - name: Clone
  55. id: checkout
  56. uses: actions/checkout@v4
  57. with:
  58. fetch-depth: 0
  59. ref: ${{ github.event.inputs.sha || github.event.pull_request.head.sha || github.sha || github.head_ref || github.ref_name }}
  60. - name: Python setup
  61. id: setup_python
  62. uses: actions/setup-python@v5
  63. with:
  64. python-version: '3.11'
  65. - name: Tests dependencies
  66. id: test_dependencies
  67. run: |
  68. pip install -r tools/server/tests/requirements.txt
  69. webui-setup:
  70. name: WebUI Setup
  71. runs-on: ubuntu-latest
  72. steps:
  73. - name: Checkout code
  74. uses: actions/checkout@v4
  75. with:
  76. fetch-depth: 0
  77. ref: ${{ github.event.inputs.sha || github.event.pull_request.head.sha || github.sha || github.head_ref || github.ref_name }}
  78. - name: Setup Node.js
  79. uses: actions/setup-node@v4
  80. with:
  81. node-version: "22"
  82. cache: "npm"
  83. cache-dependency-path: "tools/server/webui/package-lock.json"
  84. - name: Cache node_modules
  85. uses: actions/cache@v4
  86. id: cache-node-modules
  87. with:
  88. path: tools/server/webui/node_modules
  89. key: ${{ runner.os }}-node-modules-${{ hashFiles('tools/server/webui/package-lock.json') }}
  90. restore-keys: |
  91. ${{ runner.os }}-node-modules-
  92. - name: Install dependencies
  93. if: steps.cache-node-modules.outputs.cache-hit != 'true'
  94. run: npm ci
  95. working-directory: tools/server/webui
  96. webui-check:
  97. needs: webui-setup
  98. name: WebUI Check
  99. runs-on: ubuntu-latest
  100. steps:
  101. - name: Checkout code
  102. uses: actions/checkout@v4
  103. with:
  104. fetch-depth: 0
  105. ref: ${{ github.event.inputs.sha || github.event.pull_request.head.sha || github.sha || github.head_ref || github.ref_name }}
  106. - name: Setup Node.js
  107. uses: actions/setup-node@v4
  108. with:
  109. node-version: "22"
  110. - name: Restore node_modules cache
  111. uses: actions/cache@v4
  112. with:
  113. path: tools/server/webui/node_modules
  114. key: ${{ runner.os }}-node-modules-${{ hashFiles('tools/server/webui/package-lock.json') }}
  115. restore-keys: |
  116. ${{ runner.os }}-node-modules-
  117. - name: Run type checking
  118. run: npm run check
  119. working-directory: tools/server/webui
  120. - name: Run linting
  121. run: npm run lint
  122. working-directory: tools/server/webui
  123. webui-build:
  124. needs: webui-check
  125. name: WebUI Build
  126. runs-on: ubuntu-latest
  127. steps:
  128. - name: Checkout code
  129. uses: actions/checkout@v4
  130. with:
  131. fetch-depth: 0
  132. ref: ${{ github.event.inputs.sha || github.event.pull_request.head.sha || github.sha || github.head_ref || github.ref_name }}
  133. - name: Setup Node.js
  134. uses: actions/setup-node@v4
  135. with:
  136. node-version: "22"
  137. - name: Restore node_modules cache
  138. uses: actions/cache@v4
  139. with:
  140. path: tools/server/webui/node_modules
  141. key: ${{ runner.os }}-node-modules-${{ hashFiles('tools/server/webui/package-lock.json') }}
  142. restore-keys: |
  143. ${{ runner.os }}-node-modules-
  144. - name: Build application
  145. run: npm run build
  146. working-directory: tools/server/webui
  147. webui-tests:
  148. needs: webui-build
  149. name: Run WebUI tests
  150. permissions:
  151. contents: read
  152. runs-on: ubuntu-latest
  153. steps:
  154. - name: Checkout code
  155. uses: actions/checkout@v4
  156. - name: Setup Node.js
  157. uses: actions/setup-node@v4
  158. with:
  159. node-version: "22"
  160. - name: Restore node_modules cache
  161. uses: actions/cache@v4
  162. with:
  163. path: tools/server/webui/node_modules
  164. key: ${{ runner.os }}-node-modules-${{ hashFiles('tools/server/webui/package-lock.json') }}
  165. restore-keys: |
  166. ${{ runner.os }}-node-modules-
  167. - name: Install Playwright browsers
  168. run: npx playwright install --with-deps
  169. working-directory: tools/server/webui
  170. - name: Build Storybook
  171. run: npm run build-storybook
  172. working-directory: tools/server/webui
  173. - name: Run Client tests
  174. run: npm run test:client
  175. working-directory: tools/server/webui
  176. - name: Run Server tests
  177. run: npm run test:server
  178. working-directory: tools/server/webui
  179. - name: Run UI tests
  180. run: npm run test:ui
  181. working-directory: tools/server/webui
  182. - name: Run E2E tests
  183. run: npm run test:e2e
  184. working-directory: tools/server/webui
  185. server-build:
  186. needs: [webui-tests]
  187. runs-on: ubuntu-latest
  188. strategy:
  189. matrix:
  190. sanitizer: [ADDRESS, UNDEFINED] # THREAD is broken
  191. build_type: [RelWithDebInfo]
  192. include:
  193. - build_type: Release
  194. sanitizer: ""
  195. fail-fast: false # While -DLLAMA_SANITIZE_THREAD=ON is broken
  196. steps:
  197. - name: Dependencies
  198. id: depends
  199. run: |
  200. sudo apt-get update
  201. sudo apt-get -y install \
  202. build-essential \
  203. xxd \
  204. git \
  205. cmake \
  206. curl \
  207. wget \
  208. language-pack-en \
  209. libcurl4-openssl-dev
  210. - name: Clone
  211. id: checkout
  212. uses: actions/checkout@v4
  213. with:
  214. fetch-depth: 0
  215. ref: ${{ github.event.inputs.sha || github.event.pull_request.head.sha || github.sha || github.head_ref || github.ref_name }}
  216. - name: Python setup
  217. id: setup_python
  218. uses: actions/setup-python@v5
  219. with:
  220. python-version: '3.11'
  221. - name: Tests dependencies
  222. id: test_dependencies
  223. run: |
  224. pip install -r tools/server/tests/requirements.txt
  225. - name: Setup Node.js for WebUI
  226. uses: actions/setup-node@v4
  227. with:
  228. node-version: "22"
  229. cache: "npm"
  230. cache-dependency-path: "tools/server/webui/package-lock.json"
  231. - name: Install WebUI dependencies
  232. run: npm ci
  233. working-directory: tools/server/webui
  234. - name: Build WebUI
  235. run: npm run build
  236. working-directory: tools/server/webui
  237. - name: Build (no OpenMP)
  238. id: cmake_build_no_openmp
  239. if: ${{ matrix.sanitizer == 'THREAD' }}
  240. run: |
  241. cmake -B build \
  242. -DGGML_NATIVE=OFF \
  243. -DLLAMA_BUILD_SERVER=ON \
  244. -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
  245. -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON \
  246. -DGGML_OPENMP=OFF ;
  247. cmake --build build --config ${{ matrix.build_type }} -j $(nproc) --target llama-server
  248. - name: Build (sanitizers)
  249. id: cmake_build_sanitizers
  250. if: ${{ matrix.sanitizer != '' && matrix.sanitizer != 'THREAD' }}
  251. run: |
  252. cmake -B build \
  253. -DGGML_NATIVE=OFF \
  254. -DLLAMA_BUILD_SERVER=ON \
  255. -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
  256. -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON ;
  257. cmake --build build --config ${{ matrix.build_type }} -j $(nproc) --target llama-server
  258. - name: Build (sanitizers)
  259. id: cmake_build
  260. if: ${{ matrix.sanitizer == '' }}
  261. run: |
  262. cmake -B build \
  263. -DGGML_NATIVE=OFF \
  264. -DLLAMA_BUILD_SERVER=ON \
  265. -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} ;
  266. cmake --build build --config ${{ matrix.build_type }} -j $(nproc) --target llama-server
  267. - name: Tests
  268. id: server_integration_tests
  269. if: ${{ matrix.sanitizer == '' }}
  270. env:
  271. GITHUB_ACTIONS: "true"
  272. run: |
  273. cd tools/server/tests
  274. ./tests.sh
  275. - name: Tests (sanitizers)
  276. id: server_integration_tests_sanitizers
  277. if: ${{ matrix.sanitizer != '' }}
  278. run: |
  279. cd tools/server/tests
  280. LLAMA_SANITIZE=1 ./tests.sh
  281. - name: Slow tests
  282. id: server_integration_tests_slow
  283. if: ${{ (github.event.schedule || github.event.inputs.slow_tests == 'true') && matrix.build_type == 'Release' }}
  284. run: |
  285. cd tools/server/tests
  286. SLOW_TESTS=1 ./tests.sh
  287. server-windows:
  288. runs-on: windows-2022
  289. steps:
  290. - name: Clone
  291. id: checkout
  292. uses: actions/checkout@v4
  293. with:
  294. fetch-depth: 0
  295. ref: ${{ github.event.inputs.sha || github.event.pull_request.head.sha || github.sha || github.head_ref || github.ref_name }}
  296. - name: libCURL
  297. id: get_libcurl
  298. uses: ./.github/actions/windows-setup-curl
  299. - name: Build
  300. id: cmake_build
  301. env:
  302. CURL_PATH: ${{ steps.get_libcurl.outputs.curl_path }}
  303. run: |
  304. cmake -B build -DCURL_LIBRARY="$env:CURL_PATH/lib/libcurl.dll.a" -DCURL_INCLUDE_DIR="$env:CURL_PATH/include"
  305. cmake --build build --config Release -j ${env:NUMBER_OF_PROCESSORS} --target llama-server
  306. - name: Python setup
  307. id: setup_python
  308. uses: actions/setup-python@v5
  309. with:
  310. python-version: '3.11'
  311. - name: Tests dependencies
  312. id: test_dependencies
  313. run: |
  314. pip install -r tools/server/tests/requirements.txt
  315. - name: Copy Libcurl
  316. id: prepare_libcurl
  317. env:
  318. CURL_PATH: ${{ steps.get_libcurl.outputs.curl_path }}
  319. run: |
  320. cp $env:CURL_PATH/bin/libcurl-x64.dll ./build/bin/Release/libcurl-x64.dll
  321. - name: Tests
  322. id: server_integration_tests
  323. if: ${{ !matrix.disabled_on_pr || !github.event.pull_request }}
  324. run: |
  325. cd tools/server/tests
  326. $env:PYTHONIOENCODING = ":replace"
  327. pytest -v -x -m "not slow"
  328. - name: Slow tests
  329. id: server_integration_tests_slow
  330. if: ${{ (github.event.schedule || github.event.inputs.slow_tests == 'true') && matrix.build_type == 'Release' }}
  331. run: |
  332. cd tools/server/tests
  333. $env:SLOW_TESTS = "1"
  334. pytest -v -x