server.yml 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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
  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
  103. id: cmake_build
  104. if: ${{ 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: Tests
  114. id: server_integration_tests
  115. run: |
  116. cd examples/server/tests
  117. ./tests.sh
  118. - name: Slow tests
  119. id: server_integration_tests_slow
  120. if: ${{ (github.event.schedule || github.event.inputs.slow_tests == 'true') && matrix.build_type == 'Release' }}
  121. run: |
  122. cd examples/server/tests
  123. SLOW_TESTS=1 ./tests.sh
  124. server-windows:
  125. runs-on: windows-2019
  126. steps:
  127. - name: Clone
  128. id: checkout
  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: libCURL
  134. id: get_libcurl
  135. env:
  136. CURL_VERSION: 8.6.0_6
  137. run: |
  138. curl.exe -o $env:RUNNER_TEMP/curl.zip -L "https://curl.se/windows/dl-${env:CURL_VERSION}/curl-${env:CURL_VERSION}-win64-mingw.zip"
  139. mkdir $env:RUNNER_TEMP/libcurl
  140. tar.exe -xvf $env:RUNNER_TEMP/curl.zip --strip-components=1 -C $env:RUNNER_TEMP/libcurl
  141. - name: Build
  142. id: cmake_build
  143. run: |
  144. cmake -B build -DLLAMA_CURL=ON -DCURL_LIBRARY="$env:RUNNER_TEMP/libcurl/lib/libcurl.dll.a" -DCURL_INCLUDE_DIR="$env:RUNNER_TEMP/libcurl/include"
  145. cmake --build build --config Release -j ${env:NUMBER_OF_PROCESSORS} --target llama-server
  146. - name: Python setup
  147. id: setup_python
  148. uses: actions/setup-python@v5
  149. with:
  150. python-version: '3.11'
  151. - name: Tests dependencies
  152. id: test_dependencies
  153. run: |
  154. pip install -r examples/server/tests/requirements.txt
  155. - name: Copy Libcurl
  156. id: prepare_libcurl
  157. run: |
  158. cp $env:RUNNER_TEMP/libcurl/bin/libcurl-x64.dll ./build/bin/Release/libcurl-x64.dll
  159. - name: Tests
  160. id: server_integration_tests
  161. if: ${{ !matrix.disabled_on_pr || !github.event.pull_request }}
  162. run: |
  163. cd examples/server/tests
  164. $env:PYTHONIOENCODING = ":replace"
  165. pytest -v -x
  166. - name: Slow tests
  167. id: server_integration_tests_slow
  168. if: ${{ (github.event.schedule || github.event.inputs.slow_tests == 'true') && matrix.build_type == 'Release' }}
  169. run: |
  170. cd examples/server/tests
  171. $env:SLOW_TESTS = "1"
  172. pytest -v -x