chore: Add script to test Homebrew formula with local build#180
Conversation
Adds scripts/test-homebrew.sh for testing the Homebrew formula against unreleased deepwork changes. The script builds an sdist tarball, creates a temporary formula pointing to it, and runs the Homebrew install/test. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Homebrew requires formulas to live in a tap. Create a local/deepwork-test tap and copy the modified formula there before installing. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR adds a Bash script to test the Homebrew formula for deepwork against locally built (unreleased) versions. The script builds an sdist tarball from the current source, creates a temporary Homebrew tap with a modified formula pointing to the local tarball, and runs installation and testing via Homebrew commands.
Changes:
- Adds
scripts/test-homebrew.shfor local Homebrew formula testing workflow - Implements automated building, installation, and testing of deepwork via Homebrew
- Provides configurable tap location (defaults to sibling
../homebrew-deepworkdirectory)
| # Set up a local tap with the modified formula | ||
| TAP_NAME="local/deepwork-test" | ||
| TAP_DIR="$(brew --repository)/Library/Taps/local/homebrew-deepwork-test" | ||
|
|
There was a problem hiding this comment.
The script does not clean up the temporary local tap created for testing. After the script completes (successfully or on error), the local tap local/deepwork-test will remain in the Homebrew installation directory. Consider adding a trap to ensure cleanup happens even if the script fails, similar to the pattern used in nix/claude-code/update.sh which uses trap "rm -rf $TMPDIR" EXIT. Add cleanup at the end or use a trap to remove the tap directory.
| # Ensure the local test tap is cleaned up on exit, even on failure | |
| trap 'brew untap "$TAP_NAME" >/dev/null 2>&1 || true; rm -rf "$TAP_DIR"' EXIT |
| uv build --sdist | ||
|
|
||
| # Find the built tarball | ||
| TARBALL=$(ls dist/deepwork-*.tar.gz | head -1) |
There was a problem hiding this comment.
Using ls with glob patterns in a pipeline can fail unexpectedly if no files match or if there are spaces in filenames. If the dist directory is empty or the tarball name has unexpected characters, this command could fail silently or produce incorrect results. Consider using a more robust approach like a find command or using array expansion with proper quoting.
| TARBALL=$(ls dist/deepwork-*.tar.gz | head -1) | |
| shopt -s nullglob | |
| tarballs=(dist/deepwork-*.tar.gz) | |
| shopt -u nullglob | |
| TARBALL="${tarballs[0]:-}" |
| sed -e "s|url \"https://.*\"|url \"file://$TARBALL_PATH\"|" \ | ||
| -e "s|sha256 \".*\"|sha256 \"$SHA256\"|" \ | ||
| "$HOMEBREW_TAP/Formula/deepwork.rb" > "$TAP_DIR/Formula/deepwork.rb" |
There was a problem hiding this comment.
The sed command uses unquoted variable substitution within the replacement pattern, which could be vulnerable to injection if the tarball path contains special sed metacharacters like &, /, or \. While this is low-risk since the path is constructed by the script itself, it's a best practice to escape variables used in sed patterns. Consider using a delimiter other than | in the sed command and properly escaping the variables, or use alternative tools like awk or perl for more robust text replacement.
| fi | ||
|
|
||
| echo "==> Building deepwork from $REPO_DIR" | ||
| cd "$REPO_DIR" |
There was a problem hiding this comment.
The script changes the working directory with cd "$REPO_DIR" but never restores it. If this script is sourced or called from another script expecting the current directory to be preserved, this could cause issues. While this is less critical for a standalone utility script, consider either documenting this behavior or saving and restoring the original directory at the end of the script.
| rm -rf dist/ | ||
|
|
||
| # Build the sdist tarball | ||
| uv build --sdist |
There was a problem hiding this comment.
The script does not verify that the required dependencies (uv, brew, shasum, sed, awk) are installed before attempting to use them. While brew is likely to be present given the script's purpose, uv may not be installed. Consider adding dependency checks at the beginning of the script to provide clear error messages if required tools are missing, similar to how the script checks for the Homebrew tap directory.
Summary
scripts/test-homebrew.shfor testing the Homebrew formula against unreleased deepwork changesbrew install/brew test../homebrew-deepworkdirectory for the tap locationTest plan
./scripts/test-homebrew.shwith homebrew-deepwork cloned as sibling directory🤖 Generated with Claude Code