1b12c5d628df2f6d1ea7e8e20de101f16fde4a9a
[alexxy/gromacs.git] / admin / gitlab-ci / lint.gitlab-ci.yml
1 # Repository cleanliness. Source tidiness, linting, and policy compliance.
2
3 build-clang-tidy:
4   extends:
5     - .build-clang
6     - .clang7-template
7   stage: source-check
8   needs:
9     - job: simple-build
10       artifacts: false
11     - job: configure-clang-tidy
12       artifacts: true
13   variables:
14     BUILD_DIR: build-clang-tidy
15     COMPILER_MAJOR_VERSION: 7
16     EXTRA_INSTALLS: clang-tidy-$COMPILER_MAJOR_VERSION
17   except:
18     variables:
19       - $GROMACS_RELEASE
20
21 run-clang-format:
22   extends:
23     - .binary-build-template
24     - .no-cache-template
25     - .variables-template
26     - .clang-before-script-template
27     - .build-clang-template
28     - .clang7-template
29   stage: source-check
30   when: always
31   needs:
32     - job: simple-build
33       artifacts: false
34   variables:
35     KUBERNETES_CPU_LIMIT: 1
36     KUBERNETES_CPU_REQUEST: 1
37     KUBERNETES_MEMORY_LIMIT: 2Gi
38     COMPILER_MAJOR_VERSION: 7
39     EXTRA_INSTALLS: clang-format-$COMPILER_MAJOR_VERSION
40   except:
41     variables:
42       - $GROMACS_RELEASE
43   script:
44     - export CLANG_FORMAT=clang-format-$COMPILER_MAJOR_VERSION
45     - admin/clang-format.sh check --rev=HEAD^ --warnings=clang-format.log
46     - grep -iq "needs formatting" clang-format.log | tee formatting.txt || true
47     - if [ -s formatting.txt ] ; then echo "clang-format.sh found issues"; exit 1; fi
48   artifacts:
49     when: on_failure
50     paths:
51       - clang-format.log
52       - formatting.txt
53
54 run-copyright-check:
55   extends:
56     - .binary-build-template
57     - .no-cache-template
58     - .variables-template
59     - .clang-before-script-template
60     - .build-clang-template
61     - .clang7-template
62   stage: source-check
63   when: always
64   needs:
65     - job: simple-build
66       artifacts: false
67   variables:
68     KUBERNETES_CPU_LIMIT: 1
69     KUBERNETES_CPU_REQUEST: 1
70     KUBERNETES_MEMORY_LIMIT: 2Gi
71   except:
72     variables:
73       - $GROMACS_RELEASE
74   script:
75     - admin/copyright.sh check --rev=HEAD^ --warnings=copyright.log
76     - grep -iq "copyright year" copyright.log | tee years.log || true
77     - grep -iq "copyright header" copyright.log | tee headers.log || true
78     - if [[ -s years.log || -s headers.log ]] ; then
79       echo "Copyright information needs updating" ;
80       exit 1 ;
81       fi
82   artifacts:
83     when: on_failure
84     paths:
85       - copyright.log
86       - years.log
87       - headers.log
88
89 run-check-source:
90   extends:
91     - .no-cache-template
92     - .variables-template
93     - .build-docs-binary-template
94     - .documentation-before-script-template
95   stage: source-check
96   needs:
97     - job: simple-build
98       artifacts: false
99     - job: build-docs
100       artifacts: true
101   variables:
102     KUBERNETES_CPU_LIMIT: 1
103     KUBERNETES_CPU_REQUEST: 1
104     KUBERNETES_MEMORY_LIMIT: 2Gi
105     BUILD_DIR: build-docs
106     COMPILER_MAJOR_VERSION: 7
107   except:
108     variables:
109       - $GROMACS_RELEASE
110   script:
111     - cd $BUILD_DIR
112     - cmake --build . --target check-source
113     - grep -qi "error" docs/doxygen/doxygen*log docs/doxygen/check-source.log | tee doxygenError.txt || true
114     - grep -qi "warning" docs/doxygen/doxygen*log docs/doxygen/check-source.log | tee -a doxygenError.txt || true
115     - if [ -s doxygenError.txt ] ; then echo "Found errors while running doxygen"; exit 1; fi
116   artifacts:
117     name: docs-artifacts-$CI_COMMIT_REF_SLUG
118     when: always
119     expire_in: 1 week
120     paths:
121       - $BUILD_DIR/docs/doxygen/doxygen-xml.log
122       - $BUILD_DIR/docs/doxygen/check-source.log