8000 jackdaw/justfile at jaq-fix · arminhammer/jackdaw · GitHub
[go: up one dir, main page]

Skip to content

Latest commit

 

History

History
308 lines (256 loc) · 11 KB

justfile

File metadata and controls

308 lines (256 loc) · 11 KB
init: submodules
command -v cargo-zigbuild >/dev/null 2>&1 || cargo install cargo-zigbuild
command -v cargo-llvm-cov >/dev/null 2>&1 || cargo install cargo-llvm-cov
command -v zig >/dev/null 2>&1 || echo "⚠️ Warning: 'zig' not found in PATH. Required for cross-compilation."
command -v prek >/dev/null 2>&1 || echo "⚠️ Warning: 'prek' not found in PATH. Required for running pre-commit hooks."
rustup target list --installed | grep -q x86_64-unknown-linux-musl || rustup target add x86_64-unknown-linux-musl
rustup target list --installed | grep -q aarch64-unknown-linux-musl || rustup target add aarch64-unknown-linux-musl
# Pull and sync git submodules
submodules:
git submodule update --init --recursive
# Vendor the Open Workflow DSL models into jackdaw/src/dsl, copied verbatim (no edits) from `core/src/models`
# of the SDK. The commit is recorded in jackdaw/src/dsl/UPSTREAM. e.g. `just update-dsl` or
# `just update-dsl https://github.com/open-workflow-specification/sdk-rust.git v1.0.0`
update-dsl repo="https://github.com/arminhammer/sdk-rust.git" ref="main":
#!/usr/bin/env bash
set -euo pipefail
tmp=$(mktemp -d)
trap 'rm -rf "$tmp"' EXIT
git clone --quiet "{{repo}}" "$tmp/sdk"
git -C "$tmp/sdk" checkout --quiet "{{ref}}"
rev=$(git -C "$tmp/sdk" rev-parse HEAD)
rm -rf jackdaw/src/dsl
cp -r "$tmp/sdk/core/src/models" jackdaw/src/dsl
cp "$tmp/sdk/LICENSE" jackdaw/src/dsl/LICENSE
# The SDK's unit tests (in its lib.rs), run as `dsl::unit_tests`: without lib.rs's `mod models;`, and with
# serde-saphyr in place of serde_yaml.
sed -e '/^pub mod models;$/d' -e 's/serde_yaml::/serde_saphyr::/g' "$tmp/sdk/core/src/lib.rs" > jackdaw/src/dsl/unit_tests.rs
printf 'repository: %s\nref: %s\nrevision: %s\npath: core/src/models\ntests: core/src/lib.rs (unit_tests.rs)\n' "{{repo}}" "{{ref}}" "$rev" > jackdaw/src/dsl/UPSTREAM
echo "jackdaw/src/dsl now at $rev"
git status --short jackdaw/src/dsl
# Build the project
build:
cargo build
# Build static lite version for Linux x86_64 (uses zigbuild for musl cross-compilation)
build-static:
cargo zigbuild --release --target x86_64-unknown-linux-musl
# Build in development mode
build-release:
cargo build --release
# Run all unit tests
test:
cargo test --lib
# Run all CTK integration tests (consolidated report)
test-ctk:
cargo test --test ctk_conformance
test-examples:
cargo test --test example_tests
test-validate:
cargo test --test validate_tests
# Run the library BDD feature specs in jackdaw/tests/lib (skips @todo scenarios).
# Extra arguments go to cucumber, e.g. `just test-lib --tags '@crash and not @todo'`
test-lib *ARGS:
cargo test -p jackdaw-wf --test lib_features -- {{ARGS}}
# Run all tests (unit + integration, including the library BDD specs)
test-all:
cargo test
# Run Docker integration tests (requires Docker image to be built)
test-docker: docker-build
cargo test --test docker_integration_tests
# Run listener tests (gRPC and HTTP/OpenAPI)
test-listeners:
cargo test --test listener_tests --no-fail-fast
# Run nested workflow tests
test-nested-workflows:
cargo test --test nested_workflow_tests --no-fail-fast
# Build Docker image and run integration tests
test-docker-full: docker-build test-docker
# Generate code coverage report for all tests (unit and integration tests)
coverage:
cargo llvm-cov \
--all-features \
--workspace \
--html \
--open
# Generate coverage report without opening browser
coverage-report:
cargo llvm-cov \
--all-features \
--workspace \
--html
# Clean coverage data
coverage-clean:
cargo llvm-cov clean
# Clean build artifacts
clean:
cargo clean
# Clean up test containers (PostgreSQL test containers)
clean-test-containers:
#!/usr/bin/env bash
set -euo pipefail
echo "Cleaning up PostgreSQL test containers..."
# Remove all postgres test containers
docker ps -aq --filter "ancestor=postgres:16-alpine" 2>/dev/null | xargs -r docker rm -f || true
podman ps -aq --filter "ancestor=postgres:16-alpine" 2>/dev/null | xargs -r podman rm -f || true
echo "✓ Test containers cleaned"
# Clean up all stopped containers and dangling images
clean-containers-all:
#!/usr/bin/env bash
set -euo pipefail
echo "Cleaning up all stopped containers..."
docker container prune -f 2>/dev/null || true
podman container prune -f 2>/dev/null || true
echo "✓ All stopped containers cleaned"
# Format code
fmt:
cargo fmt
# Run clippy linter
lint:
cargo clippy --all-targets --all-features -- -D warnings
# Check dependency licenses, versions and sources (deny.toml)
deny:
cargo deny check licenses bans sources
# Check the public API against the latest release on crates.io
semver:
cargo semver-checks -p jackdaw-wf --all-features
# Check for potential panics (unwrap, expect, etc.)
lint-panics:
cargo clippy -- \
-W clippy::unwrap_used \
-W clippy::expect_used \
-W clippy::panic \
-W clippy::indexing_slicing
# Check code without building
check:
cargo check
# ============================================================================
# Release Binary Building
# ============================================================================
# Build static Linux binary (x86_64, musl)
build-linux-amd64:
cargo zigbuild --release --target x86_64-unknown-linux-musl
# Build static Linux binary (ARM64, musl)
build-linux-arm64:
cargo zigbuild --release --target aarch64-unknown-linux-musl
# Build macOS binary (Intel)
build-macos-amd64:
cargo build --release --target x86_64-apple-darwin
# Build macOS binary (Apple Silicon)
build-macos-arm64:
cargo build --release --target aarch64-apple-darwin
# Build universal macOS binary (combines Intel + Apple Silicon)
build-macos-universal: build-macos-amd64 build-macos-arm64
#!/usr/bin/env bash
set -euo pipefail
mkdir -p target/universal-apple-darwin/release
lipo -create \
target/x86_64-apple-darwin/release/jackdaw \
target/aarch64-apple-darwin/release/jackdaw \
-output target/universal-apple-darwin/release/jackdaw
echo "Universal macOS binary created: target/universal-apple-darwin/release/jackdaw"
# Build all release binaries (Linux x86_64, Linux ARM64, macOS universal)
build-all-release: build-linux-amd64 build-linux-arm64 build-macos-universal
@echo "All release binaries built:"
@echo " - target/x86_64-unknown-linux-musl/release/jackdaw"
@echo " - target/aarch64-unknown-linux-musl/release/jackdaw"
@echo " - target/universal-apple-darwin/release/jackdaw"
# Package release binaries with version tag
package-release VERSION:
#!/usr/bin/env bash
set -euo pipefail
mkdir -p dist
# Linux x86_64
tar -czf dist/jackdaw-{{VERSION}}-linux-amd64.tar.gz \
-C target/x86_64-unknown-linux-musl/release jackdaw
# Linux ARM64
tar -czf dist/jackdaw-{{VERSION}}-linux-arm64.tar.gz \
-C target/aarch64-unknown-linux-musl/release jackdaw
# macOS Universal
tar -czf dist/jackdaw-{{VERSION}}-macos-universal.tar.gz \
-C target/universal-apple-darwin/release jackdaw
# Generate checksums
cd dist
shasum -a 256 jackdaw-{{VERSION}}-*.tar.gz > jackdaw-{{VERSION}}-checksums.txt
cd ..
echo "✓ Release packages created in dist/"
ls -lh dist/jackdaw-{{VERSION}}-*
# Show binary sizes
show-binary-sizes:
@echo "Binary sizes:"
@ls -lh target/x86_64-unknown-linux-musl/release/jackdaw 2>/dev/null || echo " x86_64-linux-musl: not built"
@ls -lh target/aarch64-unknown-linux-musl/release/jackdaw 2>/dev/null || echo " aarch64-linux-musl: not built"
@ls -lh target/universal-apple-darwin/release/jackdaw 2>/dev/null || echo " universal-apple-darwin: not built"
# ============================================================================
# Docker Builds (Linux cross-compilation)
# ============================================================================
# Build Docker image for current platform
docker-build:
docker buildx build -f jackdaw-cli/Dockerfile --load -t jackdaw:latest .
# Build Docker image for multiple platforms (amd64 and arm64)
docker-build-multiplatform:
docker buildx build -f jackdaw-cli/Dockerfile --platform linux/amd64,linux/arm64 -t jackdaw:latest .
# Build and push Docker image for multiple platforms
docker-build-push:
docker buildx build -f jackdaw-cli/Dockerfile --platform linux/amd64,linux/arm64 -t jackdaw:latest --push .
# Build Linux x86_64 binary using Docker (extracts from builder stage)
docker-build-linux-amd64:
#!/usr/bin/env bash
set -euo pipefail
echo "Building Linux x86_64 binary in Docker..."
docker buildx build \
-f jackdaw-cli/Dockerfile \
--platform linux/amd64 \
--target builder \
--load \
-t jackdaw-builder:linux-amd64 .
echo "Extracting binary..."
mkdir -p dist
docker create --name jackdaw-extract jackdaw-builder:linux-amd64
docker cp jackdaw-extract:/out/jackdaw ./dist/jackdaw-linux-amd64
docker rm jackdaw-extract
echo "Linux x86_64 binary ready: ./dist/jackdaw-linux-amd64"
ls -lh ./dist/jackdaw-linux-amd64
file ./dist/jackdaw-linux-amd64
# Build Linux ARM64 binary using Docker (extracts from builder stage)
docker-build-linux-arm64:
#!/usr/bin/env bash
set -euo pipefail
echo "Building Linux ARM64 binary in Docker..."
docker buildx build \
-f jackdaw-cli/Dockerfile \
--platform linux/arm64 \
--target builder \
--load \
-t jackdaw-builder:linux-arm64 .
echo "Extracting binary..."
mkdir -p dist
docker create --name jackdaw-extract jackdaw-builder:linux-arm64
docker cp jackdaw-extract:/out/jackdaw ./dist/jackdaw-linux-arm64
docker rm jackdaw-extract
echo "Linux ARM64 binary ready: ./dist/jackdaw-linux-arm64"
ls -lh ./dist/jackdaw-linux-arm64
file ./dist/jackdaw-linux-arm64
# Build both Linux binaries (amd64 and arm64)
docker-build-linux: docker-build-linux-amd64 docker-build-linux-arm64
@echo ""
@echo "All Linux binaries built:"
@ls -lh ./dist/jackdaw-linux-*
# Build all release binaries (Linux via Docker, macOS native)
docker-build-all: docker-build-linux build-macos-universal
@echo ""
@echo "All release binaries ready:"
@ls -lh ./dist/jackdaw-*
@ls -lh ./target/universal-apple-darwin/release/jackdaw
# ============================================================================
# Release Management
# ============================================================================
# Package and verify the published crates without uploading
publish-dry-run:
cargo publish --dry-run --locked -p jackdaw-wf-macros -p jackdaw-wf -p jackdaw-cli
# Publish jackdaw-wf-macros, jackdaw-wf and jackdaw-cli (cargo orders them) to crates.io. Irreversible: run publish-dry-run first
publish-crate:
#!/usr/bin/env bash
set -euo pipefail
echo "Publishing jackdaw-wf-macros, jackdaw-wf and jackdaw-cli to crates.io..."
cargo publish --locked -p jackdaw-wf-macros -p jackdaw-wf -p jackdaw-cli
echo "✓ Published to crates.io"
0