1
0

server.yml 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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.head_ref && github.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: Tests dependencies
  94. id: test_dependencies
  95. run: |
  96. pip install -r examples/server/tests/requirements.txt
  97. - name: Tests
  98. id: server_integration_tests
  99. if: ${{ !matrix.disabled_on_pr || !github.event.pull_request }}
  100. run: |
  101. cd examples/server/tests
  102. PORT=8888 ./tests.sh
  103. - name: Slow tests
  104. id: server_integration_tests_slow
  105. if: ${{ (github.event.schedule || github.event.inputs.slow_tests == 'true') && matrix.build_type == 'Release' }}
  106. run: |
  107. cd examples/server/tests
  108. PORT=8888 ./tests.sh --stop --no-skipped --no-capture --tags slow
  109. server-windows:
  110. runs-on: windows-latest
  111. steps:
  112. - name: Clone
  113. id: checkout
  114. uses: actions/checkout@v4
  115. with:
  116. fetch-depth: 0
  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