-
-
Notifications
You must be signed in to change notification settings - Fork 0
127 lines (115 loc) · 4.12 KB
/
Copy pathzig-test.yml
File metadata and controls
127 lines (115 loc) · 4.12 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
# SPDX-License-Identifier: MPL-2.0
# Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>
#
# BoJ Server — Zig FFI test & build pipeline
name: Zig FFI Tests
on:
push:
branches: [main]
paths:
- 'ffi/**'
- 'cartridges/**/ffi/**'
- '.github/workflows/zig-test.yml'
pull_request:
branches: [main]
paths:
- 'ffi/**'
- 'cartridges/**/ffi/**'
- '.github/workflows/zig-test.yml'
permissions:
contents: read
jobs:
test:
name: Zig FFI Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
# Needed so `git diff origin/<base>...HEAD` can identify the
# cartridges actually changed in this PR. Full history is cheap
# on this repo; cuts down on cross-cartridge false-positive
# gating where a PR is blocked by pre-existing breakage in
# unrelated cartridges (browser-mcp, orchestrator-lsp-mcp,
# etc.). On push/main we keep the full per-cartridge sweep.
fetch-depth: 0
- name: Install Zig
uses: mlugg/setup-zig@d1434d08867e3ee9daa34448df10607b98908d29 # v2
with:
version: 0.15.2
- name: Determine cartridges to test
id: scope
env:
EVENT: ${{ github.event_name }}
BASE_REF: ${{ github.base_ref }}
run: |
set -euo pipefail
all="$(ls -d cartridges/*/ffi/ 2>/dev/null | sed 's|cartridges/||;s|/ffi/||' | sort)"
if [ "$EVENT" = "pull_request" ]; then
git fetch --no-tags --depth=50 origin "$BASE_REF" || true
changed="$(git diff --name-only "origin/${BASE_REF}...HEAD" -- 'cartridges/**' \
| awk -F/ '{print $2}' | sort -u)"
scope=""
while IFS= read -r cart; do
[ -z "$cart" ] && continue
if printf '%s\n' "$changed" | grep -qx "$cart"; then
scope="$scope$cart"$'\n'
fi
done <<< "$all"
else
scope="$all"
fi
{
echo 'carts<<EOF'
printf '%s' "$scope"
echo
echo 'EOF'
} >> "$GITHUB_OUTPUT"
echo "Cartridges in scope for this run:"
printf ' • %s\n' $(printf '%s\n' "$scope" | grep -v '^$' || true)
- name: Run catalogue tests
run: cd ffi/zig && zig build test --summary all
- name: Run readiness tests
run: cd ffi/zig && zig build readiness --summary all
- name: Run cartridge FFI tests
env:
CARTS: ${{ steps.scope.outputs.carts }}
run: |
if [ -z "$(printf '%s' "$CARTS" | tr -d '[:space:]')" ]; then
echo "::notice::No cartridges changed in this PR — skipping per-cartridge FFI tests."
exit 0
fi
failed=""
while IFS= read -r cart; do
[ -z "$cart" ] && continue
echo "::group::Testing $cart..."
if cd "cartridges/$cart/ffi" && zig build test --summary all 2>&1; then
echo " ✓ $cart passed"
else
echo " ✗ $cart FAILED"
failed="$failed $cart"
fi
cd "$GITHUB_WORKSPACE"
echo "::endgroup::"
done <<< "$CARTS"
if [ -n "$failed" ]; then
echo "::error::Failed cartridges:$failed"
exit 1
fi
- name: Build cartridge shared libraries
env:
CARTS: ${{ steps.scope.outputs.carts }}
run: |
if [ -z "$(printf '%s' "$CARTS" | tr -d '[:space:]')" ]; then
echo "::notice::No cartridges changed in this PR — skipping per-cartridge .so build."
exit 0
fi
while IFS= read -r cart; do
[ -z "$cart" ] && continue
echo "Building $cart .so..."
cd "cartridges/$cart/ffi" && zig build
cd "$GITHUB_WORKSPACE"
done <<< "$CARTS"
- name: Build static library
run: cd ffi/zig && zig build lib
- name: Run benchmarks
run: cd ffi/zig && zig build bench