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