Merge "Chore: Add Cédric Ollivier 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_warning_msg "sphinx-build option '-W' not used for spellcheck in $filename, line $linenumber."
79                   warning="1"
80                 else
81                   log_failure_msg "sphinx-build option '-W' missing in $filename, line $linenumber. Please add it."
82                   exitstatus="1"
83                 fi
84               fi
85             done < $filename
86             if [ "$sphinxbuild_detected" = "0" ]; then
87               log_failure_msg "Sphinx-build command(s) missing in $filename. Please add it."
88               exitstatus="1"
89             fi
90             unset sphinxbuild_detected
91             unset linenumber
92           fi
93           unset filename
94           filename="docs/_static/css/ribbon.css"
95           if [ ! -f $filename ]; then
96             log_failure_msg "$filename missing. Please add it or remove the full docs directory."
97             exitstatus="1"
98           else
99             log_success_msg "$filename found."
100             cssmaxwidth=$(grep '^[ \t]*max-width:' $filename | sed -e 's/^[ \t]*//' | sed -e 's/;$//');
101             if [[ ! $cssmaxwidth == *"max-width: 800px"* ]]; then
102               log_failure_msg "Setting 'max-width: 800px' missing in $filename. Please add it."
103               exitstatus="1"
104             else
105               log_success_msg "Setting 'max-width: 800px' found in $filename."
106             fi
107             unset cssmaxwidth
108           fi
109           unset filename
110           if [ "$exitstatus" = "0" ]; then
111             if [ "$warning" = "0" ]; then
112               log_success_msg "Congratulations! No documentation problem(s) detected."
113             else
114               log_warning_msg "No major documentation problem(s) detected but there are warnings!"
115             fi
116           else
117             log_failure_msg "Please fix the detected documentation problem(s)!"
118           fi
119           exit $exitstatus
120
121 - job-template:
122     name: doc-rules
123     node: ubuntu1804-docker-8c-8g
124     triggers:
125       - doc-rules-patchset-created
126     scm:
127       - doc-scm:
128           ref: $GERRIT_REFSPEC
129           project: $GERRIT_PROJECT
130     builders:
131       - doc-rules
132
133 - project:
134     name: 'doc-rules'
135     jobs:
136       - 'doc-rules'