fix(ci): build native plugin fixtures for the host target

The macOS job failed with no_matching_artifact because the integration test
copied the Linux-only example manifest and built a Linux-named .so. Tests now
generate a manifest for the actual host triple, use the platform dynamic
library name and compiler flags, and never rewrite the tracked example
manifest.

- add a cross-platform no_matching_artifact test that runs without a C compiler
- add real tamper and ABI-major-mismatch rejection tests
- make worker fixtures platform-native; Windows remains explicitly unsupported
  (no cc) rather than counted as a pass
- example build scripts emit host-specific build/ fixtures (gitignored)
- CI smoke points at the generated fixtures
This commit is contained in:
cflmy committed 2026-11-20 13:54:18 +08:00
1 parent c7f3a8422c
commit 53cdea2325
7 files changed
+285 -85

No files matched your search

+3 -3
View File
@@ -41,7 +41,7 @@ interchangeable. Update `artifacts[0].target` and `sha256` in
[`plugin.yaml`](plugin.yaml) to match what you built:
```sh
sha256sum examples/plugin-demo/solver.so
sha256sum examples/plugin-demo/build/solver.so
```
## Inspect
@@ -51,8 +51,8 @@ Manifest validation and artifact verification are implemented by
never loads plugin code):
```sh
./examples/plugin-demo/build.sh # builds solver.so and refreshes sha256
marqdo plugin inspect examples/plugin-demo
./examples/plugin-demo/build.sh # writes build/solver.<dylib> + manifest
marqdo plugin inspect examples/plugin-demo/build
```
A typical inspection flow is:
+38 -16
View File
@@ -1,22 +1,44 @@
#!/usr/bin/env bash
# Build the example C plugin and refresh the sha256 in plugin.yaml.
# Build the example C plugin and generate a host-specific manifest.
#
# The artifact is intentionally NOT committed: installing/inspecting a package
# never implies trusting or loading its native code, and the manifest must
# describe the artifact you actually build on your machine.
# The artifact and generated manifest go to `build/`, which is gitignored. The
# tracked `plugin.yaml` is never rewritten by a test or build: it documents the
# manifest shape, while the generated one matches the machine that built it.
set -euo pipefail
here="$(cd "$(dirname "$0")" && pwd)"
repo="$(cd "$here/../.." && pwd)"
cd "$repo"
cc -shared -fPIC -I include -o "$here/solver.so" "$here/solver.c"
hash="$(sha256sum "$here/solver.so" | cut -d' ' -f1)"
python3 - "$here/plugin.yaml" "$hash" <<'PY'
import sys, re, pathlib
path, digest = sys.argv[1], sys.argv[2]
p = pathlib.Path(path)
text = p.read_text()
text = re.sub(r'(?m)^(\s*sha256:\s*")[0-9a-fA-F]{64}(")', r'\g<1>' + digest + r'\g<2>', text)
p.write_text(text)
PY
echo "built $here/solver.so (sha256 $hash)"
echo "now run: marqdo plugin inspect $here"
out="$here/build"
mkdir -p "$out"
host="$(rustc -vV | sed -n 's/^host: //p')"
case "$host" in
*apple-darwin*) ext="dylib"; flags=(-dynamiclib -fPIC) ;;
*windows*) ext="dll"; flags=(-shared) ;;
*) ext="so"; flags=(-shared -fPIC) ;;
esac
artifact="solver.$ext"
cc -std=c11 -O2 "${flags[@]}" -I include -o "$out/$artifact" "$here/solver.c"
if command -v sha256sum >/dev/null 2>&1; then
hash="$(sha256sum "$out/$artifact" | cut -d' ' -f1)"
else
hash="$(shasum -a 256 "$out/$artifact" | cut -d' ' -f1)"
fi
cat > "$out/plugin.yaml" <<YAML
plugin:
name: demo.solver
version: 0.1.0
abi: "^1.0"
kind: native
exports:
- name: solver.add
signature: "(\$a: Int, \$b: Int) -> Int"
requires:
- math.compute
artifacts:
- target: $host
file: $artifact
sha256: "$hash"
YAML
echo "built $out/$artifact for $host (sha256 $hash)"
echo "now run: marqdo plugin inspect $out"