Skip to content

Fix the lint problems in the generated Homebrew formula - #57

Merged
joe4dev merged 1 commit into
mainfrom
fix-generated-formula-lint
Sep 23, 2026
Merged

joe4dev merged 1 commit into
mainfrom
fix-generated-formula-lint

Conversation

@joe4dev

@joe4dev joe4dev commented Sep 22, 2026

Copy link
Copy Markdown
Member

Motivation

Formula/localstack-cli.rb in localstack/homebrew-tap fails brew style with 5 offences and brew audit with 7 problems. The formula is generated from this repo on every release, so it can only be fixed here.

The tap now has CI that reports this (localstack/homebrew-tap#10), but it cannot block on the formula while the problems exist. This clears them, so that check can become mandatory.

Solution

Install block indentation (2 offences). The extra indentation was deliberate, and is no longer needed: homebrew_releaser/formula.py:258 indents every line by the template's 4 spaces and strips the indent from only the first, so the old workaround now causes what it once fixed.

BEFORE                            AFTER
  def install                       def install
    libexec.install Dir["*"]          libexec.install Dir["*"]
        bin.install_symlink ...       bin.install_symlink ...

Test line (2 offences). An ambiguous regexp literal, and a redundant 0 passed to shell_output:

assert_match(/LocalStack Command Line Interface/, shell_output("#{bin}/localstack --help"))

Licence (1 problem). LICENSE.txt held only the Apache-2.0 short notice, which GitHub's licensee cannot match, so the API reported NOASSERTION and the generator copied that into the formula. Replaced with the full Apache-2.0 text, copyright lines moved to NOTICE as Apache recommends. Not a change of licence — it formalises the one the file already declared.

The version: input (1 problem). Dropped, which lets Homebrew scan the version from the URL and removes the version is redundant finding.

It was added for Justintime50/homebrew-releaser#39, where Homebrew read 64 out of an …-darwin-arm64.tar.gz URL. That was a Homebrew bug, not a generator bug, and it is fixed — feeding Homebrew 7.0's scanner the exact URL from that issue now gives the right answer:

runner-2.8.4-darwin-arm64.tar.gz (issue #39)   -> 2.8.4      (reported as "64" in 2023)
localstack-cli-2026.8.0-darwin-arm64.tar.gz    -> 2026.8.0

The generated formula resolves stable: 2026.8.0 with no version stanza.

The last 2 problems came from the repository description, now Deprecated LocalStack CLI packaged with PyInstaller, superseded by lstk.

Validation

Ran homebrew_releaser.formula.generate_formula_data with these inputs and the live repository description, then linted the result — so this is what the next release generates:

Check Before After
brew style 5 offences clean
brew audit 7 problems clean
brew audit --online 7 problems clean

Licence detection, confirmed on this branch before merge:

GET /repos/localstack/localstack-cli/license                   -> NOASSERTION / Other
GET .../license?ref=fix-generated-formula-lint                 -> Apache-2.0

The generated desc becomes Deprecated localstack cli packaged with pyinstaller, superseded by lstk. The generator calls .capitalize(), so casing is lowered whatever the repo says; that is cosmetic and needs an upstream change.

Follow-up

After this merges and a release publishes, the formula step in localstack/homebrew-tap#10 can drop its continue-on-error: true and become a hard gate.

Review

Human review advised: it replaces LICENSE.txt and changes the release path, which cannot be exercised without publishing a release.

🤖 Generated with Claude Code

@joe4dev

joe4dev commented Sep 22, 2026

Copy link
Copy Markdown
Member Author

Test results: removing the version: input

Tested without publishing a release. Short version: it works, and the bug it guards against does not reproduce — but the guard is cheap and the payoff is one lint warning, so I have left it in place for you to decide.

Does dropping the input remove the stanza?

Yes. I ran homebrew_releaser.formula.generate_formula_data from Justintime50/homebrew-releaser@v3 with and without it:

Input Emitted
version: v2026.8.0 version "2026.8.0"
omitted (no version stanza)

The generator's own docstring says as much — formula.py:50: "No version attribute if Homebrew can reliably infer the version from the tar URL (GitHub tag)".

Does Homebrew then infer the right version?

The workflow comment cites Justintime50/homebrew-releaser#39, where Homebrew detected 64 from the -amd64/-arm64 URLs. That issue is closed — the version input was its resolution.

Running Homebrew's own scanner against every URL this formula carries:

v2026.8.0.tar.gz                              -> 2026.8.0
localstack-cli-2026.8.0-darwin-amd64.tar.gz   -> 2026.8.0
localstack-cli-2026.8.0-darwin-arm64.tar.gz   -> 2026.8.0
localstack-cli-2026.8.0-linux-amd64.tar.gz    -> 2026.8.0
localstack-cli-2026.8.0-linux-arm64.tar.gz    -> 2026.8.0

And loading the stanza-less formula as a real tap:

inferred stable version: 2026.8.0
stable url: .../localstack-cli-2026.8.0-darwin-arm64.tar.gz

Note the resolved url is the -arm64 one — the exact shape #39 was about — and it still scans correctly. brew style, brew audit and brew audit --online all pass on that formula.

Why I still left it in

Detection depends on the shape of the version string. 2026.8.0 is unambiguous, so the scanner prefers it over the 64. A future version that reads more like an arch suffix could regress, and the failure lands on users rather than in CI, because nothing regenerates the formula until a release publishes.

So the trade is one style warning against a small chance of a broken formula. Removing the input is defensible now that the numbers above exist; keeping it costs one warning that the tap CI reports without blocking. Happy to push the removal if you want the clean sweep.

Co-Authored-By: Claude <noreply@anthropic.com>
@joe4dev
joe4dev force-pushed the fix-generated-formula-lint branch from f3092a1 to a893d49 Compare September 22, 2026 15:40
@joe4dev
joe4dev marked this pull request as ready for review September 22, 2026 15:43

@anisaoshafi anisaoshafi 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.

Thanks for fixing the issues reported in https://github.com/localstack/homebrew-tap/actions/runs/35750559123/job/106823254091 by the CI you added there 👏🏼

@joe4dev
joe4dev merged commit a134b84 into main Sep 23, 2026
6 checks passed
@joe4dev
joe4dev deleted the fix-generated-formula-lint branch September 23, 2026 15:00
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