Allow useful CI to run in forks
[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-clang7
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-clang7
22     - .rules:not-for-release
23   stage: source-check
24   needs:
25     - job: clang-tidy:configure
26       artifacts: true
27   variables:
28     BUILD_DIR: build-clang-tidy
29     EXTRA_INSTALLS: clang-tidy-$COMPILER_MAJOR_VERSION
30
31 clang-format:
32   extends:
33     - .variables:default
34     - .use-clang7
35     - .rules:basic
36   cache: {}
37   stage: pre-build
38   tags: []
39   variables:
40     KUBERNETES_CPU_LIMIT: 1
41     KUBERNETES_CPU_REQUEST: 1
42     KUBERNETES_MEMORY_LIMIT: 2Gi
43     EXTRA_INSTALLS: clang-format-$COMPILER_MAJOR_VERSION
44   script:
45     - export CLANG_FORMAT=clang-format-$COMPILER_MAJOR_VERSION
46     - admin/clang-format.sh check --rev=HEAD^ --warnings=clang-format.log
47     - grep -iq "needs formatting" clang-format.log | tee formatting.txt || true
48     - if [ -s formatting.txt ] ; then echo "clang-format.sh found issues"; exit 1; fi
49   artifacts:
50     when: on_failure
51     paths:
52       - clang-format.log
53       - formatting.txt
54
55 copyright-check:
56   extends:
57     - .variables:default
58     - .use-clang7
59     - .rules:basic
60   cache: {}
61   stage: pre-build
62   tags: []
63   variables:
64     KUBERNETES_CPU_LIMIT: 1
65     KUBERNETES_CPU_REQUEST: 1
66     KUBERNETES_MEMORY_LIMIT: 2Gi
67   script:
68     - admin/copyright.sh check --rev=HEAD^ --warnings=copyright.log
69     - grep -iq "copyright year" copyright.log | tee years.log || true
70     - grep -iq "copyright header" copyright.log | tee headers.log || true
71     - if [[ -s years.log || -s headers.log ]] ; then
72       echo "Copyright information needs updating" ;
73       exit 1 ;
74       fi
75   artifacts:
76     when: on_failure
77     paths:
78       - copyright.log
79       - years.log
80       - headers.log
81
82 check-source:
83   extends:
84     - .variables:default
85     - .docs:build
86     - .before_script:default
87     - .rules:not-for-release
88   cache: {}
89   stage: source-check
90   needs:
91     - job: docs:build
92       artifacts: true
93   variables:
94     KUBERNETES_CPU_LIMIT: 1
95     KUBERNETES_CPU_REQUEST: 1
96     KUBERNETES_MEMORY_LIMIT: 2Gi
97     BUILD_DIR: build-docs
98   script:
99     - cd $BUILD_DIR
100     - cmake --build . --target check-source
101     - grep -qi "error" docs/doxygen/doxygen*log docs/doxygen/check-source.log | tee doxygenError.txt || true
102     - grep -qi "warning" docs/doxygen/doxygen*log docs/doxygen/check-source.log | tee -a doxygenError.txt || true
103     - if [ -s doxygenError.txt ] ; then echo "Found errors while running doxygen"; exit 1; fi
104   artifacts:
105     name: docs-artifacts-$CI_COMMIT_REF_SLUG
106     when: always
107     expire_in: 1 week
108     paths:
109       - $BUILD_DIR/docs/doxygen/doxygen-xml.log
110       - $BUILD_DIR/docs/doxygen/check-source.log
111
112 linkchecker:
113   extends:
114     - .webpage:build
115     - .rules:nightly-not-for-release
116   stage: nightly-build
117   dependencies:
118     - webpage:build
119   variables:
120     KUBERNETES_CPU_LIMIT: 1
121     KUBERNETES_CPU_REQUEST: 1
122     KUBERNETES_MEMORY_LIMIT: 2Gi
123     BUILD_DIR: build-docs
124   script:
125     - cd $BUILD_DIR
126     - linkchecker docs/html/index.html -f $CI_PROJECT_DIR/docs/linkcheckerrc -Fxml --ignore-url html-full
127       --ignore-url html-user --ignore-url html-lib --ignore-url .tar.gz --ignore-url _sources
128       -o xml
129   artifacts:
130     reports:
131       junit: $BUILD_DIR/linkchecker-out.xml