server.yml 5.6 KB

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