Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ alias c := check
alias f := fmt
alias t := test
alias p := pre-push
alias vs := verify-standalone

_default:
@just --list
Expand Down Expand Up @@ -57,3 +58,43 @@ _test-testenv:

# Run pre-push suite: format, check, and test
pre-push: fmt check test

# Verify that a crate can be built standalone without workspace dependencies
# This ensures the crate is publishable and doesn't accidentally depend on
# breaking changes from other workspace crates
verify-standalone crate *args="":
#!/usr/bin/env bash
set -euo pipefail

echo "Verifying {{crate}} can build standalone..."

# Package the crate (default: --no-verify, can be overridden with args)
cargo package -p {{crate}} --no-verify {{args}}

# Find the packaged tarball
CRATE_VERSION=$(cargo metadata --format-version 1 --no-deps | jq -r ".packages[] | select(.name == \"{{crate}}\") | .version")
TARBALL="target/package/{{crate}}-${CRATE_VERSION}.crate"

if [ ! -f "$TARBALL" ]; then
echo "Error: Could not find packaged tarball at $TARBALL"
exit 1
fi

# Create a temporary directory for unpacking
TEMP_DIR=$(mktemp -d)
trap "rm -rf $TEMP_DIR" EXIT

# Unpack the tarball
tar -xzf "$TARBALL" -C "$TEMP_DIR"

# Build the unpacked crate with --locked to ensure it uses registry dependencies
cd "$TEMP_DIR/{{crate}}-${CRATE_VERSION}"

# Set temporary directories to avoid using workspace dependencies
export CARGO_HOME="$TEMP_DIR/.cargo"
export CARGO_TARGET_DIR="$TEMP_DIR/target"

echo "Building {{crate}} in isolation..."
cargo build --locked

echo "✅ {{crate}} builds successfully in isolation!"
Loading