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