Commit b880f66c authored by Felipe Lema's avatar Felipe Lema Committed by Dmitry Kazakov
Browse files

Add clang-format to CI

Add `clang-format` to Continuous Integration so merge request are
ensured to comply with
[KDE's code convention](https://community.kde.org/Policies/Frameworks_Coding_Style#Clang-format_automatic_code_formatting)

## Test Plan

I believe everything's already been setup for invent.kde.org for gitlab CI
(formal docs [here](https://docs.gitlab.com/ee/ci/quick_start/#cicd-process-overview)
parent 8c15dc3e
#!/bin/bash -fxv
# stop running script if a command fails
set -e
# ensure `clang-format` command points to `clang-format-11`
update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-11 30
update-alternatives --set clang-format /usr/bin/clang-format-11
# download .clang-format into current directory
wget -c --output-document=.clang-format https://invent.kde.org/frameworks/extra-cmake-modules/raw/master/kde-modules/clang-format.cmake
# format source code inline
git clang-format-11 $(git merge-base origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME $CI_COMMIT_SHA)
# if files were modified, then print the diff modified that would make the proper format
if ! git diff-index --quiet HEAD; then
echo '*** Suggested changes to comply with KDE code conventions are below'
echo 'You can copy below this empty line, save the content to a format.patch file, then do `patch < format.patch`'
echo ''
git --no-pager diff -U0
exit 1
fi
exit 0
variables:
DEBIAN_FRONTEND: "noninteractive"
clang_format:
stage: build
image: debian:testing
only:
- merge_requests
- master
before_script:
- apt-get update
- apt-get install --yes --no-install-recommends wget ca-certificates git clang-format-11
- update-ca-certificates
script:
- ./.gitlab-ci.script
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment