CI: Update packer cloud setting to use HCL2 file
[ci-management.git] / jjb / doc / rules.yaml
1 ---
2 - scm:
3     name: doc-scm
4     scm:
5       - git:
6           url: "https://gerrit.onap.org/r/{project}"
7           refspec: "+refs/heads/*:refs/remotes/origin/* +refs/changes/*:refs/changes/*"
8           branches:
9             - "{ref}"
10
11 - trigger:
12     name: doc-rules-patchset-created
13     triggers:
14       - gerrit:
15           trigger-on:
16             - patchset-created-event
17             - comment-added-contains-event:
18                 comment-contains-value: recheck
19             - comment-added-contains-event:
20                 comment-contains-value: reverify
21           server-name: "Primary"
22           projects:
23             - project-compare-type: "ANT"
24               project-pattern: "**"
25               branches:
26                 - branch-compare-type: "ANT"
27                   branch-pattern: "**/*"
28                 - branch-compare-type: "ANT"
29                   branch-pattern: "refs/tags/**"
30
31 - builder:
32     name: doc-rules
33     builders:
34       # yamllint disable rule:line-length
35       - shell: |
36           #!/bin/bash
37           . /lib/lsb/init-functions || exit 0
38           exitstatus="0"
39           warning="0"
40           # message, begin
41           log_success_msg "INFO doc-rules Version 23-07-07-A"
42           log_success_msg "INFO Starting additional checks related to documentation."
43           log_success_msg "INFO See https://git.onap.org/doc/doc-best-practice for example config files (master branch)."
44           log_success_msg "INFO Modify example config files if you like to use them in a release branch."
45           log_success_msg "INFO See https://wiki.onap.org/x/w4IEBw for the detailed procedure #02."
46           log_success_msg "INFO In case of questions please contact the ONAP documentation team."
47           # docs directory
48           if [ ! -d docs ] ; then
49             log_success_msg "INFO Directory docs not found. Skipping further checks."
50             exit 0
51           fi
52           # config files, required
53           for i in docs/index.rst docs/conf.py docs/requirements-docs.txt docs/_static/css/ribbon.css .readthedocs.yaml; do
54             if [ ! -f $i ] ; then
55               log_failure_msg "FAIL $i missing. Please add it or remove the full docs directory."
56               exitstatus="1"
57             else
58               log_success_msg "INFO $i found."
59             fi
60           done
61           # config files, no longer required
62           for i in docs/conf.yaml; do
63             if [ -f $i ] ; then
64               log_failure_msg "FAIL $i found. It is no longer required. Please remove it."
65               exitstatus="1"
66             else
67               log_success_msg "INFO $i not found."
68             fi
69           done
70           # tox.ini @ docs directory
71           filename="docs/tox.ini"
72           if [ ! -f $filename ] ; then
73             log_failure_msg "FAIL $filename missing. Please add it or remove the full docs directory."
74             exitstatus="1"
75           else
76             log_success_msg "INFO $filename found."
77             # sphinx-build command and -W option
78             sphinxbuild_detected=0
79             linenumber=0
80             while IFS="" read -r line || [ -n "$line" ] ; do
81               linenumber=$((linenumber+1))
82               if echo $line | grep -q '^[ \t]*sphinx-build.*' ; then
83                 sphinxbuild_detected="1"
84                 if echo $line | grep -q '^[ \t]*sphinx-build.* -W ' ; then
85                   log_success_msg "INFO sphinx-build option '-W' used in $filename, line $linenumber."
86                 elif echo $line | grep -q ' \-b spelling ' ; then
87                   log_warning_msg "WARN sphinx-build option '-W' missing for spellcheck in $filename, line $linenumber."
88                   warning="1"
89                 else
90                   log_warning_msg "WARN sphinx-build option '-W' missing in $filename, line $linenumber. Please add it."
91                   warning="1"
92                   #log_failure_msg "FAIL sphinx-build option '-W' missing in $filename, line $linenumber. Please add it."
93                   #exitstatus="1"
94                 fi
95               fi
96             done < $filename
97             if [ "$sphinxbuild_detected" = "0" ]; then
98               log_warning_msg "WARN Sphinx-build command(s) missing in $filename. Please add it."
99               warning="1"
100               #log_failure_msg "FAIL Sphinx-build command(s) missing in $filename. Please add it."
101               #exitstatus="1"
102             fi
103             # second tox.ini @ root directory
104             if [ -f ./tox.ini ] ; then
105               # sphinx-build command
106               if cat ./tox.ini | grep -q '^[ \t]*sphinx-build.*' ; then
107                 log_warning_msg "WARN tox.ini also exists in root directory and contains sphinx-build command(s). Please check for redundancies."
108                 warning="1"
109               fi
110             fi
111             unset sphinxbuild_detected
112             unset linenumber
113           fi
114           unset filename
115           # ribbon.css
116           filename="docs/_static/css/ribbon.css"
117           if [ ! -f $filename ]; then
118             log_failure_msg "FAIL $filename missing. Please add it or remove the full docs directory."
119             exitstatus="1"
120           else
121             log_success_msg "INFO $filename found."
122             # max-width parameter
123             cssmaxwidth=$(grep '^[ \t]*max-width:' $filename | sed -e 's/^[ \t]*//' | sed -e 's/;$//');
124             if [[ ! $cssmaxwidth == *"max-width: 800px"* ]]; then
125               log_failure_msg "FAIL Setting 'max-width: 800px' missing in $filename. Please add it."
126               exitstatus="1"
127             else
128               log_success_msg "INFO Setting 'max-width: 800px' found in $filename."
129             fi
130             unset cssmaxwidth
131           fi
132           unset filename
133           # readthedocs.yaml
134           filename=".readthedocs.yaml"
135           if [ ! -f $filename ]; then
136             log_failure_msg "FAIL $filename missing. Please add it or remove the full docs directory."
137             exitstatus="1"
138           else
139             log_success_msg "INFO $filename found."
140             # obsolete parameter: (build:) image: latest
141             buildimage=$(grep '^[ \t]*image:' $filename | sed -e 's/^[ \t]*//' | sed -e 's/;$//');
142             if [[ $buildimage == *"latest"* ]]; then
143               log_failure_msg "FAIL Setting '(build: image:) latest' found in $filename. Please remove it."
144               exitstatus="1"
145             else
146               log_success_msg "INFO Setting '(build: image:) latest' not found in $filename."
147             fi
148             unset buildimage
149             # obsolete parameter: (python:) version: 3.7
150             pythonversion=$(grep '^[ \t]*version:' $filename | sed -e 's/^[ \t]*//' | sed -e 's/;$//');
151             if [[ $pythonversion == *"3.7"* ]]; then
152               log_failure_msg "FAIL Setting '(python:) version: 3.7' found in $filename. Please remove it."
153               exitstatus="1"
154             else
155               log_success_msg "INFO Setting '(python:) version: 3.7' not found in $filename."
156             fi
157             unset pythonversion
158             # obsolete parameter: submodules:
159             submodules=$(grep '^[ \t]*submodules:' $filename | sed -e 's/^[ \t]*//' | sed -e 's/;$//');
160             if [[ $submodules == *"submodules:"* ]]; then
161               log_failure_msg "FAIL Setting 'submodules:' found in $filename. Please remove it."
162               exitstatus="1"
163             else
164               log_success_msg "INFO Setting 'submodules:' not found in $filename."
165             fi
166             unset submodules
167             # required parameter: (build:) os:
168             buildos=$(grep '^[ \t]*os:' $filename | sed -e 's/^[ \t]*//' | sed -e 's/;$//');
169             if [[ ! $buildos == *"ubuntu-20.04"* ]]; then
170               log_failure_msg "FAIL Setting '(build:) os: ubuntu-20.04' missing in $filename. Please add it."
171               exitstatus="1"
172             else
173               log_success_msg "INFO Setting '(build:) os: ubuntu-20.04' found in $filename."
174             fi
175             unset buildos
176             # required parameter: (build: tools:) python
177             buildtoolspython=$(grep '^[ \t]*python:' $filename | sed -e 's/^[ \t]*//' | sed -e 's/;$//');
178             if [[ ! $buildtoolspython == *\"3.8\"* ]]; then
179               log_failure_msg "FAIL Setting '(build: tools:) python: \"3.8\"' missing in $filename. Please add it."
180               exitstatus="1"
181             else
182               log_success_msg "INFO Setting '(build: tools:) python: \"3.8\"' found in $filename."
183             fi
184             unset buildtoolspython
185           fi
186           unset filename
187           # message, end
188           if [ "$exitstatus" = "0" ]; then
189             if [ "$warning" = "0" ]; then
190               log_success_msg "INFO Congratulations! No documentation problem(s) detected."
191             else
192               log_warning_msg "WARN No major documentation problem(s) detected but there are warnings!"
193             fi
194           else
195             if [ ! "$warning" = "0" ]; then
196               log_warning_msg "WARN Please check the detected documentation warning(s)!"
197             fi
198             log_failure_msg "FAIL Please fix the detected documentation problem(s)!"
199           fi
200           exit $exitstatus
201       # yamllint enable
202
203 - job-template:
204     name: doc-rules
205     node: ubuntu1804-docker-8c-8g
206     triggers:
207       - doc-rules-patchset-created
208     scm:
209       - doc-scm:
210           ref: $GERRIT_REFSPEC
211           project: $GERRIT_PROJECT
212     builders:
213       - doc-rules
214
215 - project:
216     name: "doc-rules"
217     jobs:
218       - "doc-rules"