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
base: master
Are you sure you want to change the base?
Conversation
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/
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
HOMEBREW_NO_INSTALL_FROM_API=1 brew install --build-from-source <formula>
, where<formula>
is the name of the formula you're submitting?brew test <formula>
, where<formula>
is the name of the formula you're submitting?brew audit --strict <formula>
(after doingHOMEBREW_NO_INSTALL_FROM_API=1 brew install --build-from-source <formula>
)? If this is a new formula, does it passbrew 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:
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.