Repository navigation
244 lines (223 loc) · 10.1 KB
/
Copy path_unit-test.yml
File metadata and controls
244 lines (223 loc) · 10.1 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
name: Unit Test
# Single reusable test driver. Caller picks the language; matrix fans
# out across linux-arm64 + windows-arm64. Six call sites total —
# (test-sdk-ci | test-python | test-go) × (linux-arm64 | windows-arm64)
# — each surfacing as `<caller-job> / <platform>` in the Checks UI.
#
# All three languages need the SDK artifact: test-sdk-ci and test-python
# dlopen libgeniex; test-go links bindings/go's cgo against it. So this
# reusable always downloads sdk-${platform}.
#
# On linux-arm64 the SDK is cross-compiled in a ubuntu:24.04 toolchain
# (GLIBC_2.39); the runner host is older, so any test step that loads
# libgeniex.so must run inside ubuntu:24.04 too — see
# .github/actions/run-in-ubuntu24/. Windows runs everything directly on
# the host (no GLIBC concerns; runner ships Python 3.13 ARM64 +
# bazelisk).
on:
workflow_call:
inputs:
language:
description: "Test language: go | python | sdk"
required: true
type: string
platforms:
description: "JSON array of platforms to run on. Defaults to both."
required: false
type: string
default: '["linux-arm64", "windows-arm64"]'
gate_on_changed_files:
description: "Skip the cell when no files match the language's path filter."
required: false
type: boolean
default: true
permissions:
contents: read
packages: read
jobs:
run:
name: ${{ matrix.platform }}
strategy:
fail-fast: false
matrix:
platform: ${{ fromJSON(inputs.platforms) }}
# platform is the canonical id (matches sdk-<platform> artifacts and the
# windows-arm64 step conditions below); map it to a real runner label.
# linux tests run the arm64 SDK binary, so they need an arm64 host
# (ubuntu-24.04-arm), not the x86 ubuntu-latest.
runs-on: ${{ matrix.platform == 'windows-arm64' && 'windows-11-arm' || 'ubuntu-24.04-arm' }}
timeout-minutes: 45
env:
# Surface SDK-side trace logs to stderr in every cell so a failed
# assertion has the maximum signal available without a re-run.
GENIEX_LOG: trace
# Windows pytest runs on the host, so the ctypes loader and the
# binding need to find libgeniex and the geniex package directly.
# Linux pytest runs inside a container that re-declares these in
# its env input.
PYTHONPATH: ${{ github.workspace }}/bindings/python
GENIEX_LIB_PATH: ${{ github.workspace }}/sdk/pkg-geniex/lib
steps:
- name: Configure Windows Git
if: matrix.platform == 'windows-arm64'
shell: cmd
run: |
echo C:\Program Files\Git\bin>>%GITHUB_PATH%
git config --global core.longpaths true
git config --global core.protectNTFS false
- name: Checkout source
uses: actions/checkout@v7
with:
# changed-files diffs against the PR base SHA; fetch-depth 0
# avoids "missing base" failures on multi-commit PRs.
fetch-depth: 0
submodules: false
- name: Resolve changed files
id: files
if: inputs.gate_on_changed_files
uses: ./.github/actions/changed-files
with:
# go → cli/** OR bindings/go/**
# python → bindings/python/** OR sdk/**
# sdk → sdk/** OR third-party/** OR tests/**
include: >-
${{ inputs.language == 'go' && '^(cli|bindings/go)/' ||
inputs.language == 'python' && '^(bindings/python|sdk)/' ||
'^(sdk|third-party|tests)/' }}
- name: Decide skip
id: skip
shell: bash
env:
GATE: ${{ inputs.gate_on_changed_files }}
ANY: ${{ steps.files.outputs.any }}
LANGUAGE: ${{ inputs.language }}
PLATFORM: ${{ matrix.platform }}
run: |
set -euo pipefail
if [ "$GATE" = "true" ] && [ "$ANY" != "true" ]; then
echo "No $LANGUAGE path changes — skipping $PLATFORM"
echo "skip=true" >> "$GITHUB_OUTPUT"
else
echo "skip=false" >> "$GITHUB_OUTPUT"
fi
- name: Download SDK artifact
if: steps.skip.outputs.skip != 'true'
uses: actions/download-artifact@v8
with:
name: sdk-${{ matrix.platform }}
path: sdk/pkg-geniex/
# ---------------- go-test ----------------
# cli/release/... is excluded because it depends on InnoSetup (Windows
# installer) and the docker tarball — neither of which is testable on
# the linux runner, and the InnoSetup repo rule fails the loading phase
# on Linux. Negative patterns must follow `--`.
- name: Restore Bazel disk cache (Linux go-test)
if: steps.skip.outputs.skip != 'true' && inputs.language == 'go' && matrix.platform == 'linux-arm64'
uses: actions/cache@v6
with:
path: ~/.cache/bazel-disk
key: bazel-go-test-${{ runner.os }}-${{ hashFiles('MODULE.bazel.lock', 'cli/**/BUILD.bazel', 'bindings/go/**/BUILD.bazel', 'cli/**/*.bzl') }}
restore-keys: |
bazel-go-test-${{ runner.os }}-
- name: Run go test (Linux, ubuntu:24.04 container)
if: steps.skip.outputs.skip != 'true' && inputs.language == 'go' && matrix.platform == 'linux-arm64'
uses: ./.github/actions/run-in-ubuntu24
with:
apt_packages: "ca-certificates curl unzip gcc g++ git python3"
cache_host_path: ~/.cache/bazel-disk
cache_container_path: /root/.cache/bazel-disk
env: |
GENIEX_LOG=trace
script: |
curl -fsSL -o /usr/local/bin/bazelisk \
https://github.com/bazelbuild/bazelisk/releases/download/v1.22.1/bazelisk-linux-arm64
chmod +x /usr/local/bin/bazelisk
ln -sf /usr/local/bin/bazelisk /usr/local/bin/bazel
bazelisk test \
--//sdk:sdk_type=local \
--disk_cache=/root/.cache/bazel-disk \
--test_output=errors \
--test_summary=terse \
-- //cli/... //bindings/go/... -//cli/release/... \
2>&1 | tee .bazel-test.log
- name: Run go test (Windows host)
if: steps.skip.outputs.skip != 'true' && inputs.language == 'go' && matrix.platform == 'windows-arm64'
shell: cmd
run: bazelisk test //cli/... //bindings/go/... --//sdk:sdk_type=local --test_output=errors --test_summary=terse -- -//cli/release/...
# ---------------- python / sdk pytest (shared scaffolding) ----------------
- name: Cache HF GGUF blobs
if: steps.skip.outputs.skip != 'true' && inputs.language != 'go'
uses: actions/cache@v6
with:
path: ~/.cache/geniex
key: geniex-models-llama_cpp-${{ matrix.platform }}-v1-${{ hashFiles('tests/models.json', 'tests/_models.py', 'bindings/python/tests/conftest.py') }}
restore-keys: |
geniex-models-llama_cpp-${{ matrix.platform }}-v1-
# ---- Windows: run pytest directly on the host (Python 3.13 ARM64 preinstalled). ----
- name: Run pytest (Windows)
if: steps.skip.outputs.skip != 'true' && inputs.language != 'go' && matrix.platform == 'windows-arm64'
shell: bash
env:
LANGUAGE: ${{ inputs.language }}
run: |
set -euo pipefail
python -m pip install --upgrade pip
# tqdm is the only runtime dep declared by bindings/python.
# PEP 517 backend resolution fails on hosted Python 3.13 + pip 26.1
# so install runtime deps directly instead of `pip install ./bindings/python`.
python -m pip install "pytest>=7.0" "tqdm>=4.65"
python -c "import geniex; geniex.init(); geniex.deinit()"
if [ "$LANGUAGE" = "sdk" ]; then
python -m pytest tests -m "api or (llama_cpp and device_cpu)" -v | tee .pytest-api.log
else
python -m pytest bindings/python/tests/unit -v | tee .pytest-unit.log
python -m pytest bindings/python/tests --ignore=bindings/python/tests/unit -v | tee .pytest-int.log
fi
# ---- Linux: run pytest inside ubuntu:24.04 (matches SDK's GLIBC). ----
- name: Run pytest (Linux, ubuntu:24.04 container)
if: steps.skip.outputs.skip != 'true' && inputs.language != 'go' && matrix.platform == 'linux-arm64'
uses: ./.github/actions/run-in-ubuntu24
with:
cache_host_path: ~/.cache/geniex
cache_container_path: /root/.cache/geniex
env: |
PYTHONPATH=/workspace/bindings/python
GENIEX_LIB_PATH=/workspace/sdk/pkg-geniex/lib
GENIEX_LOG=trace
LANGUAGE=${{ inputs.language }}
script: |
python3 -m venv /tmp/venv
. /tmp/venv/bin/activate
python -m pip install --upgrade pip
python -m pip install "pytest>=7.0" "tqdm>=4.65"
status=0
if [ "$LANGUAGE" = "sdk" ]; then
python -m pytest tests -m "api or (llama_cpp and device_cpu)" -v | tee .pytest-api.log || status=$?
else
# python: run both phases so phase 2 still surfaces if phase 1 regresses.
python -m pytest bindings/python/tests/unit -v | tee .pytest-unit.log || status=$?
python -m pytest bindings/python/tests --ignore=bindings/python/tests/unit -v | tee .pytest-int.log || status=$?
fi
exit "$status"
# ---------------- Step summary ----------------
- name: Publish step summary
if: always() && steps.skip.outputs.skip != 'true'
shell: bash
env:
LANGUAGE: ${{ inputs.language }}
PLATFORM: ${{ matrix.platform }}
run: |
set -euo pipefail
{
echo "## $LANGUAGE test results — $PLATFORM"
echo
for log in .pytest-api.log .pytest-unit.log .pytest-int.log .bazel-test.log; do
[ -f "$log" ] || continue
echo "### $log"
echo
echo '```'
grep -E "PASSED|FAILED|ERROR|SKIPPED|TIMEOUT|FLAKY|passed|failed|Executed [0-9]+ out of" "$log" || echo "(no results captured)"
echo '```'
echo
done
} >> "$GITHUB_STEP_SUMMARY"