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

Fixes #6282: Run front-end tests in pre-push hook, only if changes are made in JS files. #6289

Merged
merged 23 commits into from
Feb 20, 2019

Conversation

anubhavsinha98
Copy link
Contributor

Explanation

The frontend tests only run, if any changes are made in JavaScript files.

Checklist

  • The PR title starts with "Fix #bugnum: ", followed by a short, clear summary of the changes. (If this PR fixes part of an issue, prefix the title with "Fix part of #bugnum: ...".)
  • The PR explanation includes the words "Fixes #bugnum: ..." (or "Fixes part of #bugnum" if the PR only partially fixes an issue).
  • The linter/Karma presubmit checks have passed.
    • These should run automatically, but if not, you can manually trigger them locally using python scripts/pre_commit_linter.py and bash scripts/run_frontend_tests.sh.
  • The PR is made from a branch that's not called "develop".
  • The PR follows the style guide.
  • The PR is assigned to an appropriate reviewer.
    • If you're a new contributor, please ask on Gitter for someone to assign a reviewer.
    • If you're not sure who the appropriate reviewer is, please assign to the issue's "owner" -- see the "talk-to" label on the issue.

Copy link
Member

@seanlip seanlip left a 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.

filename for filename in files_to_lint if
filename.endswith('.js')]

if js_files_to_check == []:
Copy link
Member

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).

Copy link
Contributor Author

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. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -295,6 +295,19 @@ def _install_hook():
print 'Copied file to .git/hooks directory'


def run_frontend_tests_status(files_to_lint):
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@codecov-io
Copy link

codecov-io commented Feb 18, 2019

Codecov Report

Merging #6289 into develop will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           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.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 626c4fd...e49ed77. Read the comment docs.

@anubhavsinha98
Copy link
Contributor Author

Hi @seanlip, done with changes. PTAL. Thanks!

@@ -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."""
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Member

@seanlip seanlip left a 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.

@@ -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."""
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Contributor Author

@anubhavsinha98 anubhavsinha98 Feb 18, 2019

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?

Copy link
Contributor

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

Copy link
Member

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.)

Copy link
Contributor

Choose a reason for hiding this comment

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

@seanlip We have issue #6081 open for this. Thanks

@anubhavsinha98
Copy link
Contributor Author

Hi @seanlip, changes done. PTAL. Thanks!

"""Returns true if diff includes JS files."""

"""Returns true if diff includes JS files.
Args:
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done


"""Returns true if diff includes JS files.
Args:
files_to_lint: list of files to be linted.
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@anubhavsinha98
Copy link
Contributor Author

Hi @seanlip, changes are done. Thanks!

Copy link
Member

@seanlip seanlip left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

@nithusha21
Copy link
Contributor

Hi @anubhavsinha98, could you please add a changelog label (before merging) as mentioned here. Thanks!

@anubhavsinha98
Copy link
Contributor Author

anubhavsinha98 commented Feb 19, 2019

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.

@seanlip
Copy link
Member

seanlip commented Feb 20, 2019

Hi @apb7, we need to get this merged. Could you please review as codeowner?

Thanks!

Copy link
Contributor

@apb7 apb7 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @anubhavsinha98 :)

@apb7 apb7 merged commit 6275049 into oppia:develop Feb 20, 2019
@anubhavsinha98 anubhavsinha98 deleted the pre_push_hook branch March 15, 2019 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants