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

Fix #9331: Added typescript checks to pre push hook #9334

Merged
merged 13 commits into from May 21, 2020
Merged

Fix #9331: Added typescript checks to pre push hook #9334

merged 13 commits into from May 21, 2020

Conversation

nishantwrp
Copy link
Contributor

@nishantwrp nishantwrp commented May 20, 2020

Overview

  1. This PR fixes Add typescript checks to pre_push_hook #9331
  2. This PR does the following: Added typescript checks to pre push hook

Essential 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 linter/Karma presubmit checks have passed locally on your machine.
  • "Allow edits from maintainers" is checked. (See here for instructions on how to enable it.)
    • This lets reviewers restart your CircleCI tests for you.
  • The PR is made from a branch that's not called "develop".

PR Pointers

  • Oppiabot will notify you when you don't add a PR_CHANGELOG label. If you are unable to do so, please @-mention a code owner (who will be in the Reviewers list), or ask on Gitter.
  • For what code owners will expect, see the Code Owner's wiki page.
  • Make sure your PR follows conventions in the style guide, otherwise this will lead to review delays
  • Never force push. If you do, your PR will be closed.

@oppiabot
Copy link

oppiabot bot commented May 20, 2020

Assigning @kevinlee12 for the first-pass review of this pull request. Thanks!

Copy link
Member

@vojtechjelinek vojtechjelinek left a comment

LGTM!

@codecov
Copy link

codecov bot commented May 20, 2020

Codecov Report

Merging #9334 into develop will decrease coverage by 0.00%.
The diff coverage is n/a.

@@             Coverage Diff             @@
##           develop    #9334      +/-   ##
===========================================
- Coverage    54.05%   54.04%   -0.00%     
===========================================
  Files          878      877       -1     
  Lines        36306    36310       +4     
  Branches      4346     4346              
===========================================
+ Hits         19622    19623       +1     
- Misses       15695    15697       +2     
- Partials       989      990       +1     
Flag Coverage Δ
#frontend 54.04% <ø> (-<0.01%) ⬇️
Impacted Files Coverage Δ
...topics-and-skills-dashboard-backend-api.service.ts 69.23% <0.00%> (-5.77%) ⬇️
...age/topics-and-skills-dashboard-page.controller.ts 15.56% <0.00%> (-0.17%) ⬇️
...opics-and-skills-dashboard-domain.constants.ajs.ts

@@ -396,6 +398,16 @@ def main(args=None):
python_utils.PRINT(
'Push failed, please correct the linting issues above.')
sys.exit(1)

typescript_check_status = 0
if does_diff_include_js_or_ts_files(files_to_lint):
Copy link
Member

@DubeySandeep DubeySandeep May 20, 2020

Choose a reason for hiding this comment

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

Why we should run a typescript test if js file changes? Any specific reason? (If yes, can you please add a code comment?)

Copy link
Contributor Author

@nishantwrp nishantwrp May 20, 2020

Choose a reason for hiding this comment

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

Nice Catch! It should be done only for ts files. Done!

Copy link
Member

@DubeySandeep DubeySandeep left a comment

@nishantwrp, Thanks for the PR, I've left a few comments PTAL!

@@ -66,6 +66,8 @@
TRAVIS_CI_PROTRACTOR_CHECK_CMDS = [
PYTHON_CMD, '-m', 'scripts.check_e2e_tests_are_captured_in_ci']
GIT_IS_DIRTY_CMD = 'git status --porcelain --untracked-files=no'
TYPESCRIPT_CHECKS_CMD = [
PYTHON_CMD, '-m', 'scripts.typescript_checks']
Copy link
Member

@DubeySandeep DubeySandeep May 20, 2020

Choose a reason for hiding this comment

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

Can we move this to the line above?

Copy link
Contributor Author

@nishantwrp nishantwrp May 20, 2020

Choose a reason for hiding this comment

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

done

Copy link
Member

@DubeySandeep DubeySandeep May 20, 2020

Choose a reason for hiding this comment

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

I was expecting it to be:

TYPESCRIPT_CHECKS_CMDS = [PYTHON_CMD, '-m', 'scripts.typescript_checks']

[Following max 80 chars in a ine]

Copy link
Contributor Author

@nishantwrp nishantwrp May 20, 2020

Choose a reason for hiding this comment

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

done

@@ -396,6 +398,16 @@ def main(args=None):
python_utils.PRINT(
'Push failed, please correct the linting issues above.')
sys.exit(1)

typescript_check_status = 0
Copy link
Member

@DubeySandeep DubeySandeep May 20, 2020

Choose a reason for hiding this comment

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

typescript_checks_status* (Following other variables have similar name)

Copy link
Contributor Author

@nishantwrp nishantwrp May 20, 2020

Choose a reason for hiding this comment

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

done

@@ -396,6 +398,16 @@ def main(args=None):
python_utils.PRINT(
'Push failed, please correct the linting issues above.')
sys.exit(1)

typescript_check_status = 0
if does_diff_include_js_or_ts_files(files_to_lint):
Copy link
Member

@DubeySandeep DubeySandeep May 20, 2020

Choose a reason for hiding this comment

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

I see this check twice (line 413), why don't we move this code inside the same check? (You can use a newline to present visual separation of two checks!)

Copy link
Contributor Author

@nishantwrp nishantwrp May 20, 2020

Choose a reason for hiding this comment

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

not needed

@@ -66,6 +66,8 @@
TRAVIS_CI_PROTRACTOR_CHECK_CMDS = [
PYTHON_CMD, '-m', 'scripts.check_e2e_tests_are_captured_in_ci']
GIT_IS_DIRTY_CMD = 'git status --porcelain --untracked-files=no'
TYPESCRIPT_CHECKS_CMD = [
Copy link
Member

@DubeySandeep DubeySandeep May 20, 2020

Choose a reason for hiding this comment

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

TYPESCRIPT_CHECKS_CMDS

Copy link
Contributor Author

@nishantwrp nishantwrp May 20, 2020

Choose a reason for hiding this comment

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

done

@nishantwrp nishantwrp requested a review from DubeySandeep May 20, 2020
Copy link
Member

@DubeySandeep DubeySandeep left a comment

@nishantwrp, LGTM!, I've left a few minor comments, PTAL!

Also, can you show us the time diff between old and new pre-push hook completion time? [Change 3 files for each extension (ts, js, html, py) to have a better and more general report]

[I'll approve this PR once you'll resolve the existing comments and share the testing report!]

@@ -345,6 +347,22 @@ def does_diff_include_js_or_ts_files(files_to_lint):
return False


def does_diff_include_ts_files(files_to_lint):
Copy link
Member

@DubeySandeep DubeySandeep May 20, 2020

Choose a reason for hiding this comment

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

diff_files as arg name maybe? (Considering lint word is out of context of this method (as per the method name).)

Copy link
Contributor Author

@nishantwrp nishantwrp May 20, 2020

Choose a reason for hiding this comment

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

Already a method does_diff_include_js_or_ts_files follows the same convention.. Can you ptal!

Copy link
Member

@DubeySandeep DubeySandeep May 20, 2020

Choose a reason for hiding this comment

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

Already a method does_diff_include_js_or_ts_files follows the same convention

Yeah, I agree but I think they are also incorrect because of the same reason!

Copy link
Contributor Author

@nishantwrp nishantwrp May 20, 2020

Choose a reason for hiding this comment

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

done

@@ -66,6 +66,8 @@
TRAVIS_CI_PROTRACTOR_CHECK_CMDS = [
PYTHON_CMD, '-m', 'scripts.check_e2e_tests_are_captured_in_ci']
GIT_IS_DIRTY_CMD = 'git status --porcelain --untracked-files=no'
TYPESCRIPT_CHECKS_CMD = [
PYTHON_CMD, '-m', 'scripts.typescript_checks']
Copy link
Member

@DubeySandeep DubeySandeep May 20, 2020

Choose a reason for hiding this comment

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

I was expecting it to be:

TYPESCRIPT_CHECKS_CMDS = [PYTHON_CMD, '-m', 'scripts.typescript_checks']

[Following max 80 chars in a ine]

bool. Whether the diff contains changes in any TypeScript files.
"""

for filename in files_to_lint:
Copy link
Member

@DubeySandeep DubeySandeep May 20, 2020

Choose a reason for hiding this comment

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

file_path (As it's going to be the file path, not just the filename, right? [not sure!])

Copy link
Contributor Author

@nishantwrp nishantwrp May 20, 2020

Choose a reason for hiding this comment

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

Already a method does_diff_include_js_or_ts_files follows the same convention.. Can you ptal!

Copy link
Member

@DubeySandeep DubeySandeep May 20, 2020

Choose a reason for hiding this comment

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

Already a method does_diff_include_js_or_ts_files follows the same convention

Yeh I agree, it's incorrect in those place as well, do you think we should fix those as well? [It would be great if you can do that!]

Copy link
Contributor Author

@nishantwrp nishantwrp May 20, 2020

Choose a reason for hiding this comment

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

done

@nishantwrp
Copy link
Contributor Author

nishantwrp commented May 20, 2020

@DubeySandeep The time diff is around 35s.

@nishantwrp nishantwrp requested a review from DubeySandeep May 20, 2020
Copy link
Member

@DubeySandeep DubeySandeep left a comment

@nishantwrp, LGTM! :)

"""Returns true if diff includes JavaScript or TypeScript files.

Args:
files_to_lint: list(str). List of files to be linted.
diff_files: list(str). List of files to be linted.
Copy link
Member

@DubeySandeep DubeySandeep May 20, 2020

Choose a reason for hiding this comment

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

Should we update the arg description accordingly? (here and elsewhere)

Copy link
Contributor Author

@nishantwrp nishantwrp May 20, 2020

Choose a reason for hiding this comment

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

done

@DubeySandeep
Copy link
Member

DubeySandeep commented May 20, 2020

image
@nishantwrp, I see this log on running typescript checks, is it just for me? (Do you know how I can resolve it?)

[Note: This is important to fix as it can block everyone to create a PR or push new commits!]

@nishantwrp
Copy link
Contributor Author

nishantwrp commented May 20, 2020

Please do yarn install first

@DubeySandeep
Copy link
Member

DubeySandeep commented May 20, 2020

Please do yarn install first

It got fixed after running start.py, thanks for the info! :)

@DubeySandeep
Copy link
Member

DubeySandeep commented May 20, 2020

@nishantwrp, should we run yarn install command before running typescript checks? (To avoid such failures to happen while someone pushes new changes? OR can you please check whether we run this command while running pre_commit_linter?)

@nishantwrp
Copy link
Contributor Author

nishantwrp commented May 20, 2020

It runs on running pre push hooks.

@nishantwrp
Copy link
Contributor Author

nishantwrp commented May 21, 2020

@vojtechjelinek @DubeySandeep can it be merged now?

@vojtechjelinek vojtechjelinek merged commit 1d499bc into oppia:develop May 21, 2020
18 of 19 checks passed
@nishantwrp nishantwrp deleted the typescript-pre-push branch May 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add typescript checks to pre_push_hook
4 participants