Skip to content

Commit 63595ee

Browse files
evanlinjinclaude
andcommitted
chore(just): Add verify-standalone recipe
This recipe verifies that a crate can be packaged and built in isolation (without workspace dependencies). This is useful for ensuring updated crates do not accidentally depend on breaking changes in upstream crates of the same workspace. Added alias `vs` for quick access to this commonly used verification step. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 8f281da commit 63595ee

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

justfile

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ alias c := check
33
alias f := fmt
44
alias t := test
55
alias p := pre-push
6+
alias vs := verify-standalone
67

78
_default:
89
@just --list
@@ -57,3 +58,43 @@ _test-testenv:
5758

5859
# Run pre-push suite: format, check, and test
5960
pre-push: fmt check test
61+
62+
# Verify that a crate can be built standalone without workspace dependencies
63+
# This ensures the crate is publishable and doesn't accidentally depend on
64+
# breaking changes from other workspace crates
65+
verify-standalone crate *args="":
66+
#!/usr/bin/env bash
67+
set -euo pipefail
68+
69+
echo "Verifying {{crate}} can build standalone..."
70+
71+
# Package the crate (default: --no-verify, can be overridden with args)
72+
cargo package -p {{crate}} --no-verify {{args}}
73+
74+
# Find the packaged tarball
75+
CRATE_VERSION=$(cargo metadata --format-version 1 --no-deps | jq -r ".packages[] | select(.name == \"{{crate}}\") | .version")
76+
TARBALL="target/package/{{crate}}-${CRATE_VERSION}.crate"
77+
78+
if [ ! -f "$TARBALL" ]; then
79+
echo "Error: Could not find packaged tarball at $TARBALL"
80+
exit 1
81+
fi
82+
83+
# Create a temporary directory for unpacking
84+
TEMP_DIR=$(mktemp -d)
85+
trap "rm -rf $TEMP_DIR" EXIT
86+
87+
# Unpack the tarball
88+
tar -xzf "$TARBALL" -C "$TEMP_DIR"
89+
90+
# Build the unpacked crate with --locked to ensure it uses registry dependencies
91+
cd "$TEMP_DIR/{{crate}}-${CRATE_VERSION}"
92+
93+
# Set temporary directories to avoid using workspace dependencies
94+
export CARGO_HOME="$TEMP_DIR/.cargo"
95+
export CARGO_TARGET_DIR="$TEMP_DIR/target"
96+
97+
echo "Building {{crate}} in isolation..."
98+
cargo build --locked
99+
100+
echo "{{crate}} builds successfully in isolation!"

0 commit comments

Comments
 (0)