The ugliest hack to fix rebase issues ever
[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   dependencies: []
10   tags: []
11   variables:
12     COMPILER_MAJOR_VERSION: 9
13     BUILD_DIR: build-clang-tidy
14     CMAKE_EXTRA_OPTIONS: -DCLANG_TIDY=clang-tidy-$COMPILER_MAJOR_VERSION -DGMX_CLANG_TIDY=ON -DGMX_COMPILER_WARNINGS=ON
15
16 clang-tidy:configure-schedule:
17   extends:
18     - .gromacs:base:configure
19     - .use-clang:base
20     - .rules:nightly-not-for-release
21   image: gromacs/cmake-3.15.7-llvm-9-openmpi:master
22   dependencies: []
23   tags: []
24   variables:
25     COMPILER_MAJOR_VERSION: 9
26     BUILD_DIR: build-clang-tidy
27     CMAKE_EXTRA_OPTIONS: -DCLANG_TIDY=clang-tidy-$COMPILER_MAJOR_VERSION -DGMX_CLANG_TIDY=ON -DGMX_COMPILER_WARNINGS=ON
28
29 clang-tidy:build:
30   extends:
31     - .gromacs:base:build
32     - .use-ccache
33     - .variables:default
34     - .rules:nightly-not-for-release
35   stage: source-check
36   image: gromacs/cmake-3.15.7-llvm-9-openmpi:master
37   needs:
38     - job: clang-tidy:configure-schedule
39   variables:
40     BUILD_DIR: build-clang-tidy
41
42 clang-tidy:test:
43   extends:
44     - .gromacs:base:build
45     - .use-ccache
46     - .variables:default
47     - .rules:basic-push
48   stage: source-check
49   image: gromacs/cmake-3.15.7-llvm-9-openmpi:master
50   tags: []
51   needs:
52     - job: clang-tidy:configure-push
53   variables:
54     COMPILER_MAJOR_VERSION: 9
55     BUILD_DIR: build-clang-tidy
56     EXTRA_INSTALLS: clang-tidy-$COMPILER_MAJOR_VERSION
57     KUBERNETES_CPU_LIMIT: 4
58     KUBERNETES_CPU_REQUEST: 2
59     KUBERNETES_MEMORY_LIMIT: 4Gi
60   script:
61     # TODO (issue #3272) `master` is not appropriate for use on release-xxxx branches, how should we handle that?
62     # See discussion at https://gitlab.com/gromacs/gromacs/-/merge_requests/67
63     - REV=$(git fetch -q https://gitlab.com/gromacs/gromacs.git master && git show -s --pretty=format:"%h" `git merge-base FETCH_HEAD HEAD`)
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 -iq "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:master
80   tags: []
81   variables:
82     COMPILER_MAJOR_VERSION: 7
83     KUBERNETES_CPU_LIMIT: 1
84     KUBERNETES_CPU_REQUEST: 1
85     KUBERNETES_MEMORY_LIMIT: 2Gi
86     EXTRA_INSTALLS: clang-format-$COMPILER_MAJOR_VERSION
87   script:
88     - export CLANG_FORMAT=clang-format-$COMPILER_MAJOR_VERSION
89     - admin/clang-format.sh check --rev=HEAD^ --warnings=clang-format.log
90     - grep -iq "needs formatting" clang-format.log | tee formatting.txt || true
91     - if [ -s formatting.txt ] ; then echo "clang-format.sh found issues"; exit 1; fi
92   artifacts:
93     when: on_failure
94     paths:
95       - clang-format.log
96       - formatting.txt
97
98 copyright-check:
99   extends:
100     - .variables:default
101     - .rules:basic-push
102   cache: {}
103   stage: pre-build
104   image: gromacs/ci-docs-llvm:master
105   tags: []
106   variables:
107     KUBERNETES_CPU_LIMIT: 1
108     KUBERNETES_CPU_REQUEST: 1
109     KUBERNETES_MEMORY_LIMIT: 2Gi
110   script:
111     - admin/copyright.sh check --rev=HEAD^ --warnings=copyright.log
112     - grep -iq "copyright year" copyright.log | tee years.log || true
113     - grep -iq "copyright header" copyright.log | tee headers.log || true
114     - if [[ -s years.log || -s headers.log ]] ; then
115       echo "Copyright information needs updating" ;
116       exit 1 ;
117       fi
118   artifacts:
119     when: on_failure
120     paths:
121       - copyright.log
122       - years.log
123       - headers.log
124
125 check-source:
126   extends:
127     - .variables:default
128     - .docs:build
129     - .before_script:default
130     - .rules:basic-push
131   cache: {}
132   stage: source-check
133   tags: []
134   needs:
135     - job: docs:build
136       artifacts: true
137   variables:
138     KUBERNETES_CPU_LIMIT: 1
139     KUBERNETES_CPU_REQUEST: 1
140     KUBERNETES_MEMORY_LIMIT: 2Gi
141     BUILD_DIR: build-docs
142   script:
143     - cd $BUILD_DIR
144     - cmake --build . --target check-source
145     - grep -qi "error" docs/doxygen/doxygen*log docs/doxygen/check-source.log | tee doxygenError.txt || true
146     - grep -qi "warning" docs/doxygen/doxygen*log docs/doxygen/check-source.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