-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Fix pre-commit hook; add CMake formatting pre-commit #759
Conversation
I like the idea of autoformatting the |
Let me see if I can set configure options for that. |
2c5d72b
to
db9b78e
Compare
# NOTE: We ignore C0103, which would enforce that variables are all-caps | ||
# NOTE: We ignore C0113, which would enforce that comments are used | ||
# NOTE: We set the tab size to 4 | ||
# NOTE: We set the maximum line length to 100 |
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.
Okay, I figured out how to set a config file with these four edits. With these edits, the lint check passes without modification of the code!
.cmake-lint-config.py
Outdated
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.
This file was generated with
cmake-lint --disabled {C0103,C0113} --tab-size 4 --line-width 100 --dump-config python > .cmake-lint-config.py
so it consists of the defaults plus the four edits. I figure it'd be useful to use the current defaults, given our experience with the default settings of clang-format changing.
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.
👍
# Workflow handling In the interests of green computing, development efficiency and avoiding unnecessary CI runs, this PR sets up paths for workflow handling, so that the linters are only run if the source code or build code change and the test suite is only run if the test suite, build system, or config files change. The PR also fixes a copy-paste error in the linting workflow (introduced in #759).
Fix pre-commit hook; add CMake formatting pre-commit
There was a minor issue in the pre-commit hook because the final lines checked for differences in
nextsim_precommit_before.patch
andnextsim_precommit_after.patch
but these were replaced with calls tomktemp
.While fixing this, I realised we aren't currently formatting
CMakeLists.txt
files but tools for this exist. Let me know if this is something we'd like to include.I also added some docs on how to get the pre-commit hook set up.
(Almost all of the changes in this PR are auto-formatting.)