server.yml 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  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. # Setup nodejs (to be used for verifying bundled index.html)
  70. - uses: actions/setup-node@v4
  71. with:
  72. node-version: '22.11.0'
  73. - name: WebUI - Install dependencies
  74. id: webui_lint
  75. run: |
  76. cd tools/server/webui
  77. npm ci
  78. - name: WebUI - Check code format
  79. id: webui_format
  80. run: |
  81. git config --global --add safe.directory $(realpath .)
  82. cd tools/server/webui
  83. git status
  84. npm run format
  85. git status
  86. modified_files="$(git status -s)"
  87. echo "Modified files: ${modified_files}"
  88. if [ -n "${modified_files}" ]; then
  89. echo "Files do not follow coding style. To fix: npm run format"
  90. echo "${modified_files}"
  91. exit 1
  92. fi
  93. - name: Verify bundled index.html
  94. id: verify_server_index_html
  95. run: |
  96. git config --global --add safe.directory $(realpath .)
  97. cd tools/server/webui
  98. git status
  99. npm run build
  100. git status
  101. modified_files="$(git status -s)"
  102. echo "Modified files: ${modified_files}"
  103. if [ -n "${modified_files}" ]; then
  104. echo "Repository is dirty or server/webui is not built as expected"
  105. echo "Hint: You may need to follow Web UI build guide in server/README.md"
  106. echo "${modified_files}"
  107. exit 1
  108. fi
  109. - name: Build (no OpenMP)
  110. id: cmake_build_no_openmp
  111. if: ${{ matrix.sanitizer == 'THREAD' }}
  112. run: |
  113. cmake -B build \
  114. -DGGML_NATIVE=OFF \
  115. -DLLAMA_BUILD_SERVER=ON \
  116. -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
  117. -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON \
  118. -DGGML_OPENMP=OFF ;
  119. cmake --build build --config ${{ matrix.build_type }} -j $(nproc) --target llama-server
  120. - name: Build (sanitizers)
  121. id: cmake_build_sanitizers
  122. if: ${{ matrix.sanitizer != '' && matrix.sanitizer != 'THREAD' }}
  123. run: |
  124. cmake -B build \
  125. -DGGML_NATIVE=OFF \
  126. -DLLAMA_BUILD_SERVER=ON \
  127. -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
  128. -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON ;
  129. cmake --build build --config ${{ matrix.build_type }} -j $(nproc) --target llama-server
  130. - name: Build (sanitizers)
  131. id: cmake_build
  132. if: ${{ matrix.sanitizer == '' }}
  133. run: |
  134. cmake -B build \
  135. -DGGML_NATIVE=OFF \
  136. -DLLAMA_BUILD_SERVER=ON \
  137. -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} ;
  138. cmake --build build --config ${{ matrix.build_type }} -j $(nproc) --target llama-server
  139. - name: Tests
  140. id: server_integration_tests
  141. if: ${{ matrix.sanitizer == '' }}
  142. env:
  143. GITHUB_ACTIONS: "true"
  144. run: |
  145. cd tools/server/tests
  146. ./tests.sh
  147. - name: Tests (sanitizers)
  148. id: server_integration_tests_sanitizers
  149. if: ${{ matrix.sanitizer != '' }}
  150. run: |
  151. cd tools/server/tests
  152. LLAMA_SANITIZE=1 ./tests.sh
  153. - name: Slow tests
  154. id: server_integration_tests_slow
  155. if: ${{ (github.event.schedule || github.event.inputs.slow_tests == 'true') && matrix.build_type == 'Release' }}
  156. run: |
  157. cd tools/server/tests
  158. SLOW_TESTS=1 ./tests.sh
  159. server-windows:
  160. runs-on: windows-2019
  161. steps:
  162. - name: Clone
  163. id: checkout
  164. uses: actions/checkout@v4
  165. with:
  166. fetch-depth: 0
  167. ref: ${{ github.event.inputs.sha || github.event.pull_request.head.sha || github.sha || github.head_ref || github.ref_name }}
  168. - name: libCURL
  169. id: get_libcurl
  170. uses: ./.github/actions/windows-setup-curl
  171. - name: Build
  172. id: cmake_build
  173. env:
  174. CURL_PATH: ${{ steps.get_libcurl.outputs.curl_path }}
  175. run: |
  176. cmake -B build -DCURL_LIBRARY="$env:CURL_PATH/lib/libcurl.dll.a" -DCURL_INCLUDE_DIR="$env:CURL_PATH/include"
  177. cmake --build build --config Release -j ${env:NUMBER_OF_PROCESSORS} --target llama-server
  178. - name: Python setup
  179. id: setup_python
  180. uses: actions/setup-python@v5
  181. with:
  182. python-version: '3.11'
  183. - name: Tests dependencies
  184. id: test_dependencies
  185. run: |
  186. pip install -r tools/server/tests/requirements.txt
  187. - name: Copy Libcurl
  188. id: prepare_libcurl
  189. env:
  190. CURL_PATH: ${{ steps.get_libcurl.outputs.curl_path }}
  191. run: |
  192. cp $env:CURL_PATH/bin/libcurl-x64.dll ./build/bin/Release/libcurl-x64.dll
  193. - name: Tests
  194. id: server_integration_tests
  195. if: ${{ !matrix.disabled_on_pr || !github.event.pull_request }}
  196. run: |
  197. cd tools/server/tests
  198. $env:PYTHONIOENCODING = ":replace"
  199. pytest -v -x -m "not slow"
  200. - name: Slow tests
  201. id: server_integration_tests_slow
  202. if: ${{ (github.event.schedule || github.event.inputs.slow_tests == 'true') && matrix.build_type == 'Release' }}
  203. run: |
  204. cd tools/server/tests
  205. $env:SLOW_TESTS = "1"
  206. pytest -v -x