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