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