Echo the path to and version of CMake for CI builds
[alexxy/gromacs.git] / admin / gitlab-ci / lint.gitlab-ci.yml
1 # Repository cleanliness. Source tidiness, linting, and policy compliance.
2
3 clang-tidy:configure-push:
4   extends:
5     - .gromacs:base:configure
6     - .use-clang:base
7     - .rules:basic-push
8   image: ${CI_REGISTRY}/gromacs/gromacs/ci-ubuntu-20.04-llvm-11-cuda-11.4.1
9   variables:
10     CMAKE: /usr/local/cmake-3.16.3/bin/cmake
11     COMPILER_MAJOR_VERSION: 11
12     BUILD_DIR: build-clang-tidy
13     CMAKE_EXTRA_OPTIONS: -DCLANG_TIDY=clang-tidy-$COMPILER_MAJOR_VERSION -DGMX_CLANG_TIDY=ON -DGMX_COMPILER_WARNINGS=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
14
15 clang-tidy:configure-schedule:
16   extends:
17     - .gromacs:base:configure
18     - .use-clang:base
19     - .rules:nightly-not-for-release
20   image: ${CI_REGISTRY}/gromacs/gromacs/ci-ubuntu-20.04-llvm-11-cuda-11.4.1
21   variables:
22     CMAKE: /usr/local/cmake-3.16.3/bin/cmake
23     COMPILER_MAJOR_VERSION: 11
24     BUILD_DIR: build-clang-tidy
25     CMAKE_EXTRA_OPTIONS: -DCLANG_TIDY=clang-tidy-$COMPILER_MAJOR_VERSION -DGMX_CLANG_TIDY=ON -DGMX_COMPILER_WARNINGS=ON
26
27 clang-tidy:configure-schedule-cuda:
28   extends:
29     - .gromacs:base:configure
30     - .use-clang:base
31     - .use-cuda
32     - .rules:nightly-not-for-release
33   image: ${CI_REGISTRY}/gromacs/gromacs/ci-ubuntu-20.04-llvm-11-cuda-11.4.1
34   variables:
35     CMAKE: cmake
36     COMPILER_MAJOR_VERSION: 11
37     BUILD_DIR: build-clang-tidy
38     CMAKE_EXTRA_OPTIONS: -DCLANG_TIDY=clang-tidy-$COMPILER_MAJOR_VERSION -DGMX_CLANG_TIDY=ON -DGMX_COMPILER_WARNINGS=ON -DGMX_CLANG_CUDA=ON
39
40 clang-tidy:build:
41   extends:
42     - .gromacs:base:build
43     - .use-ccache
44     - .variables:default
45     - .rules:nightly-not-for-release
46   stage: source-check
47   image: ${CI_REGISTRY}/gromacs/gromacs/ci-ubuntu-20.04-llvm-11-cuda-11.4.1
48   needs:
49     - job: clang-tidy:configure-schedule
50   variables:
51     CMAKE: /usr/local/cmake-3.16.3/bin/cmake
52     BUILD_DIR: build-clang-tidy
53
54 clang-tidy:build-cuda:
55   extends:
56     - .gromacs:base:build
57     - .use-ccache
58     - .variables:default
59     - .rules:nightly-not-for-release
60   stage: source-check
61   image: ${CI_REGISTRY}/gromacs/gromacs/ci-ubuntu-20.04-llvm-11-cuda-11.4.1
62   needs:
63     - job: clang-tidy:configure-schedule-cuda
64   variables:
65     CMAKE: cmake
66     BUILD_DIR: build-clang-tidy
67
68 clang-tidy:test:
69   extends:
70     - .gromacs:base:build
71     - .variables:default
72     - .rules:basic-push
73   stage: source-check
74   image: ${CI_REGISTRY}/gromacs/gromacs/ci-ubuntu-20.04-llvm-11-cuda-11.4.1
75   needs:
76     - job: clang-tidy:configure-push
77   variables:
78     CMAKE: /usr/local/cmake-3.16.3/bin/cmake
79     COMPILER_MAJOR_VERSION: 11
80     BUILD_DIR: build-clang-tidy
81     EXTRA_INSTALLS: clang-tidy-$COMPILER_MAJOR_VERSION
82     KUBERNETES_CPU_LIMIT: 4
83     KUBERNETES_CPU_REQUEST: 2
84     KUBERNETES_MEMORY_REQUEST: 4Gi
85   script:
86     # Make sure that a Python interpreter can be found for `/bin/env python`
87     - test -x /usr/bin/python || update-alternatives --install /usr/bin/python python /usr/bin/python3 1
88     # TODO (issue #3272) `master` is not appropriate for use on release-xxxx branches, how should we handle that?
89     - REV=$(git fetch -q https://gitlab.com/gromacs/gromacs.git master && git show -s --pretty=format:"%h" `git merge-base FETCH_HEAD HEAD`)
90     - HEAD_REV=$(git show -s --pretty=format:"%h" HEAD)
91     - if [[ "$REV" == "$HEAD_REV" ]] ; then
92         REV="HEAD~1" ;
93       fi
94     - echo "Revision used for branch point is $REV"
95     - git show -s $REV
96     - 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
97     - grep -i "found code issues|warnings" clang-tidy.log | tee code-lint.txt || true
98     - if [ -s code-lint.txt ] ; then echo "clang-tidy.sh found issues"; exit 1; fi
99   artifacts:
100     when: on_failure
101     paths:
102       - clang-tidy.log
103       - code-lint.txt
104
105 clang-format:
106   extends:
107     - .variables:default
108     - .rules:basic-push
109   cache: {}
110   stage: pre-build
111   image: ${CI_REGISTRY}/gromacs/gromacs/ci-ubuntu-20.04-llvm-11-cuda-11.4.1
112   variables:
113     COMPILER_MAJOR_VERSION: 11
114     KUBERNETES_CPU_LIMIT: 1
115     KUBERNETES_CPU_REQUEST: 1
116     KUBERNETES_MEMORY_REQUEST: 2Gi
117     EXTRA_INSTALLS: clang-format-$COMPILER_MAJOR_VERSION
118   script:
119     # TODO (issue #3272) `master` is not appropriate for use on release-xxxx branches, how should we handle that?
120     - REV=$(git fetch -q https://gitlab.com/gromacs/gromacs.git master && git show -s --pretty=format:"%h" `git merge-base FETCH_HEAD HEAD`)
121     - HEAD_REV=$(git show -s --pretty=format:"%h" HEAD)
122     - if [[ "$REV" == "$HEAD_REV" ]] ; then
123         REV="HEAD~1" ;
124       fi
125     - echo "Revision used for branch point is $REV"
126     - git show -s $REV
127     - CLANG_FORMAT=clang-format-$COMPILER_MAJOR_VERSION admin/clang-format.sh check --rev=$REV --warnings=clang-format.log
128     - grep -i "needs formatting" clang-format.log | tee formatting.txt || true
129     - if [ -s formatting.txt ] ; then echo "clang-format.sh found issues"; exit 1; fi
130   artifacts:
131     when: on_failure
132     paths:
133       - clang-format.log
134       - formatting.txt
135
136 copyright-check:
137   extends:
138     - .variables:default
139     - .rules:basic-push
140   cache: {}
141   stage: pre-build
142   image: ${CI_REGISTRY}/gromacs/gromacs/ci-ubuntu-20.04-llvm-11-cuda-11.4.1
143   variables:
144     KUBERNETES_CPU_LIMIT: 1
145     KUBERNETES_CPU_REQUEST: 1
146     KUBERNETES_MEMORY_REQUEST: 2Gi
147   script:
148     - REV=$(git fetch -q https://gitlab.com/gromacs/gromacs.git master && git show -s --pretty=format:"%h" `git merge-base FETCH_HEAD HEAD`)
149     - HEAD_REV=$(git show -s --pretty=format:"%h" HEAD)
150     - if [[ "$REV" == "$HEAD_REV" ]] ; then
151         REV="HEAD~1" ;
152       fi
153     - echo "Revision used for branch point is $REV"
154     - git show -s $REV
155     - admin/copyright.sh check --rev=$REV --warnings=copyright.log
156     - grep -i "copyright year" copyright.log | tee years.log || true
157     - grep -i "copyright header" copyright.log | tee headers.log || true
158     - if [[ -s years.log || -s headers.log ]] ; then
159       echo "Copyright information needs updating" ;
160       exit 1 ;
161       fi
162   artifacts:
163     when: on_failure
164     paths:
165       - copyright.log
166       - years.log
167       - headers.log
168
169 check-source:
170   extends:
171     - .variables:default
172     - .docs:build
173     - .before_script:default
174     - .rules:basic-push
175   cache: {}
176   stage: source-check
177   needs:
178     - job: docs:build
179       artifacts: true
180   variables:
181     KUBERNETES_CPU_LIMIT: 1
182     KUBERNETES_CPU_REQUEST: 1
183     KUBERNETES_MEMORY_REQUEST: 2Gi
184     BUILD_DIR: build-docs
185   script:
186     - CMAKE=${CMAKE:-$(which cmake)}
187     - cd $BUILD_DIR
188     - which $CMAKE
189     - $CMAKE --version
190     - $CMAKE --build . --target check-source
191     - awk '/warning.*include style.*order/,/You can use.*rst|^$/' docs/doxygen/check-source.log | tee doxygenError.txt || true
192     - awk '/warning:.*includes/,/unnecessarily|^$/' docs/doxygen/check-source.log | tee -a doxygenError.txt || true
193     - awk '/Traceback/,/.*rror|^$/' docs/doxygen/doxygen*log docs/doxygen/check-source.log | tee -a doxygenError.txt || true
194     - awk '/warning:/,/in doxygen.*|^$/' docs/doxygen/doxygen*log | tee -a doxygenError.txt || true
195     - grep -i "unused cycle suppression" docs/doxygen/check-source.log | tee -a doxygenError.txt || true
196     - if [ -s doxygenError.txt ] ; then echo "Found errors while running doxygen"; exit 1; fi
197   artifacts:
198     name: docs-artifacts-$CI_COMMIT_REF_SLUG
199     when: always
200     expire_in: 1 week
201     paths:
202       - $BUILD_DIR/docs/doxygen/doxygen-xml.log
203       - $BUILD_DIR/docs/doxygen/check-source.log
204
205 linkchecker:
206   extends:
207     - .webpage:build
208     - .rules:nightly-not-for-release
209   stage: nightly-build
210   dependencies:
211     - webpage:build
212   variables:
213     KUBERNETES_CPU_LIMIT: 1
214     KUBERNETES_CPU_REQUEST: 1
215     KUBERNETES_MEMORY_REQUEST: 2Gi
216     BUILD_DIR: build-docs
217   script:
218     - cd $BUILD_DIR
219     - linkchecker docs/html/index.html -f $CI_PROJECT_DIR/docs/linkcheckerrc -Fxml --ignore-url html-full
220       --ignore-url html-user --ignore-url html-lib --ignore-url .tar.gz --ignore-url _sources
221       -o xml
222   artifacts:
223     reports:
224       junit: $BUILD_DIR/linkchecker-out.xml