-
-
Notifications
You must be signed in to change notification settings - Fork 78
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
[qa] Add pre-push hook #161 #162
[qa] Add pre-push hook #161 #162
Conversation
@atb00ker This is functional in the current state, but I would like to add a couple more features:
What do you think? |
ff9c4b2
to
531686f
Compare
Can this file be directly added to hooks folder? Do we need to install it for some reason? Two more things:
|
From what I know, it sits in
I will try to add this in the next commit |
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 we should make this reusable for every openwisp module, having this mechanism only in openwisp-utils is not very useful.
If we could make this more generic it would be a lot more useful, eg:
- make it possible to call the script with
openwisp-pre-push-hook
(similar toopenwisp-qa-format
andopenwisp-qa-check
runtests.py
works only for python modules, we also haveruntests
and npm packages which get tested withyarn test
, would be great if the script is able to figure this out (call the file only if exists, check ifpackage.json
is present and in that case useyarn test
- the push may be done without the python virtualenv being enabled, try importing openwisp_utils and if the import fails print to standard error a message that advises to activate the right virtualenv
@nemesisdesign @atb00ker After the latest commit, |
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.
Looks good! I think we need some basic automated tests for this new code to ensure it will keep working over time also when new contributors will try to change it.
See also my comment below.
openwisp-pre-push-hook
Outdated
"'openwisp_utils' failed to import. Make sure all dependencies " | ||
"are installed and virtual environment is activated." | ||
) | ||
checks = ['run-qa-checks', 'runtests.py', 'runtests'] |
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.
here's some more problems, we need to give this a bit more thought if we want it to really be useful.
For some repositories, running all the tests can take a long time, so we usually run tests using --parallel
.
But in openwisp-monitoring we can't use --parallel
.
More over, in some repos we also run tests with SAMPLE_APP=1
.
Dealing with these cases here would complicate things too much.
I think we could just delegate everything to the run-qa-checks
script in every repository: this script would also run tests, eg:
./run-qa-checks
runs./runtests.py --parallel
andSAMPLE_APP=1 ./runtests.py --parallel
in openwisp-radius./run-qa-checks
runs./runtests.py
andSAMPLE_APP=1 ./runtests.py
in openwisp-monitoring./run-qa-checks
runsyarn test
in openwisp-wifi-login-pages
But we should allow each ./run-qa-checks
script to be called from the CI builds, eg:
./run-qa-checks --ci
, so we can skip the--parallel
flag in some cases otherwise the test coverage would drop.
@atb00ker @pandafy @nepython @NoumbissiValere @okraits what do you think? Any other useful suggestion? Or alternative approach?
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.
This looks good, @purhan I would suggest before this is merged, open a related PR in another module like controller and use it there for actual testing! 😄
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.
./run-qa-checks --ci, so we can skip the --parallel flag in some cases otherwise the test coverage would drop.
What if we instead, use a flag for the hook (--hook
) and everything else works as normal with minimal changes?
@purhan I would suggest to look in this too Pre-Commit. This can make your work a lot easier |
@devkapilbansal this is a handy project but personally I'm not in favor of using third-party libraries for this, though I would still like to hear what the other devs have to say. |
KISS: Keep it stupid simple. |
@atb00ker @nemesisdesign Please take another look at the latest commit. I have moved some of the logic to |
3eccd95
to
829c3e0
Compare
I agree on keeping it simple for now and later on as our understanding and needs grow we can decide to switch to a third party library if we deem it worth it. |
829c3e0
to
cf0ca0e
Compare
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.
LGTM!
Just please squash the 4 commits! 😄
cf0ca0e
to
d32c30c
Compare
@atb00ker Done :) |
Following up on discussion from openwisp/openwisp-docs#100. Should |
I thought this one was already merged? 😮 |
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.
Thanks @atb00ker for pinging me and thanks @purhan for your patience.
Now in order to avoid forgetting about this work and start to use it also in the rest of OpenWISP, what do you suggest would be the next step? Should we add a reference from https://github.com/openwisp/openwisp2-docs?
I guess we already have an issue for that: openwisp/openwisp-docs#100
Yes, I think it belongs in the contribution guidelines. This is more or less an optional feature, could be mentioned in the code conventions section |
Closes #161