-
Notifications
You must be signed in to change notification settings - Fork 92
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
adding clang-tidy as a linter tool #2269
Open
Suyashd999
wants to merge
9
commits into
ceph:main
Choose a base branch
from
Suyashd999:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
1d93369
adding clang-tidy as linter tool
Suyashd999 f724d88
Added build steps
Suyashd999 efeb4fa
added the script clang-tidy-to-junit for report generation
Suyashd999 31aead3
refactored clang-tidy-to-junit.py execution
Suyashd999 600c035
refactored status-context
Suyashd999 9935304
renamed LICENSE and added node configuration
Suyashd999 5e54b91
added node configuration
Suyashd999 d64fdaa
configured to work with `copy_artifacts` plugin
Suyashd999 498e2a3
updated to run clang-tidy on all files
Suyashd999 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/bash | ||
set -ex | ||
|
||
docs_pr_only | ||
if [ "$DOCS_ONLY" = true ]; then | ||
echo "Only the doc/ dir changed. No need to run make check or API tests." | ||
mkdir -p $WORKSPACE/build/out | ||
echo "File created to avoid Jenkins' Artifact Archiving plugin from hanging" > $WORKSPACE/build/out/mgr.foo.log | ||
exit 0 | ||
fi | ||
|
||
sudo apt-get install -y clang-tidy | ||
|
||
sudo apt-get install -y parallel | ||
|
||
build_debs ${VENV} ${vers} ${debian_version} | ||
|
||
output_file="clang-tidy-result" | ||
file_list="files_to_check.txt" | ||
|
||
# Store the list of files from both rgw and osd directories | ||
find "$WORKSPACE/src/rgw" \( -name '*.cpp' -o -name '*.hpp' -o -name '*.cc' \) > "$file_list" | ||
find "$WORKSPACE/src/osd" \( -name '*.cpp' -o -name '*.hpp' -o -name '*.cc' \) >> "$file_list" | ||
|
||
# Run clang-tidy and save output | ||
{ | ||
echo "Files being checked:" | ||
cat "$file_list" | ||
echo | ||
parallel -m clang-tidy -checks="-*,bugprone-use-after-move" -p "$WORKSPACE/build" {} < "$file_list" | ||
} | tee "$WORKSPACE/build/$output_file" | ||
|
||
sudo chmod +x ../src/script/clang-tidy-to-junit.py | ||
|
||
cat "$WORKSPACE/build/$output_file" | ../src/script/clang-tidy-to-junit.py $WORKSPACE/src >"$WORKSPACE/report.xml" | ||
Suyashd999 marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
- job: | ||
name: ceph-pr-clang-tidy | ||
node: small | ||
project-type: freestyle | ||
defaults: global | ||
display-name: 'ceph: Clang-tidy checks' | ||
concurrent: true | ||
quiet-period: 5 | ||
block-downstream: false | ||
block-upstream: false | ||
retry-count: 3 | ||
properties: | ||
- build-discarder: | ||
days-to-keep: 15 | ||
artifact-days-to-keep: 15 | ||
- github: | ||
url: https://github.com/ceph/ceph/ | ||
|
||
scm: | ||
- git: | ||
url: https://github.com/ceph/ceph.git | ||
name: origin | ||
branches: | ||
- origin/pr/${ghprbPullId}/merge | ||
refspec: +refs/pull/${ghprbPullId}/*:refs/remotes/origin/pr/${ghprbPullId}/* | ||
skip-tag: true | ||
shallow-clone: true | ||
honor-refspec: true | ||
timeout: 20 | ||
|
||
triggers: | ||
- github-pull-request: | ||
allow-whitelist-orgs-as-admins: true | ||
org-list: | ||
- ceph | ||
trigger-phrase: 'jenkins test clang-tidy' | ||
only-trigger-phrase: false | ||
github-hooks: true | ||
permit-all: true | ||
auto-close-on-fail: false | ||
status-context: "Signed-off-by" | ||
started-status: "checking if bugs exist in file" | ||
success-status: "no bugs found" | ||
failure-status: "bugs found" | ||
|
||
builders: | ||
- shell: | ||
!include-raw: | ||
- ../../../scripts/build_utils.sh | ||
- ../../build/build | ||
|
||
publishers: | ||
- junit: | ||
results: report.xml | ||
allow-empty-results: true |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back 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.
of course this only works if the build machine is an apt-based system, which it may not be using your current node labels. It might be more appropriate to install the package inside the pbuilder image in that case, too, although it probably doesn't matter too much; there are ways of adding extra packages to the pbuilder image
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.
We still need an answer for this; does clang-tidy exist for RHEL-like systems? or do we want to restrict this job to only apt systems?
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 is available but for now lets keep the job to apt systems only
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.
How is this accomplished? won't the command be executed (and fail) on all systems?
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 job specifies the labels for the jenkins builder it wants; we'll need to add something like 'jammy' as a label, that should suffice
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.
Where should I add this 'jammy' label?
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.
job.node is the list of labels the builder must satisfy. You probably want jammy && small
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.
@dmick I have added
node: jammy && small