Skip to content

Commit 81e8352

Browse files
authored
Create server.yml
1 parent 8527f08 commit 81e8352

File tree

1 file changed

+191
-0
lines changed

1 file changed

+191
-0
lines changed

.github/workflows/server.yml

Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
# Server build and tests
2+
name: Server
3+
4+
on:
5+
workflow_dispatch: # allows manual triggering
6+
inputs:
7+
sha:
8+
description: 'Commit SHA1 to build'
9+
required: false
10+
type: string
11+
slow_tests:
12+
description: 'Run slow tests'
13+
required: true
14+
type: boolean
15+
push:
16+
branches:
17+
- master
18+
paths: ['.github/workflows/server.yml', '**/CMakeLists.txt', '**/Makefile', '**/*.h', '**/*.hpp', '**/*.c', '**/*.cpp', '**/*.cu', '**/*.swift', '**/*.m', 'examples/server/**.*']
19+
pull_request:
20+
types: [opened, synchronize, reopened]
21+
paths: ['.github/workflows/server.yml', '**/CMakeLists.txt', '**/Makefile', '**/*.h', '**/*.hpp', '**/*.c', '**/*.cpp', '**/*.cu', '**/*.swift', '**/*.m', 'examples/server/**.*']
22+
23+
env:
24+
LLAMA_LOG_COLORS: 1
25+
LLAMA_LOG_PREFIX: 1
26+
LLAMA_LOG_TIMESTAMPS: 1
27+
LLAMA_LOG_VERBOSITY: 10
28+
29+
concurrency:
30+
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref || github.run_id }}
31+
cancel-in-progress: true
32+
33+
jobs:
34+
server:
35+
runs-on: ubuntu-latest
36+
37+
strategy:
38+
matrix:
39+
sanitizer: [ADDRESS, UNDEFINED] # THREAD is broken
40+
build_type: [RelWithDebInfo]
41+
include:
42+
- build_type: Release
43+
sanitizer: ""
44+
fail-fast: false # While -DLLAMA_SANITIZE_THREAD=ON is broken
45+
46+
steps:
47+
- name: Dependencies
48+
id: depends
49+
run: |
50+
sudo apt-get update
51+
sudo apt-get -y install \
52+
build-essential \
53+
xxd \
54+
git \
55+
cmake \
56+
curl \
57+
wget \
58+
language-pack-en \
59+
libcurl4-openssl-dev
60+
61+
- name: Clone
62+
id: checkout
63+
uses: actions/checkout@v4
64+
with:
65+
fetch-depth: 0
66+
ref: ${{ github.event.inputs.sha || github.event.pull_request.head.sha || github.sha || github.head_ref || github.ref_name }}
67+
68+
- name: Python setup
69+
id: setup_python
70+
uses: actions/setup-python@v5
71+
with:
72+
python-version: '3.11'
73+
74+
- name: Tests dependencies
75+
id: test_dependencies
76+
run: |
77+
pip install -r examples/server/tests/requirements.txt
78+
79+
- name: Verify server deps
80+
id: verify_server_deps
81+
run: |
82+
git config --global --add safe.directory $(realpath .)
83+
cd examples/server
84+
git ls-files --others --modified
85+
git status
86+
./deps.sh
87+
git status
88+
not_ignored_files="$(git ls-files --others --modified)"
89+
echo "Modified files: ${not_ignored_files}"
90+
if [ -n "${not_ignored_files}" ]; then
91+
echo "Repository is dirty or server deps are not built as expected"
92+
echo "${not_ignored_files}"
93+
exit 1
94+
fi
95+
96+
- name: Build (no OpenMP)
97+
id: cmake_build_no_openmp
98+
if: ${{ matrix.sanitizer == 'THREAD' }}
99+
run: |
100+
cmake -B build \
101+
-DGGML_NATIVE=OFF \
102+
-DLLAMA_BUILD_SERVER=ON \
103+
-DLLAMA_CURL=ON \
104+
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
105+
-DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON \
106+
-DGGML_OPENMP=OFF ;
107+
cmake --build build --config ${{ matrix.build_type }} -j $(nproc) --target llama-server
108+
109+
- name: Build
110+
id: cmake_build
111+
if: ${{ matrix.sanitizer != 'THREAD' }}
112+
run: |
113+
cmake -B build \
114+
-DGGML_NATIVE=OFF \
115+
-DLLAMA_BUILD_SERVER=ON \
116+
-DLLAMA_CURL=ON \
117+
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
118+
-DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON ;
119+
cmake --build build --config ${{ matrix.build_type }} -j $(nproc) --target llama-server
120+
121+
- name: Tests
122+
id: server_integration_tests
123+
run: |
124+
cd examples/server/tests
125+
./tests.sh
126+
127+
- name: Slow tests
128+
id: server_integration_tests_slow
129+
if: ${{ (github.event.schedule || github.event.inputs.slow_tests == 'true') && matrix.build_type == 'Release' }}
130+
run: |
131+
cd examples/server/tests
132+
SLOW_TESTS=1 ./tests.sh
133+
134+
135+
server-windows:
136+
runs-on: windows-2019
137+
138+
steps:
139+
- name: Clone
140+
id: checkout
141+
uses: actions/checkout@v4
142+
with:
143+
fetch-depth: 0
144+
ref: ${{ github.event.inputs.sha || github.event.pull_request.head.sha || github.sha || github.head_ref || github.ref_name }}
145+
146+
- name: libCURL
147+
id: get_libcurl
148+
env:
149+
CURL_VERSION: 8.6.0_6
150+
run: |
151+
curl.exe -o $env:RUNNER_TEMP/curl.zip -L "https://curl.se/windows/dl-${env:CURL_VERSION}/curl-${env:CURL_VERSION}-win64-mingw.zip"
152+
mkdir $env:RUNNER_TEMP/libcurl
153+
tar.exe -xvf $env:RUNNER_TEMP/curl.zip --strip-components=1 -C $env:RUNNER_TEMP/libcurl
154+
155+
- name: Build
156+
id: cmake_build
157+
run: |
158+
cmake -B build -DLLAMA_CURL=ON -DCURL_LIBRARY="$env:RUNNER_TEMP/libcurl/lib/libcurl.dll.a" -DCURL_INCLUDE_DIR="$env:RUNNER_TEMP/libcurl/include"
159+
cmake --build build --config Release -j ${env:NUMBER_OF_PROCESSORS} --target llama-server
160+
161+
- name: Python setup
162+
id: setup_python
163+
uses: actions/setup-python@v5
164+
with:
165+
python-version: '3.11'
166+
167+
- name: Tests dependencies
168+
id: test_dependencies
169+
run: |
170+
pip install -r examples/server/tests/requirements.txt
171+
172+
- name: Copy Libcurl
173+
id: prepare_libcurl
174+
run: |
175+
cp $env:RUNNER_TEMP/libcurl/bin/libcurl-x64.dll ./build/bin/Release/libcurl-x64.dll
176+
177+
- name: Tests
178+
id: server_integration_tests
179+
if: ${{ !matrix.disabled_on_pr || !github.event.pull_request }}
180+
run: |
181+
cd examples/server/tests
182+
$env:PYTHONIOENCODING = ":replace"
183+
pytest -v -x
184+
185+
- name: Slow tests
186+
id: server_integration_tests_slow
187+
if: ${{ (github.event.schedule || github.event.inputs.slow_tests == 'true') && matrix.build_type == 'Release' }}
188+
run: |
189+
cd examples/server/tests
190+
$env:SLOW_TESTS = "1"
191+
pytest -v -x

0 commit comments

Comments
 (0)