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