1

I have a GitLab repository containing Protocol Buffers code (i.e., .proto files).

The specifics of what I wish to accomplish shouldn't matter to my main question, but the context may help, so here goes. I wish to add a Protocol Buffers source code formatter to the repository's GitLab CI pipeline that checks whether the proto files in any merge request are correctly formatted (say, by running the formatter on the source files and checking that no changes are produced). The formatter I've settled on for this task is clang-format.

Clang-format is distributed as a binary. What is the right approach to integrate the binary into the GitLab CI pipeline for this purpose? By right approach, I'm mainly looking for:

  • solutions that are idiomatic and follow best practices; and
  • solutions that are efficient (e.g., not re-download the binary for each run, if possible)
nishanthshanmugham
  • 2,967
  • 1
  • 25
  • 29

1 Answers1

1

There are a number of docker images for clang-format at Docker Hub. Take a look at them and choose one to use. maranov/clang-git says it was specifically created for use in Gitlab CI pipelines, so that might be worth a try.

Update your .gitlab-ci.yml file to use the image:

Job Name:
  stage: my-stage
  image: maranov/clang-git
  script:
    - #run what you need to

Instead of using a pre-made image, you could create your own.

nishanthshanmugham
  • 2,967
  • 1
  • 25
  • 29
Adam Marshall
  • 6,369
  • 1
  • 29
  • 45