-
Notifications
You must be signed in to change notification settings - Fork 131
Fix runner local build ABI validation #791
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| #!/usr/bin/env bash | ||
| # Build a local Linux amd64 runner release artifact without deploying it. | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| SCRIPT_BUILD_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| SCRIPT_DIR="$(cd "$SCRIPT_BUILD_DIR/.." && pwd)" | ||
| source "$SCRIPT_DIR/common.sh" | ||
|
|
||
| REPO_ROOT="$PROJECT_ROOT" | ||
| VERSION="${VERSION:-$(grep -m 1 '^version' "$REPO_ROOT/Cargo.toml" | sed -E 's/^version *= *"([^"]+)".*/\1/')}" | ||
| COMMIT="${COMMIT:-$(git -C "$REPO_ROOT" rev-parse --short HEAD)}" | ||
| OUTPUT_DIR="${OUTPUT_DIR:-$REPO_ROOT/dist/runner-release}" | ||
| RUNNER_BIN="$OUTPUT_DIR/boxlite-runner" | ||
| RUNNER_TARBALL="$OUTPUT_DIR/boxlite-runner-v${VERSION}-linux-amd64-${COMMIT}.tar.gz" | ||
|
|
||
| if [[ -z "$VERSION" ]]; then | ||
| print_error "Could not read version from $REPO_ROOT/Cargo.toml" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [[ "$(detect_os)" != "linux" ]]; then | ||
| print_error "Runner release artifacts must be built on Linux because the binary uses cgo" | ||
| exit 1 | ||
| fi | ||
|
|
||
| require_command git "Install git" | ||
| require_command go "Install Go" | ||
| require_command tar "Install tar" | ||
| require_command sha256sum "Install coreutils" | ||
|
|
||
| if [[ "${SKIP_SUBMODULE_UPDATE:-0}" != "1" ]]; then | ||
| print_section "Updating submodules" | ||
| git -C "$REPO_ROOT" submodule update --init --recursive | ||
| fi | ||
|
|
||
| print_section "Building and validating Go SDK static library" | ||
| make -C "$REPO_ROOT" dist:go | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
On Linux arm64 or any non-amd64 host, this Useful? React with 👍 / 👎. |
||
| bash "$SCRIPT_BUILD_DIR/check-libboxlite-abi.sh" "$REPO_ROOT/sdks/go/libboxlite.a" | ||
|
|
||
| print_section "Building embedded daemon assets" | ||
| cd "$REPO_ROOT/apps" | ||
| CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \ | ||
| go build \ | ||
| -ldflags "-X github.com/boxlite-ai/daemon/internal.Version=${VERSION}" \ | ||
| -o "$REPO_ROOT/apps/runner/pkg/daemon/static/daemon-amd64" \ | ||
| ./daemon/cmd/daemon/ | ||
|
|
||
| CGO_ENABLED=1 GOOS=linux GOARCH=amd64 \ | ||
| go build \ | ||
| -o "$REPO_ROOT/apps/runner/pkg/daemon/static/boxlite-computer-use" \ | ||
| ./libs/computer-use/ | ||
|
|
||
| print_section "Building runner" | ||
| mkdir -p "$OUTPUT_DIR" | ||
| CGO_ENABLED=1 GOOS=linux GOARCH=amd64 \ | ||
| go build \ | ||
| -ldflags "-X github.com/boxlite-ai/runner/internal.Version=${VERSION}" \ | ||
| -o "$RUNNER_BIN" \ | ||
| ./runner/cmd/runner/ | ||
|
|
||
| tar -C "$OUTPUT_DIR" -czf "$RUNNER_TARBALL" "$(basename "$RUNNER_BIN")" | ||
|
|
||
| print_success "Runner artifact built" | ||
| echo "binary: $RUNNER_BIN" | ||
| echo "tarball: $RUNNER_TARBALL" | ||
| sha256sum "$RUNNER_BIN" "$RUNNER_TARBALL" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| #!/usr/bin/env bash | ||
| # Smoke-test the C ABI used by the Go SDK prebuilt static library. | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| SCRIPT_BUILD_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| SCRIPT_DIR="$(cd "$SCRIPT_BUILD_DIR/.." && pwd)" | ||
| source "$SCRIPT_DIR/common.sh" | ||
|
|
||
| LIB="${1:-target/release/libboxlite.a}" | ||
| REPO_ROOT="$PROJECT_ROOT" | ||
|
|
||
| if [[ "$LIB" != /* ]]; then | ||
| LIB="$REPO_ROOT/$LIB" | ||
| fi | ||
|
|
||
| if [[ ! -f "$LIB" ]]; then | ||
| print_error "Library not found: $LIB" | ||
| exit 1 | ||
| fi | ||
|
|
||
| require_command cc "Install a C compiler" | ||
|
|
||
| TMP_DIR="$(mktemp -d)" | ||
| trap 'rm -rf "$TMP_DIR"' EXIT | ||
|
|
||
| PROBE_C="$TMP_DIR/check-libboxlite-abi.c" | ||
| PROBE_BIN="$TMP_DIR/check-libboxlite-abi" | ||
|
|
||
| cat > "$PROBE_C" <<'C' | ||
| #include "boxlite.h" | ||
| #include <stdio.h> | ||
|
|
||
| int main(void) { | ||
| CBoxliteOptions *opts = NULL; | ||
| CBoxliteError err = {0}; | ||
|
|
||
| enum BoxliteErrorCode new_code = boxlite_options_new( | ||
| "ghcr.io/boxlite-ai/boxlite-agent-base:latest", | ||
| &opts, | ||
| &err | ||
| ); | ||
| enum BoxliteErrorCode port_code = boxlite_options_add_port( | ||
| opts, | ||
| 33689, | ||
| 2280, | ||
| BoxlitePortProtocolTcp, | ||
| NULL | ||
| ); | ||
|
|
||
| printf("new=%d add_port=%d\n", (int)new_code, (int)port_code); | ||
| if (opts != NULL) { | ||
| boxlite_options_free(opts); | ||
| } | ||
|
|
||
| return (new_code == Ok && port_code == Ok) ? 0 : 1; | ||
| } | ||
| C | ||
|
|
||
| OS="$(detect_os)" | ||
| case "$OS" in | ||
| linux) | ||
| LINK_FLAGS=(-lresolv -lpthread -ldl -lrt -lm) | ||
| ;; | ||
| macos) | ||
| LINK_FLAGS=(-framework CoreFoundation -framework Security -framework IOKit -framework Hypervisor -framework vmnet -lresolv) | ||
| ;; | ||
| *) | ||
| print_error "Unsupported platform: $(uname -s)" | ||
| exit 1 | ||
| ;; | ||
| esac | ||
|
|
||
| cc -I"$REPO_ROOT/sdks/c/include" "$PROBE_C" "$LIB" "${LINK_FLAGS[@]}" -o "$PROBE_BIN" | ||
|
|
||
| set +e | ||
| OUTPUT="$("$PROBE_BIN" 2>&1)" | ||
| STATUS=$? | ||
| set -e | ||
| echo "$OUTPUT" | ||
|
|
||
| if [[ "$STATUS" -ne 0 || "$OUTPUT" != "new=0 add_port=0" ]]; then | ||
| print_error "libboxlite ABI smoke check failed for $LIB" | ||
| exit 1 | ||
| fi | ||
|
|
||
| print_success "libboxlite ABI smoke check passed for $LIB" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add an explicit
makeprerequisite check.Line 38 invokes
make, butmakeis not validated in the dependency checks. On minimal hosts this fails with a genericcommand not foundinstead of a guided error.Suggested patch
require_command git "Install git" +require_command make "Install GNU Make" require_command go "Install Go" require_command tar "Install tar" require_command sha256sum "Install coreutils"Also applies to: 38-38
🤖 Prompt for AI Agents