Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

[Feature][Master] Clang-format tool to perform additional formatting and semantic checking of code. #20433

Merged

Conversation

mozga-intel
Copy link
Contributor

Description

There is used clang-format tool to perform additional formatting and semantic checking of code. This pull request contains a pre-commit git hook, a git-pre-commit file, (Related to: #20406, #20356 #20429)

Since clang-format needs to be installed with an appropriate configuration, the file with the requirements has to be run:
After that, we need to set up a symbolic link to a given file: To create a symbolic link to a given file, open your terminal and type:

ln -s ../../tools/git-pre-commit .git/hooks/pre-commit

If you have not set up the pre-commit hooks, you can run it locally in your local branch.

Checklist

Essentials

  • PR's title starts with a category (e.g. [BUGFIX], [MODEL], [TUTORIAL], [FEATURE], [DOC], etc)
  • Changes are complete (i.e. I finished coding on this PR)
  • All changes have test coverage
  • Code is well-documented

Changes

  • Feature1, tests, (and when applicable, API doc)
  • Feature2, tests, (and when applicable, API doc)

Comments

  • If this change is a backward incompatible change, why must this change be made.
  • Interesting edge cases to note here

@mozga-intel mozga-intel requested a review from szha as a code owner July 9, 2021 16:00
@mxnet-bot
Copy link

Hey @mozga-intel , Thanks for submitting the PR
All tests are already queued to run once. If tests fail, you can trigger one or more tests again with the following commands:

  • To trigger all jobs: @mxnet-bot run ci [all]
  • To trigger specific jobs: @mxnet-bot run ci [job1, job2]

CI supported jobs: [windows-cpu, windows-gpu, miscellaneous, centos-cpu, sanity, unix-cpu, edge, centos-gpu, unix-gpu, website, clang]


Note:
Only following 3 categories can trigger CI :PR Author, MXNet Committer, Jenkins Admin.
All CI tests must pass before the PR can be merged.

@mseth10 mseth10 added pr-awaiting-testing PR is reviewed and waiting CI build and test pr-work-in-progress PR is still work in progress and removed pr-awaiting-testing PR is reviewed and waiting CI build and test labels Jul 9, 2021
@leezu
Copy link
Contributor

leezu commented Jul 9, 2021

Would you like to add a CI step (Jenkins or Github Actions) to enforce the style is met?

@mozga-intel
Copy link
Contributor Author

mozga-intel commented Jul 16, 2021

@leezu @szha How about preparing a separate and specific-designed CI' job - we can call it lint_clang for instance? It could be a CI' job with a single responsibility, responsible only for checking and keeping a code well-formatted. Inside, all checkers can be run: a clang-format and clang-tidy script for c++, a falke8 checker for python and so on. It could be a fundamental basic property. A bash script with a single configuration - run this, this and this (either one script to run all checkers, or a few scripts to run one-dedicated) However, a common theme running through this idea is a fundamental relationship that those things need to be placed in the same job.

I have one open questions to discuss:

  • How the differences should be shown? - Either report it directly by showing that something went wrong or maybe it could be better to do it automatically behind a curtain. [Personally, I prefer to report any mistakes]

@szha
Copy link
Member

szha commented Jul 16, 2021

@mozga-intel we have lint in sanity check and I think this can be put in sanity check too. Sanity check is required to pass before other pipelines kick in.

@mozga-intel mozga-intel requested a review from leezu as a code owner July 21, 2021 12:59
@mozga-intel mozga-intel force-pushed the mozga-intel/auto_clang_format_checker_hook branch from da61dd4 to 6889cb8 Compare July 21, 2021 13:12
@mozga-intel
Copy link
Contributor Author

mozga-intel commented Jul 21, 2021

@szha @leezu How about adding a workflow like this: please have a look at: Clang format lint / clang-format (pull_request) in this PR. The clang-format checks the latest master with the current branch. If something goes wrong, then you get an error message. If clang-format finds an error, then we can add a special description on a wiki of how to run clang_format locally.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| clang-format failures found! Run: 
|    tool/lint/clang_format_ci.sh 3480ba2c6df02bb907d3a975d354efa8697c4e71 
| to fix this error. 
| **For more info, see: ___LINK__TO_WIKI__
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
  • LINK_TO_WIKI there is a place to put a link.
  • How the differences should be shown? - Either report it directly by showing that something went wrong or maybe it could be better to do it automatically behind a curtain. [Personally, I prefer to report any mistakes]

If something goes wrong, then you get an error: please have a look at the example: Link.

@szha
Copy link
Member

szha commented Jul 25, 2021

@mxnet-bot run ci [sanity]

1 similar comment
@szha
Copy link
Member

szha commented Jul 26, 2021

@mxnet-bot run ci [sanity]

@mxnet-bot
Copy link

Jenkins CI successfully triggered : [sanity]

@mseth10 mseth10 added pr-awaiting-testing PR is reviewed and waiting CI build and test pr-work-in-progress PR is still work in progress and removed pr-work-in-progress PR is still work in progress pr-awaiting-testing PR is reviewed and waiting CI build and test labels Jul 26, 2021
@szha
Copy link
Member

szha commented Jul 26, 2021

/work/runtime_functions.sh: line 722: ${{ github.event.pull_request.base.sha }}: bad substitution

@szha
Copy link
Member

szha commented Jul 26, 2021

Note that there's also a license header missing in the new file.

@mseth10 mseth10 added pr-work-in-progress PR is still work in progress and removed pr-awaiting-testing PR is reviewed and waiting CI build and test labels Sep 15, 2021
@mozga-intel
Copy link
Contributor Author

@mxnet-bot run ci [centos-gpu]

@mxnet-bot
Copy link

Jenkins CI successfully triggered : [centos-gpu]

@mseth10 mseth10 added pr-awaiting-testing PR is reviewed and waiting CI build and test pr-work-in-progress PR is still work in progress and removed pr-work-in-progress PR is still work in progress pr-awaiting-testing PR is reviewed and waiting CI build and test labels Sep 17, 2021
@mozga-intel
Copy link
Contributor Author

@mxnet-bot run ci [centos-gpu]

@mxnet-bot
Copy link

Jenkins CI successfully triggered : [centos-gpu]

@mseth10 mseth10 added pr-awaiting-testing PR is reviewed and waiting CI build and test pr-work-in-progress PR is still work in progress and removed pr-work-in-progress PR is still work in progress pr-awaiting-testing PR is reviewed and waiting CI build and test labels Sep 17, 2021
@mozga-intel
Copy link
Contributor Author

@mxnet-bot run ci [centos-gpu]

@mxnet-bot
Copy link

Jenkins CI successfully triggered : [centos-gpu]

@mseth10 mseth10 added pr-awaiting-testing PR is reviewed and waiting CI build and test pr-awaiting-review PR is waiting for code review and removed pr-work-in-progress PR is still work in progress pr-awaiting-testing PR is reviewed and waiting CI build and test labels Sep 17, 2021
@mozga-intel
Copy link
Contributor Author

@szha @leezu @akarbown Could you please review it?

@szha
Copy link
Member

szha commented Oct 7, 2021

LGTM

@leezu
Copy link
Contributor

leezu commented Oct 8, 2021

@mxnet-bot run ci [sanity]

@mxnet-bot
Copy link

Jenkins CI successfully triggered : [sanity]

@mseth10 mseth10 added pr-awaiting-testing PR is reviewed and waiting CI build and test pr-awaiting-review PR is waiting for code review and removed pr-awaiting-review PR is waiting for code review pr-awaiting-testing PR is reviewed and waiting CI build and test labels Oct 8, 2021
@szha szha merged commit 4b73646 into apache:master Oct 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
pr-awaiting-review PR is waiting for code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants