openbmc coding standards validation in CI

Stewart Smith stewart at linux.vnet.ibm.com
Mon Jan 15 12:06:29 AEDT 2018


Andrew Geissler <geissonator at gmail.com> writes:
> During the hackathon meetup, we decided to try and get something in
> our CI jobs that would validate the code formatting and automatically
> -1 the gerrit commit if it's not up to par.  The reasoning behind this
> is we still have a lot of code review comments coming in this area,
> which is wasteful for the reviewers.
>
> Ed, Adriana, and I all worked different pieces of it.  We're using the
> clang-format tool to format (and then validate the format).  The idea
> is you do the initial run of the tool against your repo and check the
> .clang-format file in with your changes.  The presence of the file
> will cause the CI job to validate the code formatting.  After the
> .clang-format is merged, CI jobs will fail if the new code doesn't
> follow the standard.  The CI jenkins job will output the diff of the
> code that is not conforming to the console.
>
> We've tried our best to get the .clang-format file to match up with
> our requirements in
> https://github.com/openbmc/docs/blob/master/cpp-style-and-conventions.md.
>
> The .clang-format file and the changes it did to the sdbusplus repo
> can be found in https://gerrit.openbmc-project.xyz/#/c/8461/.  Review
> comments appreciated.

Oh neat!

I gather the CI job is something like "parallel clang-format -i {} :::
`find . -name '*.c' -name '*.cpp' -name '*.h'`" and then check for any
changes?

-- 
Stewart Smith
OPAL Architect, IBM.



More information about the openbmc mailing list