Chore: Add Thomas Kulik as ci-man committer
[ci-management.git] / jjb / doc / rules.yaml
1 - scm:
2     name: doc-scm
3     scm:
4       - git:
5           url: 'https://gerrit.onap.org/r/{project}'
6           refspec: '+refs/heads/*:refs/remotes/origin/* +refs/changes/*:refs/changes/*'
7           branches:
8             - '{ref}'
9
10 - trigger:
11     name: doc-rules-patchset-created
12     triggers:
13       - gerrit:
14           trigger-on:
15             - patchset-created-event
16             - comment-added-contains-event:
17                 comment-contains-value: recheck
18             - comment-added-contains-event:
19                 comment-contains-value: reverify
20           server-name: 'Primary'
21           projects:
22             - project-compare-type: 'ANT'
23               project-pattern: '**'
24               branches:
25                 - branch-compare-type: 'ANT'
26                   branch-pattern: '**/*'
27                 - branch-compare-type: 'ANT'
28                   branch-pattern: 'refs/tags/**'
29
30 - builder:
31     name: doc-rules
32     builders:
33       - shell: |
34           #!/bin/bash
35           . /lib/lsb/init-functions || exit 0
36           exitstatus="0"
37           warning="0"
38           log_success_msg "Starting additional checks related to documentation."
39           log_success_msg "See https://git.onap.org/doc/doc-best-practice for example config files (master branch)."
40           log_success_msg "Modify example config files if you like to use them in a release branch."
41           log_success_msg "See https://wiki.onap.org/x/w4IEBw for the detailed procedure #02."
42           log_success_msg "In case of questions please contact the ONAP documentation team."
43           if [ ! -d docs ] ; then
44             log_success_msg "Directory docs not found. Skipping further checks."
45             exit 0
46           fi
47           for i in docs/index.rst docs/conf.py docs/requirements-docs.txt docs/_static/css/ribbon.css; do
48             if [ ! -f $i ] ; then
49               log_failure_msg "$i missing. Please add it or remove the full docs directory."
50               exitstatus="1"
51             else
52               log_success_msg "$i found."
53             fi
54           done
55           for i in docs/conf.yaml; do
56             if [ -f $i ] ; then
57               log_failure_msg "$i found. It is no longer required. Please remove it."
58               exitstatus="1"
59             else
60               log_success_msg "$i not found."
61             fi
62           done
63           filename="docs/tox.ini"
64           if [ ! -f $filename ] ; then
65               log_failure_msg "$filename missing. Please add it or remove the full docs directory."
66               exitstatus="1"
67           else
68               log_success_msg "$filename found."
69               sphinxbuild_detected=0
70               linenumber=0
71               while IFS="" read -r line || [ -n "$line" ] ; do
72                   linenumber=$((linenumber+1))
73                   if echo $line | grep -q '^[ \t]*sphinx-build.*' ; then
74                   sphinxbuild_detected="1"
75                       if echo $line | grep -q '^[ \t]*sphinx-build.* -W ' ; then
76                           log_success_msg "sphinx-build option '-W' used in $filename, line $linenumber."
77                       elif echo $line | grep -q ' \-b spelling ' ; then
78                           log_success_msg "sphinx-build option '-W' not used for spellcheck in $filename, line $linenumber."
79                       else
80                           log_failure_msg "sphinx-build option '-W' missing in $filename, line $linenumber. Please add it."
81                           exitstatus="1"
82                       fi
83                   fi
84               done < $filename
85               if [ "$sphinxbuild_detected" = "0" ]; then
86                   log_failure_msg "Sphinx-build command(s) missing in $filename. Please add it."
87                   exitstatus="1"
88               fi
89               unset sphinxbuild_detected
90               unset linenumber
91           fi
92           unset filename
93           filename="docs/_static/css/ribbon.css"
94           if [ ! -f $filename ]; then
95               log_failure_msg "$filename missing. Please add it or remove the full docs directory."
96               exitstatus="1"
97           else
98               log_success_msg "$filename found."
99               cssmaxwidth=$(grep '^[ \t]*max-width:' $filename | sed -e 's/^[ \t]*//' | sed -e 's/;$//');
100               if [[ ! $cssmaxwidth == *"max-width: 800px"* ]]; then
101                   log_failure_msg "Setting 'max-width: 800px' missing in $filename. Please add it."
102                   exitstatus="1"
103               else
104                   log_success_msg "Setting 'max-width: 800px' found in $filename."
105               fi
106               unset cssmaxwidth
107           fi
108           unset filename
109           if [ "$exitstatus" = "0" ]; then
110               if [ "$warning" = "0" ]; then
111                   log_success_msg "Congratulations! No documentation problem(s) detected."
112               else
113                   log_failure_msg "WARN No major documentation problem(s) detected but there are warnings!"
114               fi
115           else
116               log_failure_msg "Please fix the detected documentation problem(s)!"
117           fi
118           exit $exitstatus
119
120 - job-template:
121     name: doc-rules
122     node: ubuntu1804-docker-8c-8g
123     triggers:
124       - doc-rules-patchset-created
125     scm:
126       - doc-scm:
127           ref: $GERRIT_REFSPEC
128           project: $GERRIT_PROJECT
129     builders:
130       - doc-rules
131
132 - project:
133     name: 'doc-rules'
134     jobs:
135       - 'doc-rules'