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

[CI] Add cpplint as sanity check #1808

Closed
wants to merge 4 commits into from

Conversation

Squadrick
Copy link
Member

Make the required changes to ensure clean cpplint run.
Command:

$ cpplint --filter=-build/header_guard --recursive tensorflow_addons/custom_ops

Make required changes to ensure clean cpplint run.
Command:
$ cpplint --filter=-build/header_guard --recursive tensorflow_addons/custom_ops
@bhack
Copy link
Contributor

bhack commented May 10, 2020

Do we have a cpplint hook?

@bhack
Copy link
Contributor

bhack commented May 10, 2020

Probably we need a clang-format hook right?
https://www.tensorflow.org/community/contribute/code_style#style_di_codifica_c

@bhack
Copy link
Contributor

bhack commented May 11, 2020

We already have pre-commit and sanity check with clang-format so what happens here?

@bhack
Copy link
Contributor

bhack commented May 12, 2020

I see no special derived extra style rules in Tensorflow:
https://github.com/tensorflow/tensorflow/blob/master/tensorflow/.clang-format

So I think we could align with clang-format pass.

@Squadrick
Copy link
Member Author

@bhack This is not for formatting, it's using cpplint. The changes here are to make everything uniform and some accepted practices for C++ (explicit c'tor).

We might want to consider adding cpplint to our CI (cc @gabrieldemarmiesse @seanpmorgan)

@bhack
Copy link
Contributor

bhack commented May 16, 2020

Ok so It Is like in the perimeter of clang-tidy (for clang tools)

@bhack
Copy link
Contributor

bhack commented May 16, 2020

I've seen some comments in Tensorflow source code related to clang-tidy

Do you know if there Is a clang-tidy pass with a configuration in the Tensorflow CI?

@Squadrick
Copy link
Member Author

@bhack I don't think TensorFlow runs clang-tidy, at least I couldn't find anything in their "Ubuntu Sanity". There are two options for running C++ lining: cpplint, clang-tidy. cpplint is much each easier to install and run (pip), imo.

I used cpplint since it's a Google tool, but I can test with clang-tidy to maintain compatibility with TensorFlow.

@bhack
Copy link
Contributor

bhack commented May 16, 2020

Yes the scope was just to know how to create an uniform experience.
But other then that comments in the source code I found a public configuration only in MLIR but not in TF: https://github.com/llvm/llvm-project/blob/master/mlir/.clang-tidy

@gabrieldemarmiesse
Copy link
Member

I'm not a C++ dev, so I'll trust you @Squadrick if you want to add another tool for c++ in the CI. You can add an entry to the sanity checks dockerfile.

@bhack
Copy link
Contributor

bhack commented May 16, 2020

I am ok but I don't find also cpplint in their public Sanity check CI scripts. @angerson do you have any info about a clang-tidy or cpplint pass in Tensorflow CI?

@WindQAQ
Copy link
Member

WindQAQ commented May 18, 2020

Though we do not necessarily need to stick with the style of TF (like black), I personally prefer clang-tidy to cpplint.

@bhack
Copy link
Contributor

bhack commented May 18, 2020

E.g. on Chromium the config Is pubblic https://github.com/chromium/chromium/blob/master/.clang-tidy

@angerson
Copy link

Here's TensorFlow's style guide, which advocates clang-tidy: https://www.tensorflow.org/community/contribute/code_style?hl=en

@bhack
Copy link
Contributor

bhack commented May 19, 2020

@angerson If you see we already mentioned that public link in this ticket. But that Is related to clang-format not about static checks (clang-tidy Is only the package name to install there not the binary to run)

@angerson
Copy link

Either cpplint or clang-tidy's linter should be fine, then. Google exposes both for linting changesets, but IIRC TensorFlow's CI does not specifically enforce any linting.

@bhack
Copy link
Contributor

bhack commented May 20, 2020

As we have no formal pass in Tensorflow and we have already clang-tidy installed from the same package of clang-format in our CI we could do what we want. I am not sure but I Remember that if we will need clang-tidy can check a superset of cpplint but I need to double check this.

@gunan
Copy link

gunan commented May 29, 2020

When importing changes, we do run clang-tidy with the internal config on them.
Unfortunately, the configuration is not under our control, and thus running them in OSS has been a problem, because when we ran it before, it changed without notifications and broke us.

So, the first question I have is, is ensorflow/addons mirrored internally, now or sometime in the future(@karmel @theadactyl ). If yes, you may want to use clang-tidy instead.
Otherwise, if the code does not need to get inside google, you can apply any linter you like.

@bhack
Copy link
Contributor

bhack commented May 30, 2020

The ideal soultion would be to have a public clang-tidy conf like in Chromium to have an homogenus experience across SIGs and Tensorflow code for contributors but I don't know the internal policies why this could be public in Chromium and not for Tensorflow as boths proejcts have close soruce versions.

@gunan
Copy link

gunan commented Jun 5, 2020

Not exactly. Chromium uses a completely different scm than the rest of google.
Therefore, they are able to avoid running the google linters on their source code, and completely run open source versions.

@bhack
Copy link
Contributor

bhack commented Jun 5, 2020

@gunan Thanks for the little disclosure. I don't have a view on the internal Google repos so mine was just a reverse (engineering) guessing about how you are organized. I picked Chromium as an example cause at some point I thought it is going to integrate in the Chrome codebase and it could have a similar relationship like the opensource and closed source Tensorflow versions (and it is why I picked that specific example and e.g. not Clang tidy config in Goolge-cloud-cpp.
If we cannot know what Google it is doing internally I think that we could just expect that by an external point of view (the contributor) we don't need any enforcing pass and so we don't need to worry about the homogeneity of contributors coding experience across the Tensorflow ecosystem/SIGs.

@Squadrick Squadrick changed the title Cleanup: Run cpplint on custom_ops [CI] Add cpplint as sanity check Jun 16, 2020
@Squadrick
Copy link
Member Author

@gabrieldemarmiesse @seanpmorgan I've added cpplint to run a linter on custom_ops. I chose cpplint since it's easier to work with and install, and it comes with a Google style built-in.

Could you review this, please?

@bhack
Copy link
Contributor

bhack commented Jun 16, 2020

I think that we could separate cpplint introduction in the PR and the cpplint pass in another PR.
Also you need to add this in https://github.com/tensorflow/addons/blob/master/tools/docker/pre-commit.Dockerfile.

@bhack bhack mentioned this pull request Jun 16, 2020
@bhack
Copy link
Contributor

bhack commented Jun 16, 2020

I have an additional question. Is it still officially maintained by Google? See google/styleguide#528.

@bhack
Copy link
Contributor

bhack commented Jun 16, 2020

From https://pypi.org/project/cpplint/

While Google maintains cpplint, Google is not (very) responsive to issues and pull requests, this fork aims to be (somewhat) more open to add fixes to cpplint to enable fixes, when those fixes make cpplint usable in wider contexts. Also see discussion here google/styleguide#528.

@bhack bhack mentioned this pull request Jul 23, 2020
31 tasks
@qlzh727 qlzh727 removed their request for review June 24, 2021 23:55
@Squadrick Squadrick closed this Nov 5, 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.

7 participants