Skip to content

Conversation

@ncrmro
Copy link
Collaborator

@ncrmro ncrmro commented Jan 29, 2026

Summary

  • Adds scripts/test-homebrew.sh for testing the Homebrew formula against unreleased deepwork changes
  • Builds an sdist tarball from local source, creates a temporary formula pointing to it, and runs brew install/brew test
  • Defaults to sibling ../homebrew-deepwork directory for the tap location

Test plan

  • Run ./scripts/test-homebrew.sh with homebrew-deepwork cloned as sibling directory
  • Verify it builds tarball, installs via Homebrew, and runs tests

🤖 Generated with Claude Code

ncrmro and others added 6 commits January 29, 2026 10:52
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>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.sh for local Homebrew formula testing workflow
  • Implements automated building, installation, and testing of deepwork via Homebrew
  • Provides configurable tap location (defaults to sibling ../homebrew-deepwork directory)

# Set up a local tap with the modified formula
TAP_NAME="local/deepwork-test"
TAP_DIR="$(brew --repository)/Library/Taps/local/homebrew-deepwork-test"

Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
# 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

Copilot uses AI. Check for mistakes.
uv build --sdist

# Find the built tarball
TARBALL=$(ls dist/deepwork-*.tar.gz | head -1)
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
TARBALL=$(ls dist/deepwork-*.tar.gz | head -1)
shopt -s nullglob
tarballs=(dist/deepwork-*.tar.gz)
shopt -u nullglob
TARBALL="${tarballs[0]:-}"

Copilot uses AI. Check for mistakes.
Comment on lines +49 to +51
sed -e "s|url \"https://.*\"|url \"file://$TARBALL_PATH\"|" \
-e "s|sha256 \".*\"|sha256 \"$SHA256\"|" \
"$HOMEBREW_TAP/Formula/deepwork.rb" > "$TAP_DIR/Formula/deepwork.rb"
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
fi

echo "==> Building deepwork from $REPO_DIR"
cd "$REPO_DIR"
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
rm -rf dist/

# Build the sdist tarball
uv build --sdist
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants