Add clang-tidy script
[alexxy/gromacs.git] / admin / gitlab-ci / lint.gitlab-ci.yml
index 828b9a3174653ece28fe214333fa7e6f460c02c7..3836cbe5b6010f0d12b1c91c91dfe17b8f1fe112 100644 (file)
@@ -14,6 +14,20 @@ clang-tidy:configure:
   # TODO: Enable GMX_PYTHON_PACKAGE for clang-tidy when dependencies are in Docker image.
 
 clang-tidy:build:
+  extends:
+    - .gromacs:base:build
+    - .use-ccache
+    - .variables:default
+    - .use-clang7
+    - .rules:nightly-not-for-release
+  stage: source-check
+  needs:
+    - job: clang-tidy:configure
+  variables:
+    BUILD_DIR: build-clang-tidy
+    EXTRA_INSTALLS: clang-tidy-$COMPILER_MAJOR_VERSION
+
+clang-tidy:test:
   extends:
     - .gromacs:base:build
     - .use-ccache
@@ -23,10 +37,21 @@ clang-tidy:build:
   stage: source-check
   needs:
     - job: clang-tidy:configure
-      artifacts: true
   variables:
     BUILD_DIR: build-clang-tidy
     EXTRA_INSTALLS: clang-tidy-$COMPILER_MAJOR_VERSION
+    KUBERNETES_CPU_LIMIT: 4
+    KUBERNETES_CPU_REQUEST: 2
+    KUBERNETES_MEMORY_LIMIT: 4Gi
+  script:
+    - RUN_CLANG_TIDY=run-clang-tidy-$COMPILER_MAJOR_VERSION bash admin/clang-tidy.sh check --parallel=$KUBERNETES_CPU_LIMIT --warnings=clang-tidy.log --rev=origin/master -B=$BUILD_DIR
+    - grep -iq "found code issues" clang-tidy.log | tee code-lint.txt || true
+    - if [ -s code-lint.txt ] ; then echo "clang-tidy.sh found issues"; exit 1; fi
+  artifacts:
+    when: on_failure
+    paths:
+      - clang-tidy.log
+      - code-lint.txt
 
 clang-format:
   extends: