server.yml 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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, THREAD, UNDEFINED]
  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
  81. id: cmake_build
  82. run: |
  83. cmake -B build \
  84. -DLLAMA_NATIVE=OFF \
  85. -DLLAMA_BUILD_SERVER=ON \
  86. -DLLAMA_CURL=ON \
  87. -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
  88. -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON ;
  89. cmake --build build --config ${{ matrix.build_type }} -j $(nproc) --target llama-server
  90. - name: Tests
  91. id: server_integration_tests
  92. run: |
  93. cd examples/server/tests
  94. PORT=8888 ./tests.sh
  95. - name: Slow tests
  96. id: server_integration_tests_slow
  97. if: ${{ (github.event.schedule || github.event.inputs.slow_tests == 'true') && matrix.build_type == 'Release' }}
  98. run: |
  99. cd examples/server/tests
  100. PORT=8888 ./tests.sh --stop --no-skipped --no-capture --tags slow
  101. server-windows:
  102. runs-on: windows-2019
  103. steps:
  104. - name: Clone
  105. id: checkout
  106. uses: actions/checkout@v4
  107. with:
  108. fetch-depth: 0
  109. ref: ${{ github.event.inputs.sha || github.event.pull_request.head.sha || github.sha || github.head_ref || github.ref_name }}
  110. - name: libCURL
  111. id: get_libcurl
  112. env:
  113. CURL_VERSION: 8.6.0_6
  114. run: |
  115. curl.exe -o $env:RUNNER_TEMP/curl.zip -L "https://curl.se/windows/dl-${env:CURL_VERSION}/curl-${env:CURL_VERSION}-win64-mingw.zip"
  116. mkdir $env:RUNNER_TEMP/libcurl
  117. tar.exe -xvf $env:RUNNER_TEMP/curl.zip --strip-components=1 -C $env:RUNNER_TEMP/libcurl
  118. - name: Build
  119. id: cmake_build
  120. run: |
  121. cmake -B build -DLLAMA_CURL=ON -DCURL_LIBRARY="$env:RUNNER_TEMP/libcurl/lib/libcurl.dll.a" -DCURL_INCLUDE_DIR="$env:RUNNER_TEMP/libcurl/include"
  122. cmake --build build --config Release -j ${env:NUMBER_OF_PROCESSORS} --target llama-server
  123. - name: Python setup
  124. id: setup_python
  125. uses: actions/setup-python@v5
  126. with:
  127. python-version: '3.11'
  128. - name: Tests dependencies
  129. id: test_dependencies
  130. run: |
  131. pip install -r examples/server/tests/requirements.txt
  132. - name: Copy Libcurl
  133. id: prepare_libcurl
  134. run: |
  135. cp $env:RUNNER_TEMP/libcurl/bin/libcurl-x64.dll ./build/bin/Release/libcurl-x64.dll
  136. - name: Tests
  137. id: server_integration_tests
  138. if: ${{ !matrix.disabled_on_pr || !github.event.pull_request }}
  139. run: |
  140. cd examples/server/tests
  141. behave.exe --summary --stop --no-capture --exclude 'issues|wrong_usages|passkey' --tags llama.cpp
  142. - name: Slow tests
  143. id: server_integration_tests_slow
  144. if: ${{ (github.event.schedule || github.event.inputs.slow_tests == 'true') && matrix.build_type == 'Release' }}
  145. run: |
  146. cd examples/server/tests
  147. behave.exe --stop --no-skipped --no-capture --tags slow