Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

check coding style with gitlab CI

Tags:

gitlab-ci

I use clang-format to format my source code and I want to verify the coding style(variable name préfix, indentation, ...) in gitlab CI.

I already use code quality to check variable scop.

I want to add coding style verify in code quality.

someone know how to do that ?

ps: I am not a gitllab CI specialist.

like image 461
Tom Penard Avatar asked Oct 26 '25 12:10

Tom Penard


1 Answers

I have found this solution, add fallowing lines to .gitlab-ci.yml:

format:
  stage: test
  image: nexus.lumiplan.com:8443/toolchain/clang-format:13
  needs: []
  script:
    - find rootToYourProject \( \( -name \*.cpp -o -name \*.h \) -a ! -iname \*soap\* \) -print0 | xargs -0 -n 1 clang-format-13 --Werror -n --verbose
  only:
    - merge_requests

With this script I do a verification of my clang format configuration to all .cpp and .h files excepted for soap files.

like image 169
Tom Penard Avatar answered Oct 28 '25 03:10

Tom Penard



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!