-
Notifications
You must be signed in to change notification settings - Fork 60
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
quality-of-life fixes: clang-format, clang-static-analyzer, pre-commit #351
Conversation
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.
High-level comment: While the rules files additions are good, I don't think we should have commits that fix everything in one shot. We can adopt the format rules for subsequent changes and incrementally change parts of code as we touch them, but a blanket fix makes diving into history harder than just git blaming and tracking down changes from there.
I tried to alleviate some of this pain with .git-blame-ignore-revs, are you saying that you feel it's still too noisy with that configured? Here's blame on ofi_nccl_net.c, for example. AFAICT, the only case where those listed commits still appear in git blame is where it added lines, eg: with the include reordering, line wrapping, or brace insertion. I agree that it's still more lines than I would like to see. |
I don't like whitespace refactoring commits. They break git blame. I'm happy to have filters to make sure we don't screw up whitespace again, but no silly whitespace fixup commits, please. |
.git-blame-ignore-revs
Outdated
@@ -0,0 +1,8 @@ | |||
# style(tree): apply mdformat fixes | |||
99e3f12c2b09d23369262e4a17912cacab17ee1f |
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.
nah; we just shouldn't do these commits.
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.
ack, fine with this.
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 want to reraise this -- this is a good feature that can help us make changes without clobbering history. I've dropped the application of clang-format on this PR, but I didn't drop all of linters/fixers and some of those are better ignored. Note that github supports this file and blame should work correctly if you go to the top of this page and click the branch, or this link: https://github.com/aws-nslick/aws-ofi-nccl/tree/qol
485972d
to
6fd60de
Compare
configure.ac
Outdated
@@ -29,6 +30,7 @@ NCCL_NET_OFI_DISTCHCK_CONFIGURE_FLAGS= | |||
# Checks for programs | |||
AC_PROG_CC | |||
m4_version_prereq([2.70], [], [AC_PROG_CC_STDC]) | |||
AC_GNU_SOURCE |
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'm not actually sure why we need GNU_SOURCE defined, but I definitely don't want to make it the default.
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 definitely need it for asprintf, potentially others.
I agree that we should avoid gnu extensions, but so long as they're already in the codebase, I feel it's more reasonable to commit to compiling with a consistent set of feature macros until we can get back to _POSIX_C_SOURCE >= 200809L
compatibility.
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 feel strongly that this change is prudent because of potential ABI breakage when files are compiled with different feature test macros.
I also went a step further and removed config.h
for the same reason -- we have had bugs in the past few months where files did not include it, or didn't include it at the top, and this solves that for good -- no file is evaluated without bringing those macros into scope.
prior to this commit, some (but not all) files #define _GNU_SOURCE individually. Mixing gnu/posix extensions at a per-TU level is a recipe for disaster, ABI incompabitilities between files in the same project is never your first guess. Opt into extensions once and for all at the top for consistency, and also add AC_LANG([C]) to ensure that the compiler isn't guessing whether it's a C++ or C source file.
This commits parent set _GNU_SOURCE globally via automake to opt into gnu extensions for the entire project, rather than directly setting it inline in several (but not all) files. The rationale behind this was that conditionally enabling gnu extensions can lead to very hard to debug issues where different compilation units are using different (potentially abi incompatible) implementations. Similarly, not all files in our tree include `config.h' (or in some cases, TUs were including the file but not placing it at the very top, which defeats the purpose of eg: feature test macros.) Our config is ultimately very small (on the order of a dozen or so "actual" options, well within reasonable command line argument max length constraints) and can be passed directly in the compiler command line arguments instead. Do this instead so we don't have to worry about this footgun.
6e48d60
to
7870ec8
Compare
pre-commit is a tool for composing portable/generic git hooks. Introduce this to the repository with a small set of base hooks. Update docs with instructions on how to use it.
Add a pre-commit hook to format yaml files (including pre-commit's config file.)
Apply yamlfmt to files under .ci and .github. This is split into a separate commit so that it can be hidden from git blame.
add a pre-commit hook to validate that all github actions in this repository are properly formatted and don't have common gh action typos/bugs.
ba0d8d3
to
9f2289c
Compare
Exclude all unit tests from reporting, and select a handful of checks that are relevant to this project.
Add a pre-commit hook to run clang-tidy for files under src/ on every commit.
__builtin_ffsll takes a signed long long, not a uint64_t. Explicitly cast to `signed long long' before passing it. Caught with clang tidy.
This is initialized with a signed integer, but assigned to a uint64_t. Do the initialization math in a uint64_t so that there is no conversion. Caught with clang tidy.
This adds a generic editorconfig [1] file for the repo to ensure that CRLF/LF and tabwidth settings are automatically applied when possible, and adds a pre-commit hook to ensure that it is coherent with the tree. [1]: https://editorconfig.org
rename the distcheck workflow to pr-ci. Add a second job to the file for pre-commit, that runs all non-manual pre-commit hooks. Add workflow_dispatch to the file so it can be triggered manually if desired.
fixes: `warning: ‘schedule’ may be used uninitialized [-Wmaybe-uninitialized]' Signed-off-by: Nicholas Sielicki <[email protected]>
use the gh actions cache for apt packages, rather than redownloading them every time. This should accelerate the build somewhat.
Uploading the artifact with only matrix.cc in the name can cause collisions when both fail. Upload it as `${{ matrix.cc }}-${{ matrix.sdk}}-config.log' instead so that it is unique.
+ ignore unit tests + disable unused parameter warnings.
Add a basic clang-format spec to the repository and a pre-commit hook to enforce it. Actually formatting the repository by the rules within this file is split into a separate commit for the sake of doing as much as possible to keep git-blame clean (via .git-blame-ignore-revs) This style was chosen with the help of a tool called whatstyle [1].
bot:aws:retest |
Please merge master. |
Description of Changes
This introduces a large set of quality-of-life improvements.
Introduces pre-commit hooks which run on every pull request under GitHub
actions, as well as locally when setup by developers. This can catch a large
variety of style nits before they reach PR. When attempting to commit a
violating file, the fix will be automatically made and developers just need
to restage the file.
The runtime is reasonably acceptable.
If the checks get in your way when making temporary commits, one can always
pass
--no-verify
to git and rungit rebase --interactive origin/master --exec 'pre-commit run --all-files'
when preparing for PR.Introduces a clang-format file to the repository, and makes the style more consistent.
See commit message of
a25887e ci(pre-commit): introduce clang-format
fordetails on how the specific style was chosen. To avoid making all git history
useless as a part of this,
.git-blame-ignore-revs
is introduced, which can beconfigured locally to hide these commits from git blame. GitHub has support
for reading this file and hiding it from the blame view, as well.
Introduces static analysis which runs on every pull request under GitHub
actions. An example run can be found here. This runs cppcheck, clang-tidy,
and clang-static-analyzer internally via CodeChecker. Note that CodeChecker
is referenced on the upstream LLVM docs as a replacement for their older
python scripts and is fully open source. For now, PRs are not blocked on
reports from these tools. A follow-up PR will fix some of these issues, after
which, we can remove the remaining warnings that are not useful and fail the
analyzer when it introduces regressions.
There are several opinionated changes in this PR that need further discussion
and it is marked as WIP for that reason.