Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

format formulas with brew style --fix #1340

Merged
merged 6 commits into from
Aug 20, 2024

Conversation

cxreiff
Copy link
Contributor

@cxreiff cxreiff commented Aug 18, 2024

Fixes #1331.

Problem

Creating a personal tap with brew tap-new creates a default Github Actions workflow that runs a homebrew-specific style check (brew style <TAPNAME>) on the repo. Cargo-dist's generated homebrew formulas fail this style check. This does not block the core functionality of cargo-dist's homebrew publishing functionality (formula still functions), but does mean that users following cargo-dist's instructions exactly will run into workflow failures (EDIT: This was not true at all- docs mention a plain repo, not one created with brew tap-new).

Previously

It looks like this has come up before (#810) and it was solved by individually fixing each formatting problem in the templates (PR 818).

Solution

Rather than separately chase formatting issues as they come up, the homebrew publish workflow could run brew style --fix on each formula before committing it.

Pros

  • Changes to the homebrew style rules can be adjusted to automatically in the future without changes to cargo-dist's templates.
  • Changes can be made to cargo-dist's templates more freely with less fear of breaking style rules.
  • Keeps templates simple: some Homebrew style rules interact with cargo-dist's templating strategy in ways that take complicated template conditions to solve (there are rules that apply to single statements inside conditionals, while in the formula templates the number of statements in a conditional might vary based on supported platforms.

Cons

  • Homebrew publish workflow will take longer as it will need to install Homebrew every run.
  • Depends on reliability of brew style --fix (could break something without cargo-dist code changes if brew pushes a bad change).
  • Not all style changes are auto-fixable.

Testing

I've tested this by manually making these changes in the generated workflow itself and tagging a release. This means that the generation itself hasn't explicitly been tested.

Example run with new action steps: https://github.com/cxreiff/ttysvr/actions/runs/10436301681

Copy link
Contributor

@mistydemeo mistydemeo left a comment

Choose a reason for hiding this comment

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

Thank you! This won't fix all issues, but it does seem likely to reduce the number of issues like this one going forward.

This PR looks good, but one suggestion.

does mean that users following cargo-dist's instructions exactly will run into workflow failures.

We actually don't recommend that users create a tap with brew tap-new - it's explicitly not mentioned in our documentation! We recommend that users simply create an empty repository to publish packages to. There are some advantages to brew test-bot, but fewer in the cargo-dist case: while one of brew-test-bot's strengths is its ability to produce binary bottle packages, cargo-dist is already distributing binaries without using that infrastructure.

Since brew style iterates through styles very quickly, I do feel it's not always helpful for user taps to make use of it for generated formulae like this one - brew style --fix will help keep us up to date, but we still may end up being somewhat behind Homebrew's style schedule.

@cxreiff
Copy link
Contributor Author

cxreiff commented Aug 19, 2024

Oh wow, I must have read somewhere how to set up a tap and then totally misremembered where I saw it, apologies! Added a correction in the description.

@mistydemeo
Copy link
Contributor

All good! I thought it might be something like that - and was a helpful reminder to me to check our docs to make sure they're actually suggesting what I intended them to!

I'll give this a test tomorrow.

Copy link
Contributor

@mistydemeo mistydemeo left a comment

Choose a reason for hiding this comment

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

Gave it a test, and the changes it made are looking good: mistydemeo/homebrew-cargodisttest@1c5e0ac

Just a couple more suggestions before this gets merged!

Copy link
Contributor

@mistydemeo mistydemeo left a comment

Choose a reason for hiding this comment

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

Thank you! Really appreciate it.

@mistydemeo mistydemeo merged commit 362e078 into axodotdev:main Aug 20, 2024
15 checks passed
@cxreiff cxreiff deleted the publish-homebrew-autoformat branch August 20, 2024 21:10
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 publishing: autogenerated formula fails autogenerated tests
2 participants