server.yml 5.5 KB

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