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