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

feat: add new input to allow include statements at the top of formula class #46

Merged
merged 12 commits into from
Jul 11, 2024

Conversation

unfrgivn
Copy link
Contributor

@unfrgivn unfrgivn commented Jul 8, 2024

Following the official guidance here for building formulas that deploy python apps. Homebrew provides built-in helper methods for different languages so I have called this generically formula_includes to differentiate that they are inside the Formula (open to suggestions on naming). In order to use these, they must be included inside the Formula class, but outside any of the blocks that Justintime50/homebrew-releaser currently allows for.

I have added a generic placeholder that sits in the global scope of the Formula class, immediately following the metadata properties.

Example formula.rb

class TestGenerateFormula < Formula
  desc "Tool to release scripts, binaries, and executables to github"
  homepage "https://github.com/Justintime50/test-generate-formula"
  ...

  include Language::Python::Virtualenv <-- HERE IS THE NEW TEMPLATE BLOCK

  depends_on "bash" => :build
  depends_on "gcc"

  def install
    ...

@unfrgivn
Copy link
Contributor Author

unfrgivn commented Jul 8, 2024

Let me get your thoughts @Justintime50 before I do any further clean up on this.

@Justintime50
Copy link
Owner

Justintime50 commented Jul 9, 2024

Awesome! I'm for it. This will enable Python apps installable correct?

A few thoughts:

  1. Based on the docs provided, it looks like homebrew wants that includes line as the first item in the formula even before the metadata properties followed by a newline, let's follow suit in case there is a brew audit rule about it so we stay compliant.
  2. Out of curiosity, what other includes are possible?
  3. The lint is failing because I bumped the dev deps inbetween your last PR. You'll want to just clean install and then just lint-fix to pull in the new flake8/mypy rules and fix them. It looks like it corrected them back to the old rules based on your locally installed deps which no longer match the main branch.
  4. We'd want a new formula test to ensure that when the param is passed, the output formula looks like we'd expect. You'll notice there are a bunch of output formula in the test dir. Follow the examples of previous tests to add a new one and assert the new includes line is present and inspect the output file (ensure it gets committed)

@unfrgivn
Copy link
Contributor Author

unfrgivn commented Jul 9, 2024

Looks like Brew has Ruby packages for a few languages with some helper functions, https://rubydoc.brew.sh/Language.html.

Not my area of expertise, but I would assume you could include any valid Ruby package and then reference it inside in the formula.

@unfrgivn
Copy link
Contributor Author

unfrgivn commented Jul 9, 2024

Brew audit actually failed with extra whitespace. Fixing that last issue now.

@unfrgivn unfrgivn marked this pull request as ready for review July 9, 2024 23:47
Copy link
Owner

@Justintime50 Justintime50 left a comment

Choose a reason for hiding this comment

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

Looks great! Small suggestion,

TLDR: the test could be even simpler to ensure we are only testing what we care about in this particular case since we have tests for those other items elsewhere.

test/unit/test_formula.py Outdated Show resolved Hide resolved
test/unit/test_formula.py Outdated Show resolved Hide resolved
@Justintime50 Justintime50 merged commit 250a479 into Justintime50:main Jul 11, 2024
5 checks passed
@Justintime50
Copy link
Owner

v0.19.0 (or v1) shipped with the feature, thanks for adding that! 😃

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