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