1
0

server.yml 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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', 'examples/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', 'examples/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 examples/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 examples/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 examples/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 examples/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. -DLLAMA_CURL=ON \
  117. -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
  118. -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON \
  119. -DGGML_OPENMP=OFF ;
  120. cmake --build build --config ${{ matrix.build_type }} -j $(nproc) --target llama-server
  121. - name: Build (sanitizers)
  122. id: cmake_build_sanitizers
  123. if: ${{ matrix.sanitizer != '' && matrix.sanitizer != 'THREAD' }}
  124. run: |
  125. cmake -B build \
  126. -DGGML_NATIVE=OFF \
  127. -DLLAMA_BUILD_SERVER=ON \
  128. -DLLAMA_CURL=ON \
  129. -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
  130. -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON ;
  131. cmake --build build --config ${{ matrix.build_type }} -j $(nproc) --target llama-server
  132. - name: Build (sanitizers)
  133. id: cmake_build
  134. if: ${{ matrix.sanitizer == '' }}
  135. run: |
  136. cmake -B build \
  137. -DGGML_NATIVE=OFF \
  138. -DLLAMA_BUILD_SERVER=ON \
  139. -DLLAMA_CURL=ON \
  140. -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} ;
  141. cmake --build build --config ${{ matrix.build_type }} -j $(nproc) --target llama-server
  142. - name: Tests
  143. id: server_integration_tests
  144. if: ${{ matrix.sanitizer == '' }}
  145. env:
  146. GITHUB_ACTIONS: "true"
  147. run: |
  148. cd examples/server/tests
  149. ./tests.sh
  150. - name: Tests (sanitizers)
  151. id: server_integration_tests_sanitizers
  152. if: ${{ matrix.sanitizer != '' }}
  153. run: |
  154. cd examples/server/tests
  155. LLAMA_SANITIZE=1 ./tests.sh
  156. - name: Slow tests
  157. id: server_integration_tests_slow
  158. if: ${{ (github.event.schedule || github.event.inputs.slow_tests == 'true') && matrix.build_type == 'Release' }}
  159. run: |
  160. cd examples/server/tests
  161. SLOW_TESTS=1 ./tests.sh
  162. server-windows:
  163. runs-on: windows-2019
  164. steps:
  165. - name: Clone
  166. id: checkout
  167. uses: actions/checkout@v4
  168. with:
  169. fetch-depth: 0
  170. ref: ${{ github.event.inputs.sha || github.event.pull_request.head.sha || github.sha || github.head_ref || github.ref_name }}
  171. - name: libCURL
  172. id: get_libcurl
  173. env:
  174. CURL_VERSION: 8.6.0_6
  175. run: |
  176. curl.exe -o $env:RUNNER_TEMP/curl.zip -L "https://curl.se/windows/dl-${env:CURL_VERSION}/curl-${env:CURL_VERSION}-win64-mingw.zip"
  177. mkdir $env:RUNNER_TEMP/libcurl
  178. tar.exe -xvf $env:RUNNER_TEMP/curl.zip --strip-components=1 -C $env:RUNNER_TEMP/libcurl
  179. - name: Build
  180. id: cmake_build
  181. run: |
  182. cmake -B build -DLLAMA_CURL=ON -DCURL_LIBRARY="$env:RUNNER_TEMP/libcurl/lib/libcurl.dll.a" -DCURL_INCLUDE_DIR="$env:RUNNER_TEMP/libcurl/include"
  183. cmake --build build --config Release -j ${env:NUMBER_OF_PROCESSORS} --target llama-server
  184. - name: Python setup
  185. id: setup_python
  186. uses: actions/setup-python@v5
  187. with:
  188. python-version: '3.11'
  189. - name: Tests dependencies
  190. id: test_dependencies
  191. run: |
  192. pip install -r examples/server/tests/requirements.txt
  193. - name: Copy Libcurl
  194. id: prepare_libcurl
  195. run: |
  196. cp $env:RUNNER_TEMP/libcurl/bin/libcurl-x64.dll ./build/bin/Release/libcurl-x64.dll
  197. - name: Tests
  198. id: server_integration_tests
  199. if: ${{ !matrix.disabled_on_pr || !github.event.pull_request }}
  200. run: |
  201. cd examples/server/tests
  202. $env:PYTHONIOENCODING = ":replace"
  203. pytest -v -x -m "not slow"
  204. - name: Slow tests
  205. id: server_integration_tests_slow
  206. if: ${{ (github.event.schedule || github.event.inputs.slow_tests == 'true') && matrix.build_type == 'Release' }}
  207. run: |
  208. cd examples/server/tests
  209. $env:SLOW_TESTS = "1"
  210. pytest -v -x