server.yml 5.7 KB

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