From 86af1067030c622c32ebfa0246482bd69ba45411 Mon Sep 17 00:00:00 2001 From: Andrew Grimberg Date: Wed, 3 May 2023 09:47:36 -0700 Subject: Refactor: Cleanup for pre-commit Change-Id: I322d72428f094f75f065d02f179a71958f36c875 Issue-ID: CIMAN-33 Signed-off-by: Andrew Grimberg --- jjb/doc/rules.yaml | 292 ++++++++++++++++++++++++++--------------------------- 1 file changed, 146 insertions(+), 146 deletions(-) (limited to 'jjb/doc/rules.yaml') diff --git a/jjb/doc/rules.yaml b/jjb/doc/rules.yaml index 9ff64b5d9..aa17f6848 100644 --- a/jjb/doc/rules.yaml +++ b/jjb/doc/rules.yaml @@ -1,159 +1,159 @@ --- - 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}" + 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/**" + 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 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; 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" + 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 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; 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_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_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_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." + log_failure_msg "FAIL sphinx-build option '-W' missing in $filename, line $linenumber. Please add it." 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 - # 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 + fi + done < $filename + if [ "$sphinxbuild_detected" = "0" ]; then + 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 + # 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 + 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" + name: "doc-rules" + jobs: + - "doc-rules" -- cgit 1.2.3-korg