-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Fixes #6282: Run front-end tests in pre-push hook, only if changes are made in JS files. #6289
Conversation
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 @anubhavsinha98! Left some comments.
scripts/pre_push_hook.py
Outdated
filename for filename in files_to_lint if | ||
filename.endswith('.js')] | ||
|
||
if js_files_to_check == []: |
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.
Replace all this by: return bool(js_files_to_check)
.
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.
Oh Thanks @seanlip, nice idea. :)
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.
Done
scripts/pre_push_hook.py
Outdated
@@ -295,6 +295,19 @@ def _install_hook(): | |||
print 'Copied file to .git/hooks directory' | |||
|
|||
|
|||
def run_frontend_tests_status(files_to_lint): |
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 is not clear: it sounds like the function is supposed to run the tests, but instead it's just doing a check. So maybe call it does_diff_include_js_files() instead.
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.
Done
Codecov Report
@@ Coverage Diff @@
## develop #6289 +/- ##
========================================
Coverage 45.41% 45.41%
========================================
Files 594 594
Lines 30979 30979
Branches 4636 4636
========================================
Hits 14069 14069
Misses 16910 16910 Continue to review full report at Codecov.
|
Hi @seanlip, done with changes. PTAL. Thanks! |
scripts/pre_push_hook.py
Outdated
@@ -295,6 +295,16 @@ def _install_hook(): | |||
print 'Copied file to .git/hooks directory' | |||
|
|||
|
|||
def does_diff_include_js_files(files_to_lint): | |||
"""Checks if frontend tests needs to be run.""" |
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 doc string seems to be wrong -- the function checks if the diff includes JS files, right?
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.
Done.
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.
One more comment but otherwise LGTM.
scripts/pre_push_hook.py
Outdated
@@ -295,6 +295,16 @@ def _install_hook(): | |||
print 'Copied file to .git/hooks directory' | |||
|
|||
|
|||
def does_diff_include_js_files(files_to_lint): | |||
"""Returns true if diff includes JS files.""" |
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.
Missing Args, Returns docstrings.
/cc @oppia/dev-workflow-team we should check for these?
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.
Done.
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.
Missing Args, Returns docstrings.
/cc @oppia/dev-workflow-team we should check for these?
Yeah, I also think this check should be added, that every function should have Args and Returns docstrings. What do you suggest @apb7?
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.
What about those functions which does not return anything nor has any args? One example of this is here -> https://github.com/oppia/oppia/blob/develop/core/controllers/base.py#L520
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.
Hm, the lint check should be able to distinguish those by looking at the function signature? Not sure if you can detect returns though. Maybe see if the body contains any return statements.
(And yep, if there are no Args, then no "Args:" section is needed in the docstring. Ditto if there's nothing returned.)
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.
Hi @seanlip, changes done. PTAL. Thanks! |
"""Returns true if diff includes JS files.""" | ||
|
||
"""Returns true if diff includes JS files. | ||
Args: |
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.
Follow existing spacing conventions. There should be a newline above Args and a newline above Returns.
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.
Done
scripts/pre_push_hook.py
Outdated
|
||
"""Returns true if diff includes JS files. | ||
Args: | ||
files_to_lint: list of files to be linted. |
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.
Missing typeinfo. Also, docstrings have a specific punctuation format, please look at other files to see what it is and follow it exactly.
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.
Done.
Hi @seanlip, changes are done. Thanks! |
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. Thanks!
Hi @anubhavsinha98, could you please add a changelog label (before merging) as mentioned here. Thanks! |
Hi @nithusha21 thanks for the info. Added the changelog label. |
Hi @apb7, we need to get this merged. Could you please review as codeowner? Thanks! |
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, thanks @anubhavsinha98 :)
Explanation
The frontend tests only run, if any changes are made in JavaScript files.
Checklist
python scripts/pre_commit_linter.py
andbash scripts/run_frontend_tests.sh
.