3758efa4be12c4ed2dc25f88cff4ae9e8b309e5a
[alexxy/gromacs.git] / admin / gitlab-ci / lint.gitlab-ci.yml
1 # Repository cleanliness. Source tidiness, linting, and policy compliance.
2
3 configure-clang-tidy:
4   extends:
5     - .configure-clang
6     - .clang7-template
7   needs:
8     - job: simple-build
9       artifacts: false
10   variables:
11     BUILD_DIR: build-clang-tidy
12     COMPILER_MAJOR_VERSION: 7
13     CMAKE_EXTRA_OPTIONS: -DCLANG_TIDY=clang-tidy-$COMPILER_MAJOR_VERSION -DGMX_CLANG_TIDY=ON -DGMX_COMPILER_WARNINGS=ON
14     EXTRA_INSTALLS: clang-tidy-$COMPILER_MAJOR_VERSION
15   except:
16     variables:
17       - $GROMACS_RELEASE
18
19 build-clang-tidy:
20   extends:
21     - .build-clang
22     - .clang7-template
23   stage: source-check
24   needs:
25     - job: simple-build
26       artifacts: false
27     - job: configure-clang-tidy
28       artifacts: true
29   variables:
30     BUILD_DIR: build-clang-tidy
31     COMPILER_MAJOR_VERSION: 7
32     EXTRA_INSTALLS: clang-tidy-$COMPILER_MAJOR_VERSION
33   except:
34     variables:
35       - $GROMACS_RELEASE
36
37 run-clang-format:
38   extends:
39     - .binary-build-template
40     - .no-cache-template
41     - .variables:default
42     - .clang-before-script-template
43     - .build-clang-template
44     - .clang7-template
45   stage: source-check
46   when: always
47   needs:
48     - job: simple-build
49       artifacts: false
50   variables:
51     KUBERNETES_CPU_LIMIT: 1
52     KUBERNETES_CPU_REQUEST: 1
53     KUBERNETES_MEMORY_LIMIT: 2Gi
54     COMPILER_MAJOR_VERSION: 7
55     EXTRA_INSTALLS: clang-format-$COMPILER_MAJOR_VERSION
56   except:
57     variables:
58       - $GROMACS_RELEASE
59   script:
60     - export CLANG_FORMAT=clang-format-$COMPILER_MAJOR_VERSION
61     - admin/clang-format.sh check --rev=HEAD^ --warnings=clang-format.log
62     - grep -iq "needs formatting" clang-format.log | tee formatting.txt || true
63     - if [ -s formatting.txt ] ; then echo "clang-format.sh found issues"; exit 1; fi
64   artifacts:
65     when: on_failure
66     paths:
67       - clang-format.log
68       - formatting.txt
69
70 run-copyright-check:
71   extends:
72     - .binary-build-template
73     - .no-cache-template
74     - .variables:default
75     - .clang-before-script-template
76     - .build-clang-template
77     - .clang7-template
78   stage: source-check
79   when: always
80   needs:
81     - job: simple-build
82       artifacts: false
83   variables:
84     KUBERNETES_CPU_LIMIT: 1
85     KUBERNETES_CPU_REQUEST: 1
86     KUBERNETES_MEMORY_LIMIT: 2Gi
87   except:
88     variables:
89       - $GROMACS_RELEASE
90   script:
91     - admin/copyright.sh check --rev=HEAD^ --warnings=copyright.log
92     - grep -iq "copyright year" copyright.log | tee years.log || true
93     - grep -iq "copyright header" copyright.log | tee headers.log || true
94     - if [[ -s years.log || -s headers.log ]] ; then
95       echo "Copyright information needs updating" ;
96       exit 1 ;
97       fi
98   artifacts:
99     when: on_failure
100     paths:
101       - copyright.log
102       - years.log
103       - headers.log
104
105 run-check-source:
106   extends:
107     - .no-cache-template
108     - .variables:default
109     - .build-docs-binary-template
110     - .documentation-before-script-template
111   stage: source-check
112   needs:
113     - job: simple-build
114       artifacts: false
115     - job: build-docs
116       artifacts: true
117   variables:
118     KUBERNETES_CPU_LIMIT: 1
119     KUBERNETES_CPU_REQUEST: 1
120     KUBERNETES_MEMORY_LIMIT: 2Gi
121     BUILD_DIR: build-docs
122     COMPILER_MAJOR_VERSION: 7
123   except:
124     variables:
125       - $GROMACS_RELEASE
126   script:
127     - cd $BUILD_DIR
128     - cmake --build . --target check-source
129     - grep -qi "error" docs/doxygen/doxygen*log docs/doxygen/check-source.log | tee doxygenError.txt || true
130     - grep -qi "warning" docs/doxygen/doxygen*log docs/doxygen/check-source.log | tee -a doxygenError.txt || true
131     - if [ -s doxygenError.txt ] ; then echo "Found errors while running doxygen"; exit 1; fi
132   artifacts:
133     name: docs-artifacts-$CI_COMMIT_REF_SLUG
134     when: always
135     expire_in: 1 week
136     paths:
137       - $BUILD_DIR/docs/doxygen/doxygen-xml.log
138       - $BUILD_DIR/docs/doxygen/check-source.log
139
140 linkchecker:
141   extends:
142     - .build-docs-webpage
143   stage: nightly-build
144   dependencies:
145     - webpage-gmxapi
146   only:
147     - schedules
148     - triggers
149     - merge_requests
150     - external_pull_requests
151   except:
152     variables:
153       - $GROMACS_RELEASE
154   variables:
155     KUBERNETES_CPU_LIMIT: 1
156     KUBERNETES_CPU_REQUEST: 1
157     KUBERNETES_MEMORY_LIMIT: 2Gi
158     BUILD_DIR: build-docs-gmxapi
159   script:
160     - cd $BUILD_DIR
161     - linkchecker docs/html/index.html -f ../docs/linkcheckerrc -Fxml --ignore-url html-full
162       --ignore-url html-user --ignore-url html-lib --ignore-url .tar.gz --ignore-url _sources
163       -o xml
164   artifacts:
165     reports:
166       junit: $BUILD_DIR/linkchecker-out.xml