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