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

cloudflare-cli4 2.19.4 (new formula) #171268

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dgellow
Copy link
Contributor

@dgellow dgellow commented May 9, 2024

  • Have you followed the guidelines for contributing?
  • Have you ensured that your commits follow the commit style guide?
  • Have you checked that there aren't other open pull requests for the same formula update/change?
  • Have you built your formula locally with HOMEBREW_NO_INSTALL_FROM_API=1 brew install --build-from-source <formula>, where <formula> is the name of the formula you're submitting?
  • Is your test running fine brew test <formula>, where <formula> is the name of the formula you're submitting?
  • Does your build pass brew audit --strict <formula> (after doing HOMEBREW_NO_INSTALL_FROM_API=1 brew install --build-from-source <formula>)? If this is a new formula, does it pass brew audit --new <formula>?

Hi,

I'm opening this pull request to add a new formula to Homebrew for the CLI tool cli4 used to interact with Cloudflare API v4.

The audit is currently failing with:

cloudflare-cli4
  * GitHub repository not notable enough (<30 forks, <30 watchers and <75 stars)
Error: 1 problem in 1 formula detected.

The command line tool has been extracted from https://github.com/cloudflare/python-cloudflare to https://github.com/cloudflare/python-cloudflare-cli4 only yesterday, making it difficult for the repository to reach that level of notoriety. But the version that was packaged alongside cloudflare on PyPi exists since multiple years and has been advertised by Cloudflare (see this blog post for example: https://blog.cloudflare.com/python-cloudflare).

The next version of the python SDK won't be packaged with the CLI anymore and we want to ensure it stays available to current users.

I haven't contributed formulas to homebrews since a very long time, please tell me if I should correct anything.

This commit adds a new formula for Cloudflare's official CLI tool for the version 4 of the API.
The tool is fairly complex and can be used to interact with the API is various ways, some examples can be found in the README[0].

The project repository is at https://github.com/cloudflare/python-cloudflare-cli4.

`cli4`, the command line tool, was previously packaged as part of the `cloudflare` PyPi package but will now be packaged separately.

The homebrew package should be equivalent to the version published at PyPi[1] under the name cloudflare-cli4.

[0]: https://github.com/cloudflare/python-cloudflare-cli4/blob/main/README.md
[1]: https://pypi.org/project/cloudflare-cli4/
@github-actions github-actions bot added python Python use is a significant feature of the PR or issue new formula PR adds a new formula to Homebrew/homebrew-core labels May 9, 2024
@chenrui333 chenrui333 changed the title Add Formula for cloudflare-cli4 cloudflare-cli4 2.19.4 (new formula) May 9, 2024
Comment on lines +58 to +59
assert_match "version: 2.19.4", shell_output("#{bin}/cli4 --version 2>&1", 1)
assert_match "usage: cli4", shell_output("#{bin}/cli4 --help 2>&1", 1)
Copy link
Member

Choose a reason for hiding this comment

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

We need a test that exercises the some of the functionality of the app. Version checks or usage checks (foo --version or foo --help) are not sufficient, as explained in the formula cookbook.

In most cases, a good test would involve running a simple test case: run #{bin}/foo input.txt.

  • Then you can check that the output is as expected (with assert_equal or assert_match on the output of shell_output)
  • You can also check that an output file was created, if that is expected: assert_predicate testpath/"output.txt", :exist?

Some advice for specific cases:

  • If the formula is a library, compile and run some simple code that links against it. It could be taken from upstream's documentation / source examples.
  • If the formula is for a GUI program, try to find some function that runs as command-line only, like a format conversion, reading or displaying a config file, etc.
  • If the software cannot function without credentials, a test could be to try to connect with invalid credentials (or without credentials) and confirm that it fails as expected.
  • Same if the software requires a virtual machine, docker instance, etc. to be running.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Noted, thanks for the feedback.

I did see that section of the cookbook and thought the last line would apply here:

We want tests that don’t require any user input and test the basic functionality of the application. For example foo build-foo input.foo is a good test and (despite their widespread use) foo --version and foo --help are bad tests. 
However, a bad test is better than no test at all.

But I will try to find a better test case

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@chenrui333 Could you clarify if sending requests to an external API would be ok in a test case? From what I understand tests aren't expected to be run on end users machines, so that shouldn't be a privacy issue. But I also wouldn't expect Homebrew to be ok with tests sending requests to cloudflare.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think cli4 --dump could work here. The CLI tool is really about sending requests, so that doesn't really test the core behaviour, but that's for sure better than --help and --version.

The output is 889 lines, is there a way to assert over something that large, or is it ok to match a subset of the output?

Copy link
Member

Choose a reason for hiding this comment

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

The output is 889 lines, is there a way to assert over something that large, or is it ok to match a subset of the output?

you can match the subset.

Copy link
Member

Choose a reason for hiding this comment

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

just need to be a bit substantial than help and version

Copy link
Member

Choose a reason for hiding this comment

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

@dgellow any update on this?

@chenrui333 chenrui333 added notability Project is not notable enough for inclusion CI-no-fail-fast Continue CI tests despite failing GitHub Actions matrix builds. almost there PR is nearly ready to merge labels May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
almost there PR is nearly ready to merge CI-no-fail-fast Continue CI tests despite failing GitHub Actions matrix builds. new formula PR adds a new formula to Homebrew/homebrew-core notability Project is not notable enough for inclusion python Python use is a significant feature of the PR or issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants