Skip to content

feat(c-ffi-cli): -C/--container — emit & consume .pbf.json (issue #1) #58

feat(c-ffi-cli): -C/--container — emit & consume .pbf.json (issue #1)

feat(c-ffi-cli): -C/--container — emit & consume .pbf.json (issue #1) #58

Workflow file for this run

name: CI
on:
push:
branches: [yolo]
pull_request:
branches: [yolo]
jobs:
nix-build:
strategy:
fail-fast: false
matrix:
include:
- runner: ubuntu-latest
system: x86_64-linux
- runner: ubuntu-24.04-arm
system: aarch64-linux
- runner: macos-14
system: aarch64-darwin
runs-on: ${{ matrix.runner }}
name: nix (${{ matrix.system }})
steps:
- uses: actions/checkout@v6
- uses: DeterminateSystems/nix-installer-action@main
- name: Build all packages
run: nix build -L
- name: Run checks
run: |
for check in $(nix eval .#checks.${{ matrix.system }} --apply 'cs: builtins.attrNames cs' --json | jq -r '.[]'); do
echo "::group::check: $check"
nix build -L ".#checks.${{ matrix.system }}.$check"
echo "::endgroup::"
done
- name: Upload C binary
uses: actions/upload-artifact@v6
with:
name: printable-binary-c-${{ matrix.system }}
path: result/bin/printable-binary-c
- name: Upload Zig binary
uses: actions/upload-artifact@v6
with:
name: printable-binary-zig-${{ matrix.system }}
path: result/bin/printable-binary-zig
- name: Upload APE binary (Linux only)
if: matrix.system == 'x86_64-linux'
run: nix build .#printableBinaryApe -L
# APE is already in the default suite on Linux, but build explicitly to be sure
- name: Upload APE artifact
if: matrix.system == 'x86_64-linux'
uses: actions/upload-artifact@v6
with:
name: printable-binary-ape-${{ matrix.system }}
path: result/bin/printable-binary-ape.com
- name: Build WASM (x86_64-linux only)
if: matrix.system == 'x86_64-linux'
run: nix build .#printableBinaryWasm -L
- name: Upload WASM artifact
if: matrix.system == 'x86_64-linux'
uses: actions/upload-artifact@v6
with:
name: printable-binary-wasm
path: result/bin/printable-binary.wasm
windows-build:
strategy:
fail-fast: false
matrix:
include:
- runner: windows-latest
arch: x86_64
runs-on: ${{ matrix.runner }}
name: windows (${{ matrix.arch }})
# aarch64-windows is covered by the cross-windows-aarch64 job below (reliable
# Linux cross-compile) instead of the GitHub windows-11-arm preview runner,
# which exits zig build with no output (toolchain instability, not a code bug —
# the same target cross-compiles clean from Linux). Revisit native ARM when
# the runner leaves preview.
steps:
- uses: actions/checkout@v6
- name: Install Zig
shell: bash
run: |
set -euo pipefail
version="0.16.0"
if [ "$version" = "latest" ]; then
version="$(curl -fsSL https://ziglang.org/download/index.json | ruby -rjson -e 'data = JSON.parse(STDIN.read); puts data.keys.grep(/\A\d+\.\d+\.\d+\z/).sort_by { |v| v.split(".").map(&:to_i) }.last')"
fi
case "${RUNNER_OS}-${RUNNER_ARCH}" in
Linux-X64) platform="x86_64-linux"; ext="tar.xz" ;;
Linux-ARM64) platform="aarch64-linux"; ext="tar.xz" ;;
macOS-X64) platform="x86_64-macos"; ext="tar.xz" ;;
macOS-ARM64) platform="aarch64-macos"; ext="tar.xz" ;;
Windows-X64) platform="x86_64-windows"; ext="zip" ;;
Windows-ARM64) platform="aarch64-windows"; ext="zip" ;;
*) echo "Unsupported runner: ${RUNNER_OS}-${RUNNER_ARCH}" >&2; exit 1 ;;
esac
archive="$RUNNER_TEMP/zig.$ext"
install_dir="$RUNNER_TEMP/zig"
curl -fsSL "https://ziglang.org/download/${version}/zig-${platform}-${version}.${ext}" -o "$archive"
mkdir -p "$install_dir"
if [ "$ext" = "zip" ]; then
unzip -q "$archive" -d "$install_dir"
else
tar -xf "$archive" -C "$install_dir"
fi
zig_dir="$(find "$install_dir" -mindepth 1 -maxdepth 1 -type d | head -n 1)"
echo "$zig_dir" >> "$GITHUB_PATH"
"$zig_dir/zig" version
- name: Build Zig CLI
run: zig build -Doptimize=ReleaseFast
- name: Build C via zig cc
shell: bash
run: |
zig cc -O3 -I. -o printable-binary-c.exe src/printable_binary.c -lpsapi
- name: Run Zig unit tests
run: zig build test
- name: Smoke test (roundtrip)
shell: bash
run: |
echo -n "Hello, World!" > /tmp/test_input.bin
./zig-out/bin/printable-binary-zig.exe /tmp/test_input.bin > /tmp/test_encoded.txt
./zig-out/bin/printable-binary-zig.exe -d /tmp/test_encoded.txt > /tmp/test_decoded.bin
if cmp -s /tmp/test_input.bin /tmp/test_decoded.bin; then
echo "Roundtrip PASS"
else
echo "Roundtrip FAIL"
exit 1
fi
- name: Upload Zig binary
uses: actions/upload-artifact@v6
with:
name: printable-binary-zig-${{ matrix.arch }}-windows
path: zig-out/bin/printable-binary-zig.exe
- name: Upload C binary
uses: actions/upload-artifact@v6
with:
name: printable-binary-c-${{ matrix.arch }}-windows
path: printable-binary-c.exe
# aarch64-windows build coverage via reliable Linux cross-compilation, in
# place of the flaky windows-11-arm preview runner. Build-only (a cross-built
# Windows binary can't execute on the Linux runner); runtime tests are covered
# natively on windows x86_64 above and on Linux/macOS via the nix checks.
cross-windows-aarch64:
runs-on: ubuntu-latest
name: cross (aarch64-windows)
steps:
- uses: actions/checkout@v6
- name: Install Zig (x86_64-linux host)
shell: bash
run: |
set -euo pipefail
version="0.16.0"
curl -fsSL "https://ziglang.org/download/${version}/zig-x86_64-linux-${version}.tar.xz" -o "$RUNNER_TEMP/zig.tar.xz"
mkdir -p "$RUNNER_TEMP/zig"
tar -xf "$RUNNER_TEMP/zig.tar.xz" -C "$RUNNER_TEMP/zig"
zig_dir="$(find "$RUNNER_TEMP/zig" -mindepth 1 -maxdepth 1 -type d | head -n 1)"
echo "$zig_dir" >> "$GITHUB_PATH"
"$zig_dir/zig" version
- name: Cross-compile aarch64-windows (Zig CLI + lib)
run: zig build -Dtarget=aarch64-windows -Doptimize=ReleaseFast
- name: Cross-compile aarch64-windows C CLI (zig cc, -lpsapi)
run: zig cc -target aarch64-windows-gnu -O3 -I. -o printable-binary-c-aarch64-windows.exe src/printable_binary.c -lpsapi
- name: Upload aarch64-windows binaries
uses: actions/upload-artifact@v6
with:
name: printable-binary-aarch64-windows
path: |
zig-out/bin/printable-binary-zig.exe
printable-binary-c-aarch64-windows.exe