server.yml 5.7 KB

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