Fix copyright check
[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: ${CI_REGISTRY}/gromacs/gromacs/ci-ubuntu-18.04-llvm-9:release-2021
9   variables:
10     CMAKE: /usr/local/cmake-3.15.7/bin/cmake
11     COMPILER_MAJOR_VERSION: 9
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: ${CI_REGISTRY}/gromacs/gromacs/ci-ubuntu-18.04-llvm-9:release-2021
21   variables:
22     CMAKE: /usr/local/cmake-3.15.7/bin/cmake
23     COMPILER_MAJOR_VERSION: 9
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: ${CI_REGISTRY}/gromacs/gromacs/ci-ubuntu-18.04-llvm-9:release-2021
35   needs:
36     - job: clang-tidy:configure-schedule
37   variables:
38     CMAKE: /usr/local/cmake-3.15.7/bin/cmake
39     BUILD_DIR: build-clang-tidy
40
41 clang-tidy:test:
42   extends:
43     - .gromacs:base:build
44     - .variables:default
45     - .rules:basic-push
46   stage: source-check
47   image: ${CI_REGISTRY}/gromacs/gromacs/ci-ubuntu-18.04-llvm-9:release-2021
48   needs:
49     - job: clang-tidy:configure-push
50   variables:
51     CMAKE: /usr/local/cmake-3.15.7/bin/cmake
52     COMPILER_MAJOR_VERSION: 9
53     BUILD_DIR: build-clang-tidy
54     EXTRA_INSTALLS: clang-tidy-$COMPILER_MAJOR_VERSION
55     KUBERNETES_CPU_LIMIT: 4
56     KUBERNETES_CPU_REQUEST: 2
57     KUBERNETES_MEMORY_REQUEST: 4Gi
58   script:
59     # Make sure that a Python interpreter can be found for `/bin/env python`
60     - test -x /usr/bin/python || update-alternatives --install /usr/bin/python python /usr/bin/python3 1
61     # TODO (issue #3272) `master` is not appropriate for use on release-xxxx branches, how should we handle that?
62     - REV=$(git fetch -q https://gitlab.com/gromacs/gromacs.git release-2021 && git show -s --pretty=format:"%h" `git merge-base FETCH_HEAD HEAD`)
63     - HEAD_REV=$(git show -s --pretty=format:"%h" HEAD)
64     - if [[ "$REV" == "$HEAD_REV" ]] ; then
65         REV="HEAD~1" ;
66       fi
67     - echo "Revision used for branch point is $REV"
68     - git show -s $REV
69     - 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
70     - grep -i "found code issues" clang-tidy.log | tee code-lint.txt || true
71     - if [ -s code-lint.txt ] ; then echo "clang-tidy.sh found issues"; exit 1; fi
72   artifacts:
73     when: on_failure
74     paths:
75       - clang-tidy.log
76       - code-lint.txt
77
78 clang-format:
79   extends:
80     - .variables:default
81     - .rules:basic-push
82   cache: {}
83   stage: pre-build
84   image: ${CI_REGISTRY}/gromacs/gromacs/ci-ubuntu-18.04-llvm-7-docs:release-2021
85   variables:
86     COMPILER_MAJOR_VERSION: 7
87     KUBERNETES_CPU_LIMIT: 1
88     KUBERNETES_CPU_REQUEST: 1
89     KUBERNETES_MEMORY_REQUEST: 2Gi
90     EXTRA_INSTALLS: clang-format-$COMPILER_MAJOR_VERSION
91   script:
92     - REV=$(git fetch -q https://gitlab.com/gromacs/gromacs.git release-2021 && git show -s --pretty=format:"%h" `git merge-base FETCH_HEAD HEAD`)
93     - HEAD_REV=$(git show -s --pretty=format:"%h" HEAD)
94     - if [[ "$REV" == "$HEAD_REV" ]] ; then
95         REV="HEAD~1" ;
96       fi
97     - echo "Revision used for branch point is $REV"
98     - git show -s $REV
99     - CLANG_FORMAT=clang-format-$COMPILER_MAJOR_VERSION admin/clang-format.sh check --rev=$REV --warnings=clang-format.log
100     - grep -i "needs formatting" clang-format.log | tee formatting.txt || true
101     - if [ -s formatting.txt ] ; then echo "clang-format.sh found issues"; exit 1; fi
102   artifacts:
103     when: on_failure
104     paths:
105       - clang-format.log
106       - formatting.txt
107
108 copyright-check:
109   extends:
110     - .variables:default
111     - .rules:basic-push
112   cache: {}
113   stage: pre-build
114   image: ${CI_REGISTRY}/gromacs/gromacs/ci-ubuntu-18.04-llvm-7-docs:release-2021
115   variables:
116     KUBERNETES_CPU_LIMIT: 1
117     KUBERNETES_CPU_REQUEST: 1
118     KUBERNETES_MEMORY_REQUEST: 2Gi
119   script:
120     - REV=$(git fetch -q https://gitlab.com/gromacs/gromacs.git release-2021 && git show -s --pretty=format:"%h" `git merge-base FETCH_HEAD HEAD`)
121     - HEAD_REV=$(git show -s --pretty=format:"%h" HEAD)
122     - if [[ "$REV" == "$HEAD_REV" ]] ; then
123         REV="HEAD~1" ;
124       fi
125     - echo "Revision used for branch point is $REV"
126     - git show -s $REV
127     - admin/copyright.sh check --rev=$REV --warnings=copyright.log
128     - grep -i "copyright year" copyright.log | tee years.log || true
129     - grep -i "copyright header" copyright.log | tee headers.log || true
130     - if [[ -s years.log || -s headers.log ]] ; then
131       echo "Copyright information needs updating" ;
132       exit 1 ;
133       fi
134   artifacts:
135     when: on_failure
136     paths:
137       - copyright.log
138       - years.log
139       - headers.log
140
141 check-source:
142   extends:
143     - .variables:default
144     - .docs:build
145     - .before_script:default
146     - .rules:basic-push
147   cache: {}
148   stage: source-check
149   needs:
150     - job: docs:build
151       artifacts: true
152   variables:
153     KUBERNETES_CPU_LIMIT: 1
154     KUBERNETES_CPU_REQUEST: 1
155     KUBERNETES_MEMORY_REQUEST: 2Gi
156     BUILD_DIR: build-docs
157   script:
158     - CMAKE=${CMAKE:-$(which cmake)}
159     - cd $BUILD_DIR
160     - $CMAKE --build . --target check-source
161     - awk '/warning.*include style.*order/,/You can use.*rst|^$/' docs/doxygen/check-source.log | tee doxygenError.txt || true
162     - awk '/warning:.*includes/,/unnecessarily|^$/' docs/doxygen/check-source.log | tee -a doxygenError.txt || true
163     - awk '/Traceback/,/.*rror|^$/' docs/doxygen/doxygen*log docs/doxygen/check-source.log | tee -a doxygenError.txt || true
164     - awk '/warning:/,/in doxygen.*|^$/' docs/doxygen/doxygen*log | tee -a doxygenError.txt || true
165     - grep -i "unused cycle suppression" docs/doxygen/check-source.log | tee -a doxygenError.txt || true
166     - if [ -s doxygenError.txt ] ; then echo "Found errors while running doxygen"; exit 1; fi
167   artifacts:
168     name: docs-artifacts-$CI_COMMIT_REF_SLUG
169     when: always
170     expire_in: 1 week
171     paths:
172       - $BUILD_DIR/docs/doxygen/doxygen-xml.log
173       - $BUILD_DIR/docs/doxygen/check-source.log
174
175 linkchecker:
176   extends:
177     - .webpage:build
178     - .rules:nightly-not-for-release
179   stage: nightly-build
180   dependencies:
181     - webpage:build
182   variables:
183     KUBERNETES_CPU_LIMIT: 1
184     KUBERNETES_CPU_REQUEST: 1
185     KUBERNETES_MEMORY_REQUEST: 2Gi
186     BUILD_DIR: build-docs
187   script:
188     - cd $BUILD_DIR
189     - linkchecker docs/html/index.html -f $CI_PROJECT_DIR/docs/linkcheckerrc -Fxml --ignore-url html-full
190       --ignore-url html-user --ignore-url html-lib --ignore-url .tar.gz --ignore-url _sources
191       -o xml
192   artifacts:
193     reports:
194       junit: $BUILD_DIR/linkchecker-out.xml