Echo the path to and version of CMake for CI builds
[alexxy/gromacs.git] / admin / gitlab-ci / lint.gitlab-ci.yml
index 8ba4b40398f401af3a8c8bdcb74c8056dd581bb5..623998101330bf77e82975b492746e869357b9f9 100644 (file)
 # Repository cleanliness. Source tidiness, linting, and policy compliance.
 
-configure-clang-tidy:
+clang-tidy:configure-push:
   extends:
-    - .configure-extends-template
-    - .use-clang7
-  needs:
-    - job: simple-build
-      artifacts: false
+    - .gromacs:base:configure
+    - .use-clang:base
+    - .rules:basic-push
+  image: ${CI_REGISTRY}/gromacs/gromacs/ci-ubuntu-20.04-llvm-11-cuda-11.4.1
+  variables:
+    CMAKE: /usr/local/cmake-3.16.3/bin/cmake
+    COMPILER_MAJOR_VERSION: 11
+    BUILD_DIR: build-clang-tidy
+    CMAKE_EXTRA_OPTIONS: -DCLANG_TIDY=clang-tidy-$COMPILER_MAJOR_VERSION -DGMX_CLANG_TIDY=ON -DGMX_COMPILER_WARNINGS=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
+
+clang-tidy:configure-schedule:
+  extends:
+    - .gromacs:base:configure
+    - .use-clang:base
+    - .rules:nightly-not-for-release
+  image: ${CI_REGISTRY}/gromacs/gromacs/ci-ubuntu-20.04-llvm-11-cuda-11.4.1
   variables:
+    CMAKE: /usr/local/cmake-3.16.3/bin/cmake
+    COMPILER_MAJOR_VERSION: 11
     BUILD_DIR: build-clang-tidy
     CMAKE_EXTRA_OPTIONS: -DCLANG_TIDY=clang-tidy-$COMPILER_MAJOR_VERSION -DGMX_CLANG_TIDY=ON -DGMX_COMPILER_WARNINGS=ON
-    EXTRA_INSTALLS: clang-tidy-$COMPILER_MAJOR_VERSION
-  except:
-    variables:
-      - $GROMACS_RELEASE
 
-build-clang-tidy:
+clang-tidy:configure-schedule-cuda:
+  extends:
+    - .gromacs:base:configure
+    - .use-clang:base
+    - .use-cuda
+    - .rules:nightly-not-for-release
+  image: ${CI_REGISTRY}/gromacs/gromacs/ci-ubuntu-20.04-llvm-11-cuda-11.4.1
+  variables:
+    CMAKE: cmake
+    COMPILER_MAJOR_VERSION: 11
+    BUILD_DIR: build-clang-tidy
+    CMAKE_EXTRA_OPTIONS: -DCLANG_TIDY=clang-tidy-$COMPILER_MAJOR_VERSION -DGMX_CLANG_TIDY=ON -DGMX_COMPILER_WARNINGS=ON -DGMX_CLANG_CUDA=ON
+
+clang-tidy:build:
   extends:
-    - .build-clang
-    - .use-clang7
+    - .gromacs:base:build
+    - .use-ccache
+    - .variables:default
+    - .rules:nightly-not-for-release
   stage: source-check
+  image: ${CI_REGISTRY}/gromacs/gromacs/ci-ubuntu-20.04-llvm-11-cuda-11.4.1
   needs:
-    - job: simple-build
-      artifacts: false
-    - job: configure-clang-tidy
-      artifacts: true
+    - job: clang-tidy:configure-schedule
   variables:
+    CMAKE: /usr/local/cmake-3.16.3/bin/cmake
     BUILD_DIR: build-clang-tidy
-    EXTRA_INSTALLS: clang-tidy-$COMPILER_MAJOR_VERSION
-  except:
-    variables:
-      - $GROMACS_RELEASE
 
-run-clang-format:
+clang-tidy:build-cuda:
   extends:
-    - .binary-build-template
+    - .gromacs:base:build
+    - .use-ccache
     - .variables:default
-    - .use-clang7
-  cache: {}
+    - .rules:nightly-not-for-release
+  stage: source-check
+  image: ${CI_REGISTRY}/gromacs/gromacs/ci-ubuntu-20.04-llvm-11-cuda-11.4.1
+  needs:
+    - job: clang-tidy:configure-schedule-cuda
+  variables:
+    CMAKE: cmake
+    BUILD_DIR: build-clang-tidy
+
+clang-tidy:test:
+  extends:
+    - .gromacs:base:build
+    - .variables:default
+    - .rules:basic-push
   stage: source-check
-  when: always
+  image: ${CI_REGISTRY}/gromacs/gromacs/ci-ubuntu-20.04-llvm-11-cuda-11.4.1
   needs:
-    - job: simple-build
-      artifacts: false
+    - job: clang-tidy:configure-push
   variables:
+    CMAKE: /usr/local/cmake-3.16.3/bin/cmake
+    COMPILER_MAJOR_VERSION: 11
+    BUILD_DIR: build-clang-tidy
+    EXTRA_INSTALLS: clang-tidy-$COMPILER_MAJOR_VERSION
+    KUBERNETES_CPU_LIMIT: 4
+    KUBERNETES_CPU_REQUEST: 2
+    KUBERNETES_MEMORY_REQUEST: 4Gi
+  script:
+    # Make sure that a Python interpreter can be found for `/bin/env python`
+    - test -x /usr/bin/python || update-alternatives --install /usr/bin/python python /usr/bin/python3 1
+    # TODO (issue #3272) `master` is not appropriate for use on release-xxxx branches, how should we handle that?
+    - REV=$(git fetch -q https://gitlab.com/gromacs/gromacs.git master && git show -s --pretty=format:"%h" `git merge-base FETCH_HEAD HEAD`)
+    - HEAD_REV=$(git show -s --pretty=format:"%h" HEAD)
+    - if [[ "$REV" == "$HEAD_REV" ]] ; then
+        REV="HEAD~1" ;
+      fi
+    - echo "Revision used for branch point is $REV"
+    - git show -s $REV
+    - RUN_CLANG_TIDY=run-clang-tidy-$COMPILER_MAJOR_VERSION bash admin/clang-tidy.sh check --parallel=$KUBERNETES_CPU_LIMIT --warnings=clang-tidy.log --rev=$REV -B=$BUILD_DIR
+    - grep -i "found code issues|warnings" 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:
+    - .variables:default
+    - .rules:basic-push
+  cache: {}
+  stage: pre-build
+  image: ${CI_REGISTRY}/gromacs/gromacs/ci-ubuntu-20.04-llvm-11-cuda-11.4.1
+  variables:
+    COMPILER_MAJOR_VERSION: 11
     KUBERNETES_CPU_LIMIT: 1
     KUBERNETES_CPU_REQUEST: 1
-    KUBERNETES_MEMORY_LIMIT: 2Gi
+    KUBERNETES_MEMORY_REQUEST: 2Gi
     EXTRA_INSTALLS: clang-format-$COMPILER_MAJOR_VERSION
-  except:
-    variables:
-      - $GROMACS_RELEASE
   script:
-    - export CLANG_FORMAT=clang-format-$COMPILER_MAJOR_VERSION
-    - admin/clang-format.sh check --rev=HEAD^ --warnings=clang-format.log
-    - grep -iq "needs formatting" clang-format.log | tee formatting.txt || true
+    # TODO (issue #3272) `master` is not appropriate for use on release-xxxx branches, how should we handle that?
+    - REV=$(git fetch -q https://gitlab.com/gromacs/gromacs.git master && git show -s --pretty=format:"%h" `git merge-base FETCH_HEAD HEAD`)
+    - HEAD_REV=$(git show -s --pretty=format:"%h" HEAD)
+    - if [[ "$REV" == "$HEAD_REV" ]] ; then
+        REV="HEAD~1" ;
+      fi
+    - echo "Revision used for branch point is $REV"
+    - git show -s $REV
+    - CLANG_FORMAT=clang-format-$COMPILER_MAJOR_VERSION admin/clang-format.sh check --rev=$REV --warnings=clang-format.log
+    - grep -i "needs formatting" clang-format.log | tee formatting.txt || true
     - if [ -s formatting.txt ] ; then echo "clang-format.sh found issues"; exit 1; fi
   artifacts:
     when: on_failure
@@ -62,28 +133,28 @@ run-clang-format:
       - clang-format.log
       - formatting.txt
 
-run-copyright-check:
+copyright-check:
   extends:
-    - .binary-build-template
     - .variables:default
-    - .use-clang7
+    - .rules:basic-push
   cache: {}
-  stage: source-check
-  when: always
-  needs:
-    - job: simple-build
-      artifacts: false
+  stage: pre-build
+  image: ${CI_REGISTRY}/gromacs/gromacs/ci-ubuntu-20.04-llvm-11-cuda-11.4.1
   variables:
     KUBERNETES_CPU_LIMIT: 1
     KUBERNETES_CPU_REQUEST: 1
-    KUBERNETES_MEMORY_LIMIT: 2Gi
-  except:
-    variables:
-      - $GROMACS_RELEASE
+    KUBERNETES_MEMORY_REQUEST: 2Gi
   script:
-    - admin/copyright.sh check --rev=HEAD^ --warnings=copyright.log
-    - grep -iq "copyright year" copyright.log | tee years.log || true
-    - grep -iq "copyright header" copyright.log | tee headers.log || true
+    - REV=$(git fetch -q https://gitlab.com/gromacs/gromacs.git master && git show -s --pretty=format:"%h" `git merge-base FETCH_HEAD HEAD`)
+    - HEAD_REV=$(git show -s --pretty=format:"%h" HEAD)
+    - if [[ "$REV" == "$HEAD_REV" ]] ; then
+        REV="HEAD~1" ;
+      fi
+    - echo "Revision used for branch point is $REV"
+    - git show -s $REV
+    - admin/copyright.sh check --rev=$REV --warnings=copyright.log
+    - grep -i "copyright year" copyright.log | tee years.log || true
+    - grep -i "copyright header" copyright.log | tee headers.log || true
     - if [[ -s years.log || -s headers.log ]] ; then
       echo "Copyright information needs updating" ;
       exit 1 ;
@@ -95,31 +166,33 @@ run-copyright-check:
       - years.log
       - headers.log
 
-run-check-source:
+check-source:
   extends:
     - .variables:default
-    - .build-docs-binary-template
-    - .documentation-before-script-template
+    - .docs:build
+    - .before_script:default
+    - .rules:basic-push
   cache: {}
   stage: source-check
   needs:
-    - job: simple-build
-      artifacts: false
-    - job: build-docs
+    - job: docs:build
       artifacts: true
   variables:
     KUBERNETES_CPU_LIMIT: 1
     KUBERNETES_CPU_REQUEST: 1
-    KUBERNETES_MEMORY_LIMIT: 2Gi
+    KUBERNETES_MEMORY_REQUEST: 2Gi
     BUILD_DIR: build-docs
-  except:
-    variables:
-      - $GROMACS_RELEASE
   script:
+    - CMAKE=${CMAKE:-$(which cmake)}
     - cd $BUILD_DIR
-    - cmake --build . --target check-source
-    - grep -qi "error" docs/doxygen/doxygen*log docs/doxygen/check-source.log | tee doxygenError.txt || true
-    - grep -qi "warning" docs/doxygen/doxygen*log docs/doxygen/check-source.log | tee -a doxygenError.txt || true
+    - which $CMAKE
+    - $CMAKE --version
+    - $CMAKE --build . --target check-source
+    - awk '/warning.*include style.*order/,/You can use.*rst|^$/' docs/doxygen/check-source.log | tee doxygenError.txt || true
+    - awk '/warning:.*includes/,/unnecessarily|^$/' docs/doxygen/check-source.log | tee -a doxygenError.txt || true
+    - awk '/Traceback/,/.*rror|^$/' docs/doxygen/doxygen*log docs/doxygen/check-source.log | tee -a doxygenError.txt || true
+    - awk '/warning:/,/in doxygen.*|^$/' docs/doxygen/doxygen*log | tee -a doxygenError.txt || true
+    - grep -i "unused cycle suppression" docs/doxygen/check-source.log | tee -a doxygenError.txt || true
     - if [ -s doxygenError.txt ] ; then echo "Found errors while running doxygen"; exit 1; fi
   artifacts:
     name: docs-artifacts-$CI_COMMIT_REF_SLUG
@@ -131,26 +204,19 @@ run-check-source:
 
 linkchecker:
   extends:
-    - .build-docs-webpage
+    - .webpage:build
+    - .rules:nightly-not-for-release
   stage: nightly-build
   dependencies:
-    - webpage-gmxapi
-  only:
-    - schedules
-    - triggers
-    - merge_requests
-    - external_pull_requests
-  except:
-    variables:
-      - $GROMACS_RELEASE
+    - webpage:build
   variables:
     KUBERNETES_CPU_LIMIT: 1
     KUBERNETES_CPU_REQUEST: 1
-    KUBERNETES_MEMORY_LIMIT: 2Gi
-    BUILD_DIR: build-docs-gmxapi
+    KUBERNETES_MEMORY_REQUEST: 2Gi
+    BUILD_DIR: build-docs
   script:
     - cd $BUILD_DIR
-    - linkchecker docs/html/index.html -f ../docs/linkcheckerrc -Fxml --ignore-url html-full
+    - linkchecker docs/html/index.html -f $CI_PROJECT_DIR/docs/linkcheckerrc -Fxml --ignore-url html-full
       --ignore-url html-user --ignore-url html-lib --ignore-url .tar.gz --ignore-url _sources
       -o xml
   artifacts: