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