8000 ENH: Lint checks for PR diffs by ganesh-k13 · Pull Request #18423 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

ENH: Lint checks for PR diffs #18423

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

Merged
merged 9 commits into from
Mar 7, 2021
Merged

ENH: Lint checks for PR diffs #18423

merged 9 commits into from
Mar 7, 2021

Conversation

ganesh-k13
Copy link
Member
@ganesh-k13 ganesh-k13 commented Feb 16, 2021

Lint checks for PR diffs

This PR aims to integrate the linting checks on diffs to the CI pipeline.

Changes

  1. Add linter.py, heavily based on scipy linter
  2. Integrated with Azure Pipelines
  3. Integrated with GitHub actions.
  4. Added options to run with runtest.py

Usage:

Just script:

python tools/linter.py --branch main # Checks on LCA commit with main
python tools/linter.py --uncommitted # Checks only uncommitted changes

With runtest:

python runtests.py --lint main
python runtests.py --lint uncommitted

Other todo items

  • Integrate with other pipelines if changes are fine

Based on scipy/scipy#11423

cc: @rgommers @seberg

@ganesh-k13
Copy link
Member Author

@mattip
Copy link
Member
mattip commented Feb 16, 2021

Is there a reason to prefer github actions over azure pipelines for this? I find the summary presentation on github actions a little nicer and it is more tightly integrated with github.

@ganesh-k13
Copy link
Member Author
ganesh-k13 commented Feb 16, 2021

It was a very random choice from my side Matti :). Yeah, I'll see GitHub actions, looks cleaner 👍 .
[EDIT] Scipy used Travis if I'm not wrong

@rgommers
Copy link
Member

+1 Azure is really annoying, it takes a lot of clicking to get from the "Details" link in the PR view to the actual logs.

@charris
Copy link
Member
charris commented Feb 16, 2021

it takes a lot of clicking to get from the "Details" link in the PR view to the actual logs.

My experience is the opposite, scrolling down the log to find the actual error is a lengthy process in GitHub actions. Azure does a nice job organizing the results. I'm hoping GitHub improves things going forward.

@mattip
Copy link
Member
mattip commented Feb 16, 2021

scrolling down the log to find the actual error is a lengthy process in GitHub actions

This might be because I used a single composite sub-action .github/workflow/action/action.yml that incorporates the older travis steps rather than separate setup/build/test steps. There is a request to have a way to separate larger actions in the UI.

@ganesh-k13
Copy link
Member Author

I've added Github actions as well(in the process, will fix errors), we can choose one and discard other

@@ -32,6 +32,21 @@ jobs:
python-version: ${{ env.PYTHON_VERSION }}
- uses: ./.github/actions

lint:
needs: smoke_test
Copy link
Member Author

Choose a reason for hiding this comment

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

I think we can run lint irrespective of smoke_test?

Copy link
Member

Choose a reason for hiding this comment

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

Well, do we want a lint failure to fail the whole build or just provide one more data point about the PR? On PyTorch they choose to end the CI early since anyway the submitter will have to fix the PR, so the whole CI will have to run again. That perspective would make me think it should run first, and everything else be conditional on it. On the otherhand, the CI might fail for other reasons so the linter is just icing on the cake, in which case it should not fail the whole CI run. I think I have a slight preference for the former: make it the reverse of this:

smoke_test:
  needs: lint

What do others think?

Copy link
Member

Choose a reason for hiding this comment

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

To have an opinion, how about we run both and only continue if both succeed? That way, if you look at the PR you know whether there are clearly issues beyond style. And the smoke-test run doesn't take a huge amount of resources for NumPy.
The argument of rerunning CI is good though, even if it might be mildly annoying sometimes to get blocked by.

Copy link
Member Author

Choose a reason for hiding this comment

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

I added lint and smoke as mandatory, making the summary look like this.

Copy link
Member Author

Choose a reason for hiding this comment

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

What would be nice is to group jobs and call it say preflight, and add preflight as needs instead of adding lint+smoke every time.

Copy link
Member

Choose a reason for hiding this comment

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

I like this. I don't have an opinion on actions vs. azure, but either version seems like a good addition in any case.

Copy link
Member

Choose a reason for hiding this comment

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

I like the idea of running it on both Azure and GH Actions, as the PR does now.

The preflight thing is a nice cleanup, but it's not essential and can be done separately.

@ganesh-k13 ganesh-k13 force-pushed the enh_lint branch 2 times, most recently from 9f5871a to 898ee74 Compare February 18, 2021 17:17
Copy link
Member
@mattip mattip left a comment

Choose a reason for hiding this comment

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

Looking good, thanks. I have a few styling suggestions. I understand the if clause for the skips on github actions is a copy-paste, but I seem to recall it does not work. I guess we can leave that for #18343

@ganesh-k13 ganesh-k13 force-pushed the enh_lint branch 4 times, most recently from a2df2d5 to 5eb7c8e Compare February 21, 2021 06:10
@ganesh-k13
Copy link
Member Author

Sorry for bombarding with force pushes, not able to check errors in my fork.

@ganesh-k13
Copy link
Member Author

Shall I add this check as an option in runtest? Users can use that instead of directly running this script.

@rgommers
Copy link
Member

Shall I add this check as an option in runtest? Users can use that instead of directly running this script.

That sounds like a good idea to me.

@ganesh-k13
Copy link
Member Author
ganesh-k13 commented Feb 22, 2021

Forgot to add --unified=0 for branch check, irony I guess :). At least it's catching some errors :)

@ganesh-k13 ganesh-k13 force-pushed the enh_lint branch 2 times, most recently from ee21636 to fb43f15 Compare February 22, 2021 16:16
Base automatically changed from master to main March 4, 2021 02:05
@rgommers
Copy link
Member
rgommers commented Mar 6, 2021

This accumulated a merge conflict now, would you mind rebasing @ganesh-k13? Do you think it's good to merge?

@ganesh-k13
Copy link
Member Author

I have fixed it Ralf. I hope the merge-base logic is fine, other than that I think we are good to ship it.

@ganesh-k13
Copy link
Member Author
ganesh-k13 commented Mar 7, 2021

Sorry for the strange commit meta data, on a different PC :( , will fix by tonight when I get back.
[EDIT] it got fixed :) . This is nice, -x in git

Copy link
Member
@rgommers rgommers left a comment

Choose a reason for hiding this comment

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

LGTM. Tested locally, and all works as expected. In it goes. Thanks @ganesh-k13! And thanks everyone else for reviews.

@rgommers rgommers merged commit b88ab10 into numpy:main Mar 7, 2021
@rgommers
Copy link
Member
rgommers commented Mar 7, 2021

Testing in gh-18566, and I think fixing a leftover master

@ganesh-k13
Copy link
Member Author
ganesh-k13 commented Mar 7, 2021

I also think we have to handle this error: https://github.com/numpy/numpy/runs/2051142496#step:5:1.

This happens due to

python tools/linter.py --branch origin/${{ github.base_ref }}

this line where: ${{ github.base_ref }} is empty

[EDIT] same is true for Azure: https://dev.azure.com/numpy/numpy/_build/results?buildId=16027&view=logs&j=a2bdd735-2cd0-5874-344f-2950fb45c949&t=43bcde9c-2634-50fc-b6ce-b6802de90ad4&l=11

@rgommers
Copy link
Member
rgommers commented Mar 7, 2021

Ah yes, the CI changes in this PR work for other PRs, but not for merge commits on master.

@ganesh-k13
Copy link
Member Author

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.

5 participants
0