-
-
Notifications
You must be signed in to change notification settings - Fork 56
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
Calling bash-unit pre-commit hook in ci + sample setup #107
Conversation
Hi @mdeweerd, Thank you for your PR. First, I find the quality gates that pre-commit is checking on bash_unit already, thanks to your setup, super handy and very efficient, thank you again. As for running the tests per se, I'm not yet comfortable with doing that. I'm not sure I want the tests to be just another quality gate. I mean, I can live with end of file line issues, with quotes confusing usage, etc. but there's no way we can have failing tests, never. So I appreciate the idea of having both pre-commit on one side and the tests on the other side as first class citizens and not the tests lost in the pre-commit quality gates. In summary: I love the idea of having two distinct C.I. steps: one for the tests, another for pre-commit. This PR also helps me realize that we might have an issue with bash_unit as a pre-commit anyway. As a developer writing code and testing it with bash_unit what I want is for the tests to run when the production code is changed. Running the tests when I change the test is important of course but when the production code is changed, this is when I want to have the tests ran. And as you write in this PR's description, pre-commit will only run on changed files. In this particular instance, what I want is for all the tests to run when the file bash_unit is changed. So for pre-commit + bash_unit to be very useful I would probably want to say something like:
But maybe we're a bit out of scope of what a pre-commit hook should do? As you mention, we can run I'm just thinking out loud here and wondering how one would use bash_unit with pre-commit. Not being a user myself this does not have strong value so I wouldn't change your contribution about it in #100 you certainly nows it better than I do. Anyway, not a fan of letting pre-commit run all the tests. I have also other bad reasons to not do it as bash_unit is having issues on BSD systems currently. So when coding on BSD (OS X in my case) you might need to have an alternative setup to run the tests like docker, for instance. So pre-commit would be a problem here... until BSD execution issues are solved, of course. On a side note, I've tried to use it anyway but I can't make it work seemingly. If I run pre-commit on all files I don't see any bash_unit step:
|
Overall I agree and what I did here is probably inline with your observations. The reasons to add bash-commit to the pre-commit configuration are:
The hook does not run by default as I defined that it should run only in the "manual" stage. When you run pre-commit from the CLI without the --hook-stage option it will not run. Documentation and 'ci' do the rest to run the tests. Again, having it as a pre-commit configuration makes it easy to setup and update - one just needs to change the revision number and the project is using another bash_unit version. Using pre-commit for the configuration also allows that version control of the tool used. While I admit that one could integrate the bash_unit version in the link to download it from, the readme does propose to install it from "master", and the install.sh script will just get the latest release. So basically I think we agree, it is just a matter of using pre-commit in a way that matches that. EDIT:
EDIT2:
|
I've added a |
Thanks for your detailed answer @mdeweerd , it all makes sense to me 👍 |
This is an update to the pre-commit configuration so that it uses the hook proposed in this repository.
I used a specific commit has as there is/was no regular tag yet.
This alos shows a limitation of pre-commit: only changed files are provides as arguments and there is no option to automatically propose all files matching the regex.
Howevert that means that one could execute bash_unit on a test that changed automatically.
As shown in the integration setup, it's still possible to run on all files usin the '-a/--all-files' option. The other solution is to use the 'args:' parameter in the hook configuration.