1# Server build and tests
2name: Server
3
4on:
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', 'tools/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', 'tools/server/**.*']
22
23env:
24 LLAMA_LOG_COLORS: 1
25 LLAMA_LOG_PREFIX: 1
26 LLAMA_LOG_TIMESTAMPS: 1
27 LLAMA_LOG_VERBOSITY: 10
28
29concurrency:
30 group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref || github.run_id }}
31 cancel-in-progress: true
32
33jobs:
34 server:
35 runs-on: ubuntu-latest
36
37 strategy:
38 matrix:
39 sanitizer: [ADDRESS, UNDEFINED] # THREAD is very slow
40 build_type: [RelWithDebInfo]
41 include:
42 - build_type: Release
43 sanitizer: ""
44 extra_args: ""
45 - build_type: Release
46 sanitizer: ""
47 extra_args: "LLAMA_ARG_BACKEND_SAMPLING=1"
48 fail-fast: false
49
50 steps:
51 - name: Dependencies
52 id: depends
53 run: |
54 sudo apt-get update
55 sudo apt-get -y install \
56 build-essential \
57 xxd \
58 git \
59 cmake \
60 curl \
61 wget \
62 language-pack-en \
63 libssl-dev
64
65 - name: Clone
66 id: checkout
67 uses: actions/checkout@v6
68 with:
69 fetch-depth: 0
70 ref: ${{ github.event.inputs.sha || github.event.pull_request.head.sha || github.sha || github.head_ref || github.ref_name }}
71
72 - name: Build
73 id: cmake_build
74 run: |
75 cmake -B build \
76 -DLLAMA_BUILD_BORINGSSL=ON \
77 -DGGML_SCHED_NO_REALLOC=ON \
78 -DGGML_SANITIZE_ADDRESS=${{ matrix.sanitizer == 'ADDRESS' }} \
79 -DGGML_SANITIZE_THREAD=${{ matrix.sanitizer == 'THREAD' }} \
80 -DGGML_SANITIZE_UNDEFINED=${{ matrix.sanitizer == 'UNDEFINED' }} \
81 -DLLAMA_SANITIZE_ADDRESS=${{ matrix.sanitizer == 'ADDRESS' }} \
82 -DLLAMA_SANITIZE_THREAD=${{ matrix.sanitizer == 'THREAD' }} \
83 -DLLAMA_SANITIZE_UNDEFINED=${{ matrix.sanitizer == 'UNDEFINED' }}
84 cmake --build build --config ${{ matrix.build_type }} -j $(nproc) --target llama-server
85
86 - name: Python setup
87 id: setup_python
88 uses: actions/setup-python@v6
89 with:
90 python-version: '3.11'
91 pip-install: -r tools/server/tests/requirements.txt
92
93 - name: Tests
94 id: server_integration_tests
95 if: ${{ (!matrix.disabled_on_pr || !github.event.pull_request) }}
96 run: |
97 cd tools/server/tests
98 export ${{ matrix.extra_args }}
99 pytest -v -x -m "not slow"
100
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 tools/server/tests
106 export ${{ matrix.extra_args }}
107 SLOW_TESTS=1 pytest -v -x
108
109 server-windows:
110 runs-on: windows-2022
111
112 steps:
113 - name: Clone
114 id: checkout
115 uses: actions/checkout@v6
116 with:
117 fetch-depth: 0
118 ref: ${{ github.event.inputs.sha || github.event.pull_request.head.sha || github.sha || github.head_ref || github.ref_name }}
119
120 - name: Build
121 id: cmake_build
122 run: |
123 cmake -B build -DLLAMA_BUILD_BORINGSSL=ON -DGGML_SCHED_NO_REALLOC=ON
124 cmake --build build --config Release -j ${env:NUMBER_OF_PROCESSORS} --target llama-server
125
126 - name: Python setup
127 id: setup_python
128 uses: actions/setup-python@v6
129 with:
130 python-version: '3.11'
131 pip-install: -r tools/server/tests/requirements.txt
132
133 - name: Tests
134 id: server_integration_tests
135 if: ${{ !matrix.disabled_on_pr || !github.event.pull_request }}
136 run: |
137 cd tools/server/tests
138 $env:PYTHONIOENCODING = ":replace"
139 pytest -v -x -m "not slow"
140
141 - name: Slow tests
142 id: server_integration_tests_slow
143 if: ${{ (github.event.schedule || github.event.inputs.slow_tests == 'true') && matrix.build_type == 'Release' }}
144 run: |
145 cd tools/server/tests
146 $env:SLOW_TESTS = "1"
147 pytest -v -x