Update to clang-tidy-9
[alexxy/gromacs.git] / admin / gitlab-ci / lint.gitlab-ci.yml
1 # Repository cleanliness. Source tidiness, linting, and policy compliance.
2
3 clang-tidy:configure:
4   extends:
5     - .gromacs:base:configure
6     - .use-clang9
7     - .rules:not-for-release
8   dependencies: []
9   variables:
10     BUILD_DIR: build-clang-tidy
11     CMAKE_EXTRA_OPTIONS: -DCLANG_TIDY=clang-tidy-$COMPILER_MAJOR_VERSION -DGMX_CLANG_TIDY=ON -DGMX_COMPILER_WARNINGS=ON
12     EXTRA_INSTALLS: clang-tidy-$COMPILER_MAJOR_VERSION
13     CMAKE_GMXAPI_OPTIONS: "-DGMX_PYTHON_PACKAGE=OFF"
14   # TODO: Enable GMX_PYTHON_PACKAGE for clang-tidy when dependencies are in Docker image.
15
16 clang-tidy:build:
17   extends:
18     - .gromacs:base:build
19     - .use-ccache
20     - .variables:default
21     - .use-clang9
22     - .rules:nightly-not-for-release
23   stage: source-check
24   needs:
25     - job: clang-tidy:configure
26   variables:
27     BUILD_DIR: build-clang-tidy
28     EXTRA_INSTALLS: clang-tidy-$COMPILER_MAJOR_VERSION
29
30 clang-tidy:test:
31   extends:
32     - .gromacs:base:build
33     - .use-ccache
34     - .variables:default
35     - .use-clang9
36     - .rules:not-for-release
37   stage: source-check
38   needs:
39     - job: clang-tidy:configure
40   variables:
41     BUILD_DIR: build-clang-tidy
42     EXTRA_INSTALLS: clang-tidy-$COMPILER_MAJOR_VERSION
43     KUBERNETES_CPU_LIMIT: 4
44     KUBERNETES_CPU_REQUEST: 2
45     KUBERNETES_MEMORY_LIMIT: 4Gi
46   script:
47     # TODO (issue #3272) `master` is not appropriate for use on release-xxxx branches, how should we handle that?
48     # See discussion at https://gitlab.com/gromacs/gromacs/-/merge_requests/67
49     - REV=$(git fetch -q https://gitlab.com/gromacs/gromacs.git master && git show -s --pretty=format:"%h" `git merge-base FETCH_HEAD HEAD`)
50     - 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
51     - grep -iq "found code issues" clang-tidy.log | tee code-lint.txt || true
52     - if [ -s code-lint.txt ] ; then echo "clang-tidy.sh found issues"; exit 1; fi
53   artifacts:
54     when: on_failure
55     paths:
56       - clang-tidy.log
57       - code-lint.txt
58
59 clang-format:
60   extends:
61     - .variables:default
62     - .use-clang7
63     - .rules:basic
64   cache: {}
65   stage: pre-build
66   tags: []
67   variables:
68     KUBERNETES_CPU_LIMIT: 1
69     KUBERNETES_CPU_REQUEST: 1
70     KUBERNETES_MEMORY_LIMIT: 2Gi
71     EXTRA_INSTALLS: clang-format-$COMPILER_MAJOR_VERSION
72   script:
73     - export CLANG_FORMAT=clang-format-$COMPILER_MAJOR_VERSION
74     - admin/clang-format.sh check --rev=HEAD^ --warnings=clang-format.log
75     - grep -iq "needs formatting" clang-format.log | tee formatting.txt || true
76     - if [ -s formatting.txt ] ; then echo "clang-format.sh found issues"; exit 1; fi
77   artifacts:
78     when: on_failure
79     paths:
80       - clang-format.log
81       - formatting.txt
82
83 copyright-check:
84   extends:
85     - .variables:default
86     - .use-clang7
87     - .rules:basic
88   cache: {}
89   stage: pre-build
90   tags: []
91   variables:
92     KUBERNETES_CPU_LIMIT: 1
93     KUBERNETES_CPU_REQUEST: 1
94     KUBERNETES_MEMORY_LIMIT: 2Gi
95   script:
96     - admin/copyright.sh check --rev=HEAD^ --warnings=copyright.log
97     - grep -iq "copyright year" copyright.log | tee years.log || true
98     - grep -iq "copyright header" copyright.log | tee headers.log || true
99     - if [[ -s years.log || -s headers.log ]] ; then
100       echo "Copyright information needs updating" ;
101       exit 1 ;
102       fi
103   artifacts:
104     when: on_failure
105     paths:
106       - copyright.log
107       - years.log
108       - headers.log
109
110 check-source:
111   extends:
112     - .variables:default
113     - .docs:build
114     - .before_script:default
115     - .rules:not-for-release
116   cache: {}
117   stage: source-check
118   needs:
119     - job: docs:build
120       artifacts: true
121   variables:
122     KUBERNETES_CPU_LIMIT: 1
123     KUBERNETES_CPU_REQUEST: 1
124     KUBERNETES_MEMORY_LIMIT: 2Gi
125     BUILD_DIR: build-docs
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     - .webpage:build
143     - .rules:nightly-not-for-release
144   stage: nightly-build
145   dependencies:
146     - webpage:build
147   variables:
148     KUBERNETES_CPU_LIMIT: 1
149     KUBERNETES_CPU_REQUEST: 1
150     KUBERNETES_MEMORY_LIMIT: 2Gi
151     BUILD_DIR: build-docs
152   script:
153     - cd $BUILD_DIR
154     - linkchecker docs/html/index.html -f $CI_PROJECT_DIR/docs/linkcheckerrc -Fxml --ignore-url html-full
155       --ignore-url html-user --ignore-url html-lib --ignore-url .tar.gz --ignore-url _sources
156       -o xml
157   artifacts:
158     reports:
159       junit: $BUILD_DIR/linkchecker-out.xml