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