Skip to content

fix: homebrew distribution - #128

Open
webbrain-one wants to merge 1 commit into
0x77dev:mainfrom
webbrain-one:webbrain/issue-11
Open

fix: homebrew distribution#128
webbrain-one wants to merge 1 commit into
0x77dev:mainfrom
webbrain-one:webbrain/issue-11

Conversation

@webbrain-one

@webbrain-one webbrain-one commented Jul 27, 2026

Copy link
Copy Markdown

Closes #11

Summary by CodeRabbit

  • New Features
    • Added Homebrew installation support for the pdf-sign command-line tool on Apple Silicon Macs.
    • Included a basic verification test to confirm the installed tool launches successfully.

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

Adds a Homebrew formula for the prebuilt macOS arm64 PdfSign v0.2.0 release, including project metadata, binary installation into Homebrew’s bin directory, and a basic pdf-sign --help test.

Changes

Homebrew distribution

Layer / File(s) Summary
Formula installation and CLI test
Formula/pdf-sign.rb
Defines the PdfSign release URL, version, license, and SHA-256 value; installs the pdf-sign binary and validates CLI availability with pdf-sign --help.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Poem

A rabbit hops where formulas grow,
“PdfSign” joins the brew below.
An arm64 binary, snug and bright,
Help text proves it runs just right.
Hop, hop—signed PDFs take flight!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main change: adding Homebrew distribution support via a formula.
Linked Issues check ✅ Passed The PR fulfills issue #11 by creating a new Homebrew formula as requested.
Out of Scope Changes check ✅ Passed The changes stay within scope of the Homebrew formula request and add no unrelated code.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Formula/pdf-sign.rb`:
- Around line 4-5: Replace the placeholder sha256 value in the Formula
definition with the actual SHA-256 checksum computed from the exact v0.2.0
pdf-sign-macos-arm64 release asset referenced by url.
- Around line 4-5: Update the formula’s platform handling around the macOS arm64
URL in the top-level formula definition: either add verified platform-specific
artifacts and SHA256 values for Linux, WSL, and Intel macOS, or explicitly
restrict installation to supported macOS arm64 systems using Homebrew platform
guards and an appropriate caveat. Ensure unsupported users cannot install the
incompatible binary.
- Around line 8-10: Update the install method to install the downloaded URL
basename pdf-sign-macos-arm64 and rename it to pdf-sign during installation, so
the executable is exposed under the expected command name.
- Around line 12-14: Update the formula’s test block to invoke the installed
pdf-sign executable through Homebrew’s standard system API instead of the
unsupported test.shell_script method. Preserve the existing --help argument and
test intent.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6906aaac-ea97-425c-beb1-9eee577e2324

📥 Commits

Reviewing files that changed from the base of the PR and between 20b2a51 and ba4c699.

📒 Files selected for processing (1)
  • Formula/pdf-sign.rb

Comment thread Formula/pdf-sign.rb
Comment on lines +4 to +5
url "https://github.com/0x77dev/pdf-sign/releases/download/v0.2.0/pdf-sign-macos-arm64"
sha256 "sha256-hash-placeholder" # To be updated on release

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🔴 Critical | ⚡ Quick win

Replace the placeholder checksum before merging.

Line 5 is not a valid SHA-256 for the release artifact, so Homebrew’s download verification will reject installation. Compute the checksum for the exact v0.2.0 asset and commit it. (docs.brew.sh)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Formula/pdf-sign.rb` around lines 4 - 5, Replace the placeholder sha256 value
in the Formula definition with the actual SHA-256 checksum computed from the
exact v0.2.0 pdf-sign-macos-arm64 release asset referenced by url.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== formula =="
if [ -f Formula/pdf-sign.rb ]; then
  cat -n Formula/pdf-sign.rb
else
  echo "Formula/pdf-sign.rb not found"
fi

echo
echo "== git status/stat =="
git status --short
git diff -- Formula/pdf-sign.rb | sed -n '1,160p' || true

echo
echo "== Homebrew formula patterns for platform restrictions in repository =="
rg -n 'only_.*platform|on_(macos|linux)|caveats|system \?|not_recommended|platform :|MacOS\.is_arm64|arch == "arm64"|only_arm64|if macos\.arm64|if SystemArchitecture::X86_64' -S --glob '*.rb' | head -200

Repository: 0x77dev/pdf-sign

Length of output: 786


🌐 Web query:

Homebrew formula binary installation error unsupported platform download URL linux Windows documentation

💡 Result:

Homebrew is officially supported on Linux and Windows Subsystem for Linux (WSL) 2 [1][2]. It is not supported for native Windows (i.e., outside of WSL) [1][3]. If you are encountering an "unsupported platform" or similar binary installation error, it is likely due to one of the following reasons: 1. Improper Installation Path: Homebrew must be installed in its default, supported prefix to correctly download and utilize precompiled binary packages (known as bottles) [4][5]. The required paths are: - Linux/WSL: /home/linuxbrew/.linuxbrew [6][5] - macOS Intel: /usr/local [6][5] - macOS Apple Silicon: /opt/homebrew [6][5] Installing outside these paths often forces Homebrew to attempt to build from source, which is frequently unsupported or prone to failure [4][7]. 2. Architecture/Emulator Mismatch: Homebrew enforces strict architecture checks [8][7]. For example, attempting to install ARM-based Homebrew in an Intel default prefix (or vice versa) will trigger an error [7][9]. Ensure you are using the correct terminal architecture or that your shell is not being incorrectly translated (e.g., via Rosetta 2 on macOS) [8][9]. 3. WSL 1 Limitations: While Homebrew may function on WSL 1, it is considered a Tier 3 (experimental/unsupported) platform due to known compatibility issues [1][2]. The Homebrew project strongly recommends using WSL 2 [1][2]. To resolve most binary installation errors: - Ensure Homebrew is installed in the correct default prefix for your OS [4][5]. - Verify that your system meets the requirements (e.g., glibc/gcc on Linux) [1][2]. - If you have an unsupported configuration, the recommended solution is to perform a clean, default installation [4][7]. For further troubleshooting, consult the official Homebrew documentation at https://docs.brew.sh/ [5].

Citations:


Restrict or add artifacts for unsupported platforms.

This formula only exposes a macOS arm64 binary, while Homebrew also runs on Linux, WSL, and Intel Macs. Add platform-specific URLs/checksums or reject unsupported platforms with on_linux, only_on :macos, and/or a caveats; otherwise those users can install an executable that will not run on their platform.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Formula/pdf-sign.rb` around lines 4 - 5, Update the formula’s platform
handling around the macOS arm64 URL in the top-level formula definition: either
add verified platform-specific artifacts and SHA256 values for Linux, WSL, and
Intel macOS, or explicitly restrict installation to supported macOS arm64
systems using Homebrew platform guards and an appropriate caveat. Ensure
unsupported users cannot install the incompatible binary.

Comment thread Formula/pdf-sign.rb
Comment on lines +8 to +10
def install
bin.install "pdf-sign"
end

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

Install the filename downloaded by the URL.

The URL’s basename is pdf-sign-macos-arm64, but bin.install "pdf-sign" looks for pdf-sign in the staging directory. Rename during installation:

Proposed fix
-    bin.install "pdf-sign"
+    bin.install "pdf-sign-macos-arm64" => "pdf-sign"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
def install
bin.install "pdf-sign"
end
def install
bin.install "pdf-sign-macos-arm64" => "pdf-sign"
end
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Formula/pdf-sign.rb` around lines 8 - 10, Update the install method to
install the downloaded URL basename pdf-sign-macos-arm64 and rename it to
pdf-sign during installation, so the executable is exposed under the expected
command name.

Comment thread Formula/pdf-sign.rb
Comment on lines +12 to +14
test do
test.shell_script { "pdf-sign --help" }
end

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Locate formula:"
fd -a '^(pdf-sign\.rb|.*\.rb)$' . | sed 's#^\./##' | rg 'Formula|pdf-sign|test-shell-script|shell_script' || true

echo
echo "Formula snippet:"
if [ -f Formula/pdf-sign.rb ]; then
  cat -n Formula/pdf-sign.rb | sed -n '1,80p'
fi

echo
echo "Search test.shell_script usage in repo:"
rg -n 'test\.shell_script|shell_script \{' . --glob '*.rb' || true

echo
echo "Search installed executable test patterns nearby:"
rg -n "bin/\S+.*--help|system \\\$?\\\$?\\{bin\\}/|test\s*\n\s*\{" . --glob '*.rb' | head -100

Repository: 0x77dev/pdf-sign

Length of output: 1102


🌐 Web query:

Homebrew Formula Cookbook example test do system bin foo --help

💡 Result:

In a Homebrew formula, the test do block is used to verify that the installed software functions correctly [1]. While common commands like foo --version or foo --help are often used for basic smoke tests, Homebrew's official documentation considers them weak tests [1][2]. The preferred approach is to perform a test that exercises the application's actual functionality, such as processing an input file or performing a specific operation [1][3]. If you were to include a test using a system command (often preferred over bare backticks for better error handling and output separation), the modern syntax is to separate the command and its arguments as individual strings [4]: test do system bin/"foo", "--help" end Key considerations for writing tests in Homebrew: 1. Test Environment: The test do block automatically creates a temporary, isolated directory [1]. The environment variable HOME is set to this temporary directory, ensuring the test does not interact with your actual home directory [1]. 2. System Commands: Using system "cmd", "arg1", "arg2" is the recommended way to invoke executables [4]. This avoids shell injection issues and correctly handles arguments with spaces [4]. 3. Assertions: To verify output, you can use shell_output to capture the command's standard output [1]: assert_match "Usage:", shell_output("#{bin}/foo --help") 4. Best Practices: Aim for tests that do not require user input and verify real functionality, such as creating a small test file, running the tool against it, and checking the resulting output [1][5][6]. While a --help test is better than no test at all, reviewers and maintainers generally prefer tests that confirm the software is fully operational [1][3].

Citations:


🌐 Web query:

Homebrew FormulaDSL shell_script test.shell_script

💡 Result:

There is no specialized shell_script method within the Homebrew Formula DSL for defining tests. Instead, to execute shell commands within a formula's test block, you use standard Ruby system command execution methods, primarily shell_output or system [1][2][3]. The test block, defined as test do ... end within a Homebrew Formula, provides an environment where you can verify the installed software's functionality [1][2]. Because it is a standard Ruby block, you have access to various helper methods provided by Homebrew [2][3]: 1. system: Executes a command. It raises an error if the command fails (returns a non-zero exit status). 2. shell_output: Executes a command and returns its standard output. It also raises an error if the command fails, making it ideal for checking the output of commands like --version or specific subcommands. 3. testpath: A reference to a temporary directory created automatically for the test [1][4][5]. Homebrew sets the HOME environment variable to this path during the test, ensuring tests do not interfere with your actual user environment [1]. Example of a typical test block: test do # Write a test file or run a command assert_match "expected output", shell_output("#{bin}/my_executable --version") system "#{bin}/my_executable", "arg1", "arg2" end If you are looking for functionality related to generating shell completions, Homebrew provides the generate_completions_from_executable method, which is distinct from writing general-purpose shell tests [2][6].

Citations:


🌐 Web query:

"test.shell_script" "Homebrew"

💡 Result:

In the context of Homebrew, there is no specific command or DSL element named test.shell_script [1][2]. If you are looking to execute shell commands within a Homebrew formula during the test phase, you use the standard Ruby system/command execution methods provided within the test do block [2][3]. The recommended approach is to use methods like shell_output to run shell commands and assert their output [4][2]. Common patterns inside a formula's test do block include: 1. Using shell_output: This runs a command and returns the output, which you can then check with assertions like assert_match or assert_equal [4][2]. test do assert_match "expected output", shell_output("#{bin}/program --version") end 2. Using system: This executes a command and expects it to succeed (exit with 0). If the command fails, the test will fail [4][2]. test do system "#{bin}/program", "arg1", "arg2" end If you are referring to Homebrew's internal development tooling, there are files such as Library/Homebrew/test/utils/shell_spec.rb used for testing Homebrew's own utilities, but these are not part of the formula DSL available to users [5]. Additionally, Homebrew allows for external commands, which can be implemented as shell scripts, but these follow a naming convention (e.g., brew-extcmd) and are distinct from formula test blocks [6].

Citations:


Use the standard Homebrew test command API.

test.shell_script is not part of the formula test DSL, so this test is likely to raise NoMethodError. Call the installed executable with system, as Homebrew examples show.

Proposed fix
   test do
-    test.shell_script { "pdf-sign --help" }
+    system "#{bin}/pdf-sign", "--help"
   end
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
test do
test.shell_script { "pdf-sign --help" }
end
test do
system "#{bin}/pdf-sign", "--help"
end
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Formula/pdf-sign.rb` around lines 12 - 14, Update the formula’s test block to
invoke the installed pdf-sign executable through Homebrew’s standard system API
instead of the unsupported test.shell_script method. Preserve the existing
--help argument and test intent.

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.

homebrew distribution

1 participant