Add a C++ linting job via git-clang-format
Change-Id: Ia21fdbb236b6e8541ba58c5710cc5cfec62568ee
diff --git a/roles/git-clang-format/tasks/main.yaml b/roles/git-clang-format/tasks/main.yaml
new file mode 100644
index 0000000..f8b9f38
--- /dev/null
+++ b/roles/git-clang-format/tasks/main.yaml
@@ -0,0 +1,17 @@
+- name: Run test_command
+ shell: |
+ OUT='{{ ansible_user_dir }}/zuul-output/logs/git-clang-format.patch'
+ git-clang-format --quiet --diff --style file 'origin/{{ zuul.branch }}' | tee "${OUT}"
+ if [[ "$(head -n 1 ${OUT})" == "no modified files to format" ]]; then
+ # no usable exit code for this...
+ rm -f "${OUT}"
+ exit 0
+ elif [[ -s "${OUT}" ]]; then
+ # ...whereas this one exits with 0...
+ exit 1
+ else
+ rm -f "${OUT}"
+ exit 0
+ fi
+ args:
+ chdir: '{{ zuul.project.src_dir }}'