Update image names in job definitions.
[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/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: 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: 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: 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 release-2021 && 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: 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     - REV=$(git fetch -q https://gitlab.com/gromacs/gromacs.git release-2021 && git show -s --pretty=format:"%h" `git merge-base FETCH_HEAD HEAD`)
93     - HEAD_REV=$(git show -s --pretty=format:"%h" HEAD)
94     - if [[ "$REV" == "$HEAD_REV" ]] ; then
95         REV="HEAD~1" ;
96       fi
97     - echo "Revision used for branch point is $REV"
98     - git show -s $REV
99     - CLANG_FORMAT=clang-format-$COMPILER_MAJOR_VERSION admin/clang-format.sh check --rev=$REV --warnings=clang-format.log
100     - grep -i "needs formatting" clang-format.log | tee formatting.txt || true
101     - if [ -s formatting.txt ] ; then echo "clang-format.sh found issues"; exit 1; fi
102   artifacts:
103     when: on_failure
104     paths:
105       - clang-format.log
106       - formatting.txt
107
108 copyright-check:
109   extends:
110     - .variables:default
111     - .rules:basic-push
112   cache: {}
113   stage: pre-build
114   image: gromacs/ci-ubuntu-18.04-llvm-7-docs
115   variables:
116     KUBERNETES_CPU_LIMIT: 1
117     KUBERNETES_CPU_REQUEST: 1
118     KUBERNETES_MEMORY_REQUEST: 2Gi
119   script:
120     # TODO (issue #3272) `master` is not appropriate for use on release-xxxx branches, how should we handle that?
121     - REV=$(git fetch -q https://gitlab.com/gromacs/gromacs.git master && git show -s --pretty=format:"%h" `git merge-base FETCH_HEAD HEAD`)
122     - HEAD_REV=$(git show -s --pretty=format:"%h" HEAD)
123     - if [[ "$REV" == "$HEAD_REV" ]] ; then
124         REV="HEAD~1" ;
125       fi
126     - echo "Revision used for branch point is $REV"
127     - git show -s $REV
128     - admin/copyright.sh check --rev=$REV --warnings=copyright.log
129     - grep -i "copyright year" copyright.log | tee years.log || true
130     - grep -i "copyright header" copyright.log | tee headers.log || true
131     - if [[ -s years.log || -s headers.log ]] ; then
132       echo "Copyright information needs updating" ;
133       exit 1 ;
134       fi
135   artifacts:
136     when: on_failure
137     paths:
138       - copyright.log
139       - years.log
140       - headers.log
141
142 check-source:
143   extends:
144     - .variables:default
145     - .docs:build
146     - .before_script:default
147     - .rules:basic-push
148   cache: {}
149   stage: source-check
150   needs:
151     - job: docs:build
152       artifacts: true
153   variables:
154     KUBERNETES_CPU_LIMIT: 1
155     KUBERNETES_CPU_REQUEST: 1
156     KUBERNETES_MEMORY_REQUEST: 2Gi
157     BUILD_DIR: build-docs
158   script:
159     - CMAKE=${CMAKE:-$(which cmake)}
160     - cd $BUILD_DIR
161     - $CMAKE --build . --target check-source
162     - awk '/warning.*include style.*order/,/You can use.*rst|^$/' docs/doxygen/check-source.log | tee doxygenError.txt || true
163     - awk '/warning:.*includes/,/unnecessarily|^$/' docs/doxygen/check-source.log | tee -a doxygenError.txt || true
164     - awk '/Traceback/,/.*rror|^$/' docs/doxygen/doxygen*log docs/doxygen/check-source.log | tee -a doxygenError.txt || true
165     - awk '/warning:/,/in doxygen.*|^$/' docs/doxygen/doxygen*log | tee -a doxygenError.txt || true
166     - grep -i "unused cycle suppression" docs/doxygen/check-source.log | tee -a doxygenError.txt || true
167     - if [ -s doxygenError.txt ] ; then echo "Found errors while running doxygen"; exit 1; fi
168   artifacts:
169     name: docs-artifacts-$CI_COMMIT_REF_SLUG
170     when: always
171     expire_in: 1 week
172     paths:
173       - $BUILD_DIR/docs/doxygen/doxygen-xml.log
174       - $BUILD_DIR/docs/doxygen/check-source.log
175
176 linkchecker:
177   extends:
178     - .webpage:build
179     - .rules:nightly-not-for-release
180   stage: nightly-build
181   dependencies:
182     - webpage:build
183   variables:
184     KUBERNETES_CPU_LIMIT: 1
185     KUBERNETES_CPU_REQUEST: 1
186     KUBERNETES_MEMORY_REQUEST: 2Gi
187     BUILD_DIR: build-docs
188   script:
189     - cd $BUILD_DIR
190     - linkchecker docs/html/index.html -f $CI_PROJECT_DIR/docs/linkcheckerrc -Fxml --ignore-url html-full
191       --ignore-url html-user --ignore-url html-lib --ignore-url .tar.gz --ignore-url _sources
192       -o xml
193   artifacts:
194     reports:
195       junit: $BUILD_DIR/linkchecker-out.xml