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