Skip to content

Conversation

@driazati
Copy link
Contributor

@driazati driazati commented Jun 15, 2021

Stack from ghstack:

This changes clang-tidy in lint.yml to pull the raw diff from GitHub and parse that rather than use the PRs base revision. The way we diff with the base revision can cause the spurious inclusion of files not changed in the PR as in https://github.com/pytorch/pytorch/pull/59967/checks?check_run_id=2832565901. We could be smarter about how we query git, but this approach ends up being simpler since we just need to search for the diff headers in the .diff file.

See https://github.com/pytorch/pytorch/pull/60049/checks?check_run_id=2834254915 for an example CI run with this on (the failure is expected, the relevant part there is the fact that the line filter still works fine)

Differential Revision: D29148886

This changes clang-tidy in lint.yml to pull the raw diff from GitHub and parse that rather than use the PRs base revision. The base revision can cause the spurious inclusion of files not changed in the PR as in https://github.com/pytorch/pytorch/pull/59967/checks?check_run_id=2832565901. We could be smarter about how we query git, but this approach ends up being simpler since we just need to search for the diff headers in the .diff file.

[ghstack-poisoned]
@facebook-github-bot
Copy link
Contributor

facebook-github-bot commented Jun 15, 2021

💊 CI failures summary and remediations

As of commit d201f9d (more details on the Dr. CI page):


💚 💚 Looks good so far! There are no failures yet. 💚 💚


This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.

Please report bugs/suggestions to the (internal) Dr. CI Users group.

Click here to manually regenerate this comment.

driazati added 2 commits June 15, 2021 15:45
This changes clang-tidy in lint.yml to pull the raw diff from GitHub and parse that rather than use the PRs base revision. The base revision can cause the spurious inclusion of files not changed in the PR as in https://github.com/pytorch/pytorch/pull/59967/checks?check_run_id=2832565901. We could be smarter about how we query git, but this approach ends up being simpler since we just need to search for the diff headers in the .diff file.

See https://github.com/pytorch/pytorch/pull/60049/checks?check_run_id=2834140350 for an example CI run with this on

[ghstack-poisoned]
This changes clang-tidy in lint.yml to pull the raw diff from GitHub and parse that rather than use the PRs base revision. The base revision can cause the spurious inclusion of files not changed in the PR as in https://github.com/pytorch/pytorch/pull/59967/checks?check_run_id=2832565901. We could be smarter about how we query git, but this approach ends up being simpler since we just need to search for the diff headers in the .diff file.

See https://github.com/pytorch/pytorch/pull/60049/checks?check_run_id=2834140350 for an example CI run with this on

[ghstack-poisoned]
@driazati
Copy link
Contributor Author

@driazati has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@driazati driazati requested a review from a team June 15, 2021 23:00
This changes clang-tidy in lint.yml to pull the raw diff from GitHub and parse that rather than use the PRs base revision. The way we diff with the base revision can cause the spurious inclusion of files not changed in the PR as in https://github.com/pytorch/pytorch/pull/59967/checks?check_run_id=2832565901. We could be smarter about how we query git, but this approach ends up being simpler since we just need to search for the diff headers in the .diff file.

See https://github.com/pytorch/pytorch/pull/60049/checks?check_run_id=2834254915 for an example CI run with this on (the failure is expected, the relevant part there is the fact that the line filter still works fine)

Differential Revision: [D29148886](https://our.internmc.facebook.com/intern/diff/D29148886)

[ghstack-poisoned]
@samestep
Copy link
Contributor

Maybe I'm misunderstanding, but I thought that @malfet a few weeks ago made this repo clang-tidy clean? In that case, can't we just get rid of all the fancy logic in tools/clang_tidy.py, and just run it on the repo like we do with Flake8 and mypy?

@driazati
Copy link
Contributor Author

for one it can be slow (no actual numbers on this though), but secondly since we never enabled clang-tidy on master the cleanliness has regressed in the meantime. We’ll need to do another batch of NOLINTNEXTLINEs to make it clean again + enable it on master

Copy link
Contributor

@samestep samestep left a comment

Choose a reason for hiding this comment

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

oh I see; so the reason you have to change the diff parsing code is because GitHub doesn't let you tell it to give 0 context lines around each hunk, like Git does?

@driazati
Copy link
Contributor Author

oh I see; so the reason you have to change the diff parsing code is because GitHub doesn't let you tell it to give 0 context lines around each hunk, like Git does?

Yup it's the same thing you can see here https://github.com/pytorch/pytorch/pull/60048.diff which is basically the git diff of the PR.

@driazati
Copy link
Contributor Author

@driazati has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link
Member

@seemethere seemethere left a comment

Choose a reason for hiding this comment

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

Maybe we can also use this approach of grabbing the PR diff to resolve issues found in #60111

@seemethere
Copy link
Member

Does this mean that there'll be no enablement of the clang-tidy job on master since it now relies on PR_NUMBER?

@samestep
Copy link
Contributor

Does this mean that there'll be no enablement of the clang-tidy job on master since it now relies on PR_NUMBER?

clang-tidy is already disabled on master

@driazati
Copy link
Contributor Author

Does this mean that there'll be no enablement of the clang-tidy job on master since it now relies on PR_NUMBER?

It's skipped currently, we're planning to add that soon once we make the codebase clang-tidy clean again (on master it will just lint everything so we'll have to add some special casing to remove the --diff-file flag when PR_NUMBER isn't present)

@facebook-github-bot
Copy link
Contributor

@driazati merged this pull request in 9d77646.

facebook-github-bot pushed a commit that referenced this pull request Jun 18, 2021
Summary:
PR #60048 neglected to include the `--paths` option for file filtering, so it ended up passing every changed file in the diff to clang-tidy (cpp files outside `torch/csrc/`, yaml/sh files, etc.). This adds that back in to make the filtering work properly again.

Tested it manually by printing out the files to lint and running

```bash
curl -L https://github.com/pytorch/pytorch/pull/60018.diff > diff
python tools/clang_tidy.py --diff-file diff --paths torch/csrc/

curl -L https://github.com/pytorch/pytorch/pull/60222.diff > diff
python tools/clang_tidy.py --diff-file diff --paths torch/csrc/
```

Should fix #60192 and fix #60193, the files tripping errors there shouldn't have been passed to clang-tidy in the first place (supporting aten/ for clang-tidy is a separate task)

Pull Request resolved: #60225

Reviewed By: zhouzhuojie

Differential Revision: D29216251

Pulled By: driazati

fbshipit-source-id: b5d7fb7161d33eb7958a6f1ccc25809942045209
@facebook-github-bot facebook-github-bot deleted the gh/driazati/43/head branch June 20, 2021 14:16
jjsjann123 pushed a commit to csarofeen/pytorch that referenced this pull request Jun 23, 2021
Summary:
PR pytorch#60048 neglected to include the `--paths` option for file filtering, so it ended up passing every changed file in the diff to clang-tidy (cpp files outside `torch/csrc/`, yaml/sh files, etc.). This adds that back in to make the filtering work properly again.

Tested it manually by printing out the files to lint and running

```bash
curl -L https://github.com/pytorch/pytorch/pull/60018.diff > diff
python tools/clang_tidy.py --diff-file diff --paths torch/csrc/

curl -L https://github.com/pytorch/pytorch/pull/60222.diff > diff
python tools/clang_tidy.py --diff-file diff --paths torch/csrc/
```

Should fix pytorch#60192 and fix pytorch#60193, the files tripping errors there shouldn't have been passed to clang-tidy in the first place (supporting aten/ for clang-tidy is a separate task)

Pull Request resolved: pytorch#60225

Reviewed By: zhouzhuojie

Differential Revision: D29216251

Pulled By: driazati

fbshipit-source-id: b5d7fb7161d33eb7958a6f1ccc25809942045209
jjsjann123 added a commit to csarofeen/pytorch that referenced this pull request Jun 23, 2021
* Fix default DEFAULT_FILE_PATTERN in clang-tidy (pytorch#60212)

Summary:
Without the change, clang-tidy also checks folders like `.circleci/...`

Example of the clang-tidy that looked into `.circleci` changes
https://github.com/pytorch/pytorch/runs/2844682644?check_suite_focus=true

[skip ci]

Pull Request resolved: pytorch#60212

Reviewed By: seemethere

Differential Revision: D29214728

Pulled By: zhouzhuojie

fbshipit-source-id: fd53f7b2f7d88936264db1effdc06cc4fc271ca4

* Fix clang-tidy path filtering (pytorch#60225)

Summary:
PR pytorch#60048 neglected to include the `--paths` option for file filtering, so it ended up passing every changed file in the diff to clang-tidy (cpp files outside `torch/csrc/`, yaml/sh files, etc.). This adds that back in to make the filtering work properly again.

Tested it manually by printing out the files to lint and running

```bash
curl -L https://github.com/pytorch/pytorch/pull/60018.diff > diff
python tools/clang_tidy.py --diff-file diff --paths torch/csrc/

curl -L https://github.com/pytorch/pytorch/pull/60222.diff > diff
python tools/clang_tidy.py --diff-file diff --paths torch/csrc/
```

Should fix pytorch#60192 and fix pytorch#60193, the files tripping errors there shouldn't have been passed to clang-tidy in the first place (supporting aten/ for clang-tidy is a separate task)

Pull Request resolved: pytorch#60225

Reviewed By: zhouzhuojie

Differential Revision: D29216251

Pulled By: driazati

fbshipit-source-id: b5d7fb7161d33eb7958a6f1ccc25809942045209

* Re-enable clang-tidy on PRs (pytorch#60297)

Summary:
Pull Request resolved: pytorch#60297

This switches clang-tidy to the fresh tag from https://github.com/pytorch/test-infra/runs/2860763986 which has a fix for the missing OMP headers we were seeing. Along with pytorch#60225 this should restore clang-tidy to normal functionality and we shouldn't see any spurious warnings.

Test Plan: Imported from OSS

Reviewed By: seemethere, 1ntEgr8

Differential Revision: D29239783

Pulled By: driazati

fbshipit-source-id: b1893256fdb27436af03d6c5279e81f64b47fe6b

Co-authored-by: Zhuojie Zhou <[email protected]>
Co-authored-by: driazati <[email protected]>
@driazati driazati mentioned this pull request Jul 1, 2021
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.

4 participants