server.yml 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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. concurrency:
  22. group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref || github.run_id }}
  23. cancel-in-progress: true
  24. jobs:
  25. server:
  26. runs-on: ubuntu-latest
  27. strategy:
  28. matrix:
  29. sanitizer: [ADDRESS, UNDEFINED] # THREAD is broken
  30. build_type: [RelWithDebInfo]
  31. include:
  32. - build_type: Release
  33. sanitizer: ""
  34. fail-fast: false # While -DLLAMA_SANITIZE_THREAD=ON is broken
  35. steps:
  36. - name: Dependencies
  37. id: depends
  38. run: |
  39. sudo apt-get update
  40. sudo apt-get -y install \
  41. build-essential \
  42. xxd \
  43. git \
  44. cmake \
  45. curl \
  46. wget \
  47. language-pack-en \
  48. libcurl4-openssl-dev
  49. - name: Clone
  50. id: checkout
  51. uses: actions/checkout@v4
  52. with:
  53. fetch-depth: 0
  54. ref: ${{ github.event.inputs.sha || github.event.pull_request.head.sha || github.sha || github.head_ref || github.ref_name }}
  55. - name: Python setup
  56. id: setup_python
  57. uses: actions/setup-python@v5
  58. with:
  59. python-version: '3.11'
  60. - name: Tests dependencies
  61. id: test_dependencies
  62. run: |
  63. pip install -r examples/server/tests/requirements.txt
  64. - name: Verify server deps
  65. id: verify_server_deps
  66. run: |
  67. git config --global --add safe.directory $(realpath .)
  68. cd examples/server
  69. git ls-files --others --modified
  70. git status
  71. ./deps.sh
  72. git status
  73. not_ignored_files="$(git ls-files --others --modified)"
  74. echo "Modified files: ${not_ignored_files}"
  75. if [ -n "${not_ignored_files}" ]; then
  76. echo "Repository is dirty or server deps are not built as expected"
  77. echo "${not_ignored_files}"
  78. exit 1
  79. fi
  80. - name: Build (no OpenMP)
  81. id: cmake_build_no_openmp
  82. if: ${{ matrix.sanitizer == 'THREAD' }}
  83. run: |
  84. cmake -B build \
  85. -DLLAMA_NATIVE=OFF \
  86. -DLLAMA_BUILD_SERVER=ON \
  87. -DLLAMA_CURL=ON \
  88. -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
  89. -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON \
  90. -DLLAMA_OPENMP=OFF ;
  91. cmake --build build --config ${{ matrix.build_type }} -j $(nproc) --target llama-server
  92. - name: Build
  93. id: cmake_build
  94. if: ${{ matrix.sanitizer != 'THREAD' }}
  95. run: |
  96. cmake -B build \
  97. -DLLAMA_NATIVE=OFF \
  98. -DLLAMA_BUILD_SERVER=ON \
  99. -DLLAMA_CURL=ON \
  100. -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
  101. -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON ;
  102. cmake --build build --config ${{ matrix.build_type }} -j $(nproc) --target llama-server
  103. - name: Tests
  104. id: server_integration_tests
  105. run: |
  106. cd examples/server/tests
  107. PORT=8888 ./tests.sh
  108. - name: Slow tests
  109. id: server_integration_tests_slow
  110. if: ${{ (github.event.schedule || github.event.inputs.slow_tests == 'true') && matrix.build_type == 'Release' }}
  111. run: |
  112. cd examples/server/tests
  113. PORT=8888 ./tests.sh --stop --no-skipped --no-capture --tags slow
  114. server-windows:
  115. runs-on: windows-2019
  116. steps:
  117. - name: Clone
  118. id: checkout
  119. uses: actions/checkout@v4
  120. with:
  121. fetch-depth: 0
  122. ref: ${{ github.event.inputs.sha || github.event.pull_request.head.sha || github.sha || github.head_ref || github.ref_name }}
  123. - name: libCURL
  124. id: get_libcurl
  125. env:
  126. CURL_VERSION: 8.6.0_6
  127. run: |
  128. curl.exe -o $env:RUNNER_TEMP/curl.zip -L "https://curl.se/windows/dl-${env:CURL_VERSION}/curl-${env:CURL_VERSION}-win64-mingw.zip"
  129. mkdir $env:RUNNER_TEMP/libcurl
  130. tar.exe -xvf $env:RUNNER_TEMP/curl.zip --strip-components=1 -C $env:RUNNER_TEMP/libcurl
  131. - name: Build
  132. id: cmake_build
  133. run: |
  134. cmake -B build -DLLAMA_CURL=ON -DCURL_LIBRARY="$env:RUNNER_TEMP/libcurl/lib/libcurl.dll.a" -DCURL_INCLUDE_DIR="$env:RUNNER_TEMP/libcurl/include"
  135. cmake --build build --config Release -j ${env:NUMBER_OF_PROCESSORS} --target llama-server
  136. - name: Python setup
  137. id: setup_python
  138. uses: actions/setup-python@v5
  139. with:
  140. python-version: '3.11'
  141. - name: Tests dependencies
  142. id: test_dependencies
  143. run: |
  144. pip install -r examples/server/tests/requirements.txt
  145. - name: Copy Libcurl
  146. id: prepare_libcurl
  147. run: |
  148. cp $env:RUNNER_TEMP/libcurl/bin/libcurl-x64.dll ./build/bin/Release/libcurl-x64.dll
  149. - name: Tests
  150. id: server_integration_tests
  151. if: ${{ !matrix.disabled_on_pr || !github.event.pull_request }}
  152. run: |
  153. cd examples/server/tests
  154. behave.exe --summary --stop --no-capture --exclude 'issues|wrong_usages|passkey' --tags llama.cpp
  155. - name: Slow tests
  156. id: server_integration_tests_slow
  157. if: ${{ (github.event.schedule || github.event.inputs.slow_tests == 'true') && matrix.build_type == 'Release' }}
  158. run: |
  159. cd examples/server/tests
  160. behave.exe --stop --no-skipped --no-capture --tags slow