-
Notifications
You must be signed in to change notification settings - Fork 18
355 lines (286 loc) · 9.15 KB
/
test.yml
File metadata and controls
355 lines (286 loc) · 9.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
name: Ahnlich TestSuite
on:
push:
branches: ["main"]
paths:
- ahnlich/**
- sdk/**
pull_request:
branches: ["main"]
paths:
- ahnlich/**
- sdk/**
env:
CARGO_TERM_COLOR: always
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
jobs:
run-rust-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up sccache
uses: mozilla-actions/sccache-action@v0.0.9
- name: Set up Rust cache
uses: Swatinem/rust-cache@v2
with:
workspaces: ahnlich
shared-key: ahnlich-rust
- name: Set up cargo and rustup tools
run: |
which cargo-nextest || cargo install --locked cargo-nextest
- name: Install protoc
run: |
sudo apt-get update
sudo apt-get install -y protobuf-compiler
- name: Cache Docker images.
uses: ScribeMD/docker-cache@0.5.0
with:
key: ${{ runner.os }}-cargo-${{ hashFiles('ahnlich/Cargo.lock') }}
- name: Cache Ahnlich Home directory images.
uses: actions/cache@v4
with:
path: ~/.ahnlich
key: ${{ runner.os }}-ahnlich-models
- name: Format and Lint
working-directory: ./ahnlich
run: |
make format
make clippy
- name: Check Rust Client is up to date
working-directory: ./ahnlich
run: |
make grpc-update-rust
if [[ -n "$(git status . --porcelain)" ]]; then
echo "::error::Running 'make grpc-update-rust' caused changes, Please check that rust client is up to date"
git --no-pager diff .
exit 1
fi
- name: Detect changed rust files in workspace
uses: dorny/paths-filter@v3
id: changes
with:
filters: |
ai:
- 'ahnlich/ai/**'
types:
- 'ahnlich/types/**'
- name: Build and Format Rust Example
working-directory: ./examples/rust/image-search
run: |
cargo b && cargo fmt
- name: Run Full Workspace Tests
if: steps.changes.outputs.ai == 'true' || steps.changes.outputs.types == 'true'
working-directory: ./ahnlich
run: make test
- name: Run Workspace Tests (excluding AI)
if: steps.changes.outputs.ai != 'true' && steps.changes.outputs.types != 'true'
working-directory: ./ahnlich
run: cargo nextest run --workspace --exclude ai --no-capture
- name: Upload Test Results
uses: actions/upload-artifact@v4
if: always()
with:
name: rust
path: ahnlich/target/nextest/default/rust.xml
run-python-tests:
if: always()
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up sccache
uses: mozilla-actions/sccache-action@v0.0.9
- name: Set up Rust cache
uses: Swatinem/rust-cache@v2
with:
workspaces: ahnlich
shared-key: ahnlich-rust
- uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Run image
uses: abatilo/actions-poetry@v3
with:
poetry-version: 1.7.0
- name: View poetry --help
run: poetry --help
- name: Cache using poetry lock
uses: actions/cache@v4
with:
path: ./.venv
key: venv-${{ hashFiles('poetry.lock') }}
- name: Installing poetry dependencies
working-directory: ./sdk/ahnlich-client-py
run: poetry install
- name: Check Python Linting
working-directory: ./sdk/ahnlich-client-py
run: |
poetry run isort . -c --profile black; echo $?
poetry run black . --check; echo $?
- name: Install protoc
run: |
sudo apt-get update
sudo apt-get install -y protobuf-compiler
- name: Complie Binaries
working-directory: ./ahnlich
run: |
cargo build
- name: Check Python Client is up to date
working-directory: ./ahnlich
run: |
make grpc-update-python
if [[ -n "$(git status ../sdk/ahnlich-client-py --porcelain)" ]]; then
echo "::error::Running 'make grpc-update-python' caused changes, Please check that python client is up to date"
git --no-pager diff ../sdk/ahnlich-client-py
exit 1
fi
- name: Run Python Client Tests
working-directory: ./sdk/ahnlich-client-py
env:
AHNLICH_DB_HOST: "127.0.0.1"
AHNLICH_DB_PORT: 1349
AHNLICH_AI_HOST: "127.0.0.1"
AHNLICH_AI_PORT: 8000
run: |
poetry run pytest -s -vv --junitxml=./python.xml
- name: Upload Test Results
uses: actions/upload-artifact@v4
if: always()
with:
name: python
path: sdk/ahnlich-client-py/python.xml
run-go-tests:
if: always()
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up sccache
uses: mozilla-actions/sccache-action@v0.0.9
- name: Set up Rust cache
uses: Swatinem/rust-cache@v2
with:
workspaces: ahnlich
shared-key: ahnlich-rust
- name: Install Protoc
uses: arduino/setup-protoc@v3
- name: Setup buf
uses: bufbuild/buf-setup-action@v1
- name: Setup Go Environment
uses: actions/setup-go@v5
with:
go-version: 1.22
cache-dependency-path: ./sdk/ahnlich-client-go/go.sum
- name: Install Dependencies
working-directory: ./sdk/ahnlich-client-go
run: make install-dependencies CI=1
- name: Format and Lint Check
working-directory: ./sdk/ahnlich-client-go
run: make pre-commit-check
# TODO: enable once Go grpc formatting is stabilised
# - name: Check Go client is up to date
# working-directory: ./ahnlich
# run: |
# make grpc-update-go
# if [[ -n "$(git status ../sdk/ahnlich-client-go --porcelain)" ]]; then
# echo "::error::Running 'make grpc-update-go' caused changes. Please check that the Go client is up to date"
# git --no-pager diff ../sdk/ahnlich-client-go
# exit 1
# fi
- name: Run Tests
working-directory: ./sdk/ahnlich-client-go
run: |
make test CACHE=1 REPORT=1
- name: Upload Test Results
uses: actions/upload-artifact@v4
if: always()
with:
name: go
path: sdk/ahnlich-client-go/go.xml
run-node-tests:
if: always()
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up sccache
uses: mozilla-actions/sccache-action@v0.0.9
- name: Set up Rust cache
uses: Swatinem/rust-cache@v2
with:
workspaces: ahnlich
shared-key: ahnlich-rust
- name: Cache Ahnlich Home directory
uses: actions/cache@v4
with:
path: ~/.ahnlich
key: ${{ runner.os }}-ahnlich-models
- name: Install Protoc
run: |
sudo apt-get update
sudo apt-get install -y protobuf-compiler
- name: Setup buf
uses: bufbuild/buf-setup-action@v1
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 22
- name: Install Dependencies
working-directory: ./sdk/ahnlich-client-node
run: make install-dependencies
- name: Format Check
working-directory: ./sdk/ahnlich-client-node
run: make pre-commit-check
- name: Check Node client is up to date
working-directory: ./ahnlich
run: |
make grpc-update-node
if [[ -n "$(git status ../sdk/ahnlich-client-node/grpc --porcelain)" ]]; then
echo "::error::Running 'make grpc-update-node' caused changes. Please check that the Node client is up to date"
git --no-pager diff ../sdk/ahnlich-client-node/grpc
exit 1
fi
- name: Build Binaries
working-directory: ./ahnlich
run: cargo build --bin ahnlich-db --bin ahnlich-ai
- name: Run Tests
working-directory: ./sdk/ahnlich-client-node
run: make test REPORT=1
- name: Upload Test Results
uses: actions/upload-artifact@v4
if: always()
with:
name: node
path: sdk/ahnlich-client-node/node.xml
upload-test-results:
if: always()
runs-on: ubuntu-latest
needs: ["run-rust-tests", "run-python-tests", "run-go-tests", "run-node-tests"]
steps:
- name: Download Rust Test Output
uses: actions/download-artifact@v4
with:
name: rust
path: ./rust
- name: Download Python Test Output
uses: actions/download-artifact@v4
with:
name: python
path: ./python
- name: Download Go Test Output
uses: actions/download-artifact@v4
with:
name: go
path: ./go
- name: Download Node Test Output
uses: actions/download-artifact@v4
with:
name: node
path: ./node
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action/macos@v2
if: always()
with:
files: |
rust/*.xml
python/*.xml
go/*.xml
node/*.xml