-
Notifications
You must be signed in to change notification settings - Fork 306
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
DAOS-16923 cq: make clang-format required #15685
base: master
Are you sure you want to change the base?
Conversation
Make clang-format GHA required on PRs. Skip-build: true Signed-off-by: Dalton Bohning <[email protected]>
Ticket title is 'Make clang-format required on PRs' |
@mchaarawi Per request, it's this simple to make clang-format required. Should we alert devs before merging this? |
Note that since this is version controlled, inflight PRs will not be affected until this change is merged into their branch |
Skip-build: true Signed-off-by: Dalton Bohning <[email protected]>
Since it may conflict with system. Skip-build: true Signed-off-by: Dalton Bohning <[email protected]>
Skip-build: true Signed-off-by: Dalton Bohning <[email protected]>
I think you're going to get some pushback internally on this one. I'm personally ok with it. |
If it's required, does it mean a PR has to be force landed. You might want to add or point to documentation for the comments to disable it (such as for FOREACH macros) when it does weird things. |
Right. It either needs to pass or needs force landing.
I don't work with C code enough to know - do you have an example of this? Or do you mean disable the hook with DAOS_GITHOOK_SKIP? (which would then require force landing) |
Skip-build: true Signed-off-by: Dalton Bohning <[email protected]>
utils/githooks/README.md
Outdated
## Install DAOS Git Hooks | ||
Installing is a two-step process: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
## Install DAOS Git Hooks
Installing is a two-step process:
An empty line after ## ...
is required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Required? this seems to render correctly. I'll update though
utils/githooks/README.md
Outdated
change with it. | ||
|
||
2. Install all of the required tools | ||
### 2. Install the required tools |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
### 2. Install the tools
Some of them are optional as mentioned below.
utils/githooks/README.md
Outdated
``` | ||
To install system packages with your package manager - for example: | ||
```sh | ||
dnf install git-clang-format |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sudo dnf install git-clang-format -y
utils/githooks/README.md
Outdated
```sh | ||
dnf install git-clang-format | ||
``` | ||
### Installed tools |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#### Recommended tools
Is it a subsection of Install the~~ required~~ tools?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was not, but makes sense. Thanks
utils/githooks/README.md
Outdated
It is important to check the output on commit for any errors that may indicate | ||
any one of the required tools is missing. | ||
|
||
1. copyright - Custom tool that automatically updates copyrights in modified files. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The script's name is update-copyright
.
and
why some of names are within '`'?
All names refer to *.sh
scripts in utils\githooks\pre-commit.d
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed '`' and made names match script names
@@ -13,11 +14,11 @@ if [ -e .git/MERGE_HEAD ]; then | |||
fi | |||
|
|||
if ! command -v git-clang-format > /dev/null 2>&1; then | |||
echo "git-clang-format not installed. Skipping" | |||
echo "git-clang-format not installed. See ./utils/githooks/README.md for instructions" | |||
exit 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exit 1
Shall we also make git-clang-format
not optional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No objection from me. But TBH I don't write enough C code to know whether that will bother people
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we enable this in CI we should also enable it in githooks.
Otherwise build fails and user will have to make another commit to fix that issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do agree with you. But in the past people have not liked when a githook prevents them from committing. Hopefully with updated documentation and it being required in the GHA, people will accept it 😛
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we get acceptance here we can also modify all other pre-commit scripts later to force everybody with pre-validation for every changes that are later verified by CI ;).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in the past people have not liked when a githook prevents them from committing
Funny thing clang changes over time and differs from distro to distro. So, you may even have clang-format pre-hook enabled and still be stopped by a check on GitHub. Just because of the different versions I believe.
Here --no-verify
toggle becomes very useful. Just turn it off when it is in your way. ;-)
exit 0 | ||
fi | ||
if ! command -v clang-format > /dev/null 2>&1; then | ||
echo "clang-format not installed. Skipping" | ||
echo "clang-format not installed. See ./utils/githooks/README.md for instructions" | ||
exit 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exit 1
Shall we also make git-clang-format
not optional?
exit 0 | ||
fi | ||
if ! command -v clang-format > /dev/null 2>&1; then | ||
echo "clang-format not installed. Skipping" | ||
echo "clang-format not installed. See ./utils/githooks/README.md for instructions" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
./utils/githooks/README.md#2-install-the-required-tools
Let's try to use link to particular section - helps a lot.
utils/githooks/README.md
Outdated
|
||
It is important to check the output on commit for any errors that may indicate | ||
any one of the required tools is missing. | ||
### Optional tools |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#### Optional tools
Is it a subsection of Install the~~ required~~ tools?
clang-format has made unwanted (human-unreadable) changes to RPC definition macros. Pretty bad. And in those cases we've had to repair this after the fact in subsequent commits by using C comments containing "clang-format off" and "clang-format on" to mark the region of the source code that clang-format should not modify. Example region with the control comments: Line 103 in fe389f9
Line 132 in fe389f9
|
Skip-build: true Signed-off-by: Dalton Bohning <[email protected]>
Skip-build: true Signed-off-by: Dalton Bohning <[email protected]>
Skip-build: true Signed-off-by: Dalton Bohning <[email protected]>
exit 0 | ||
echo "git-clang-format not installed." | ||
echo "See ./utils/githooks/README.md#2-install-the-required-tools for instructions." | ||
exit 1 | ||
fi | ||
if ! command -v clang-format > /dev/null 2>&1; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ! command -v clang-format > /dev/null 2>&1; then
I think we can remove this check as:
- there is a strict dependency between
git-clang-format
pkg andclang-tools-extra
(clang-format
) pkg. Every time - the presence of clang-format is checked by
extra.py
script few lines later
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I admit I don't know much about this tool
Skip-build: true Signed-off-by: Dalton Bohning <[email protected]>
Make clang-format GHA required on PRs.
Skip-build: true
Before requesting gatekeeper:
Features:
(orTest-tag*
) commit pragma was used or there is a reason documented that there are no appropriate tags for this PR.Gatekeeper: