Print base commit for source linters
[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   tags: []
10   variables:
11     COMPILER_MAJOR_VERSION: 8
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/cmake-3.11.4-llvm-8-openmpi:2020
21   tags: []
22   variables:
23     COMPILER_MAJOR_VERSION: 8
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/cmake-3.11.4-llvm-8-openmpi:2020
35   needs:
36     - job: clang-tidy:configure-schedule
37   variables:
38     BUILD_DIR: build-clang-tidy
39
40 clang-tidy:test:
41   extends:
42     - .gromacs:base:build
43     - .variables:default
44     - .rules:basic-push
45   stage: source-check
46   image: gromacs/cmake-3.11.4-llvm-8-openmpi:2020
47   tags: []
48   needs:
49     - job: clang-tidy:configure-push
50   variables:
51     COMPILER_MAJOR_VERSION: 8
52     BUILD_DIR: build-clang-tidy
53     EXTRA_INSTALLS: clang-tidy-$COMPILER_MAJOR_VERSION
54     KUBERNETES_CPU_LIMIT: 4
55     KUBERNETES_CPU_REQUEST: 2
56     KUBERNETES_MEMORY_LIMIT: 4Gi
57   script:
58     - REV=$(git fetch -q https://gitlab.com/gromacs/gromacs.git release-2020 && 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:2020
81   tags: []
82   variables:
83     COMPILER_MAJOR_VERSION: 7
84     KUBERNETES_CPU_LIMIT: 1
85     KUBERNETES_CPU_REQUEST: 1
86     KUBERNETES_MEMORY_LIMIT: 2Gi
87     EXTRA_INSTALLS: clang-format-$COMPILER_MAJOR_VERSION
88   script:
89     - REV=$(git fetch -q https://gitlab.com/gromacs/gromacs.git release-2020 && git show -s --pretty=format:"%h" `git merge-base FETCH_HEAD HEAD`)
90     - HEAD_REV=$(git show -s --pretty=format:"%h" HEAD)
91     - if [[ "$REV" == "$HEAD_REV" ]] ; then
92         REV="HEAD~1" ;
93       fi
94     - echo "Revision used for branch point is $REV"
95     - git show -s $REV
96     - CLANG_FORMAT=clang-format-$COMPILER_MAJOR_VERSION admin/clang-format.sh check --rev=$REV --warnings=clang-format.log
97     - grep -i "needs formatting" clang-format.log | tee formatting.txt || true
98     - if [ -s formatting.txt ] ; then echo "clang-format.sh found issues"; exit 1; fi
99   artifacts:
100     when: on_failure
101     paths:
102       - clang-format.log
103       - formatting.txt
104
105 copyright-check:
106   extends:
107     - .variables:default
108     - .rules:basic-push
109   cache: {}
110   stage: pre-build
111   image: gromacs/ci-docs-llvm:2020
112   tags: []
113   variables:
114     KUBERNETES_CPU_LIMIT: 1
115     KUBERNETES_CPU_REQUEST: 1
116     KUBERNETES_MEMORY_LIMIT: 2Gi
117   script:
118     - REV=$(git fetch -q https://gitlab.com/gromacs/gromacs.git release-2020 && git show -s --pretty=format:"%h" `git merge-base FETCH_HEAD HEAD`)
119     - HEAD_REV=$(git show -s --pretty=format:"%h" HEAD)
120     - if [[ "$REV" == "$HEAD_REV" ]] ; then
121         REV="HEAD~1" ;
122       fi
123     - echo "Revision used for branch point is $REV"
124     - git show -s $REV
125     - admin/copyright.sh check --rev=$REV --warnings=copyright.log
126     - grep -i "copyright year" copyright.log | tee years.log || true
127     - grep -i "copyright header" copyright.log | tee headers.log || true
128     - if [[ -s years.log || -s headers.log ]] ; then
129       echo "Copyright information needs updating" ;
130       exit 1 ;
131       fi
132   artifacts:
133     when: on_failure
134     paths:
135       - copyright.log
136       - years.log
137       - headers.log
138
139 check-source:
140   extends:
141     - .variables:default
142     - .docs:build
143     - .before_script:default
144     - .rules:basic-push
145   cache: {}
146   stage: source-check
147   tags: []
148   needs:
149     - job: docs:build
150       artifacts: true
151   variables:
152     KUBERNETES_CPU_LIMIT: 1
153     KUBERNETES_CPU_REQUEST: 1
154     KUBERNETES_MEMORY_LIMIT: 2Gi
155     BUILD_DIR: build-docs
156   script:
157     - cd $BUILD_DIR
158     - cmake --build . --target check-source
159     - awk '/warning.*include style.*order/,/You can use.*rst|^$/' docs/doxygen/check-source.log | tee doxygenError.txt || true
160     - awk '/Traceback/,/.*rror|^$/' docs/doxygen/doxygen*log docs/doxygen/check-source.log | tee -a doxygenError.txt || true
161     - awk '/warning:/,/in doxygen.*|^$/' docs/doxygen/doxygen*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_LIMIT: 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