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