server.yml 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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. python3-venv \
  56. curl \
  57. wget \
  58. language-pack-en \
  59. libcurl4-openssl-dev
  60. - name: Clone
  61. id: checkout
  62. uses: actions/checkout@v4
  63. with:
  64. fetch-depth: 0
  65. ref: ${{ github.event.inputs.sha || github.event.pull_request.head.sha || github.sha || github.head_ref || github.ref_name }}
  66. - name: Verify server deps
  67. id: verify_server_deps
  68. run: |
  69. git config --global --add safe.directory $(realpath .)
  70. cd examples/server
  71. git ls-files --others --modified
  72. git status
  73. ./deps.sh
  74. git status
  75. not_ignored_files="$(git ls-files --others --modified)"
  76. echo "Modified files: ${not_ignored_files}"
  77. if [ -n "${not_ignored_files}" ]; then
  78. echo "Repository is dirty or server deps are not built as expected"
  79. echo "${not_ignored_files}"
  80. exit 1
  81. fi
  82. - name: Build
  83. id: cmake_build
  84. run: |
  85. mkdir build
  86. cd build
  87. cmake .. \
  88. -DLLAMA_NATIVE=OFF \
  89. -DLLAMA_BUILD_SERVER=ON \
  90. -DLLAMA_CURL=ON \
  91. -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
  92. -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON ;
  93. cmake --build . --config ${{ matrix.build_type }} -j $(nproc) --target server
  94. - name: Setup python env
  95. id: pipenv
  96. run: |
  97. cd examples/server/tests
  98. python3 -m venv venv
  99. . venv/bin/activate
  100. pip install -r requirements.txt
  101. - name: Tests
  102. id: server_integration_tests
  103. if: ${{ !matrix.disabled_on_pr || !github.event.pull_request }}
  104. run: |
  105. cd examples/server/tests
  106. PORT=8888 ./tests.sh
  107. - name: Slow tests
  108. id: server_integration_tests_slow
  109. if: ${{ (github.event.schedule || github.event.inputs.slow_tests == 'true') && matrix.build_type == 'Release' }}
  110. run: |
  111. cd examples/server/tests
  112. PORT=8888 ./tests.sh --stop --no-skipped --no-capture --tags slow
  113. server-windows:
  114. runs-on: windows-latest
  115. steps:
  116. - name: Clone
  117. id: checkout
  118. uses: actions/checkout@v4
  119. with:
  120. fetch-depth: 0
  121. - name: libCURL
  122. id: get_libcurl
  123. env:
  124. CURL_VERSION: 8.6.0_6
  125. run: |
  126. curl.exe -o $env:RUNNER_TEMP/curl.zip -L "https://curl.se/windows/dl-${env:CURL_VERSION}/curl-${env:CURL_VERSION}-win64-mingw.zip"
  127. mkdir $env:RUNNER_TEMP/libcurl
  128. tar.exe -xvf $env:RUNNER_TEMP/curl.zip --strip-components=1 -C $env:RUNNER_TEMP/libcurl
  129. - name: Build
  130. id: cmake_build
  131. run: |
  132. mkdir build
  133. cd build
  134. cmake .. -DLLAMA_CURL=ON -DCURL_LIBRARY="$env:RUNNER_TEMP/libcurl/lib/libcurl.dll.a" -DCURL_INCLUDE_DIR="$env:RUNNER_TEMP/libcurl/include"
  135. cmake --build . --config Release -j ${env:NUMBER_OF_PROCESSORS} --target 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