server.yml 6.9 KB

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