diff --git a/.gitlab-industrial-ci-kinetic-no-rosinstall.yml b/.gitlab-industrial-ci-kinetic-no-rosinstall.yml index b64a68a55cc88378df6656e1c32b9c318407ae9a..354e04343db6b64ccbf9397812fe2fedb9183862 100644 --- a/.gitlab-industrial-ci-kinetic-no-rosinstall.yml +++ b/.gitlab-industrial-ci-kinetic-no-rosinstall.yml @@ -147,3 +147,20 @@ file_syntax: when: always tags: - docker + +########################################################## +## Check for errors in Asciidoctor files +## Could not find a proper linter for Asciidoctor format, +## so this is a custom-made "dirty" script +########################################################## +adoc_syntax: + stage: postcheck + image: alpine + before_script: + - apk add --update curl asciidoctor bash + script: + - curl -Ls https://git.code.tecnalia.com/tecnalia_robotics-public/gitlab_templates/raw/master/scripts/asciidoctor_syntax_check.bash | bash -s -- . + tags: + - docker + when: always + allow_failure: yes diff --git a/.gitlab-industrial-ci-kinetic-with-rosinstall.yml b/.gitlab-industrial-ci-kinetic-with-rosinstall.yml index c095ae7182b423b5c0e54c856bccc6d5d6e1cc83..3fd1545d02f1b661127bae43eb2f41b51d1b0aaf 100644 --- a/.gitlab-industrial-ci-kinetic-with-rosinstall.yml +++ b/.gitlab-industrial-ci-kinetic-with-rosinstall.yml @@ -149,3 +149,20 @@ file_syntax: when: always tags: - docker + +########################################################## +## Check for errors in Asciidoctor files +## Could not find a proper linter for Asciidoctor format, +## so this is a custom-made "dirty" script +########################################################## +adoc_syntax: + stage: postcheck + image: alpine + before_script: + - apk add --update curl asciidoctor bash + script: + - curl -Ls https://git.code.tecnalia.com/tecnalia_robotics-public/gitlab_templates/raw/master/scripts/asciidoctor_syntax_check.bash | bash -s -- . + tags: + - docker + when: always + allow_failure: yes diff --git a/scripts/asciidoctor_syntax_check.bash b/scripts/asciidoctor_syntax_check.bash new file mode 100644 index 0000000000000000000000000000000000000000..fb66a87b58071134a107e41101ce7729ea02c96e --- /dev/null +++ b/scripts/asciidoctor_syntax_check.bash @@ -0,0 +1,21 @@ +#!/bin/bash + +if ! [ -x "$(command -v asciidoctor)" ]; then + echo "Error: asciidoctor is not installed" + exit 1 +fi + +if [ -z "$1" ] ; then + echo "Error: No argument supplied - path needed" + exit 1 +fi + +touch output.log # avoid failing if no adoc files exist +while IFS= read -r -d '' filename; do + asciidoctor "$filename" 2>&1 | tee -a output.log +done < <(find "$1" -name '*.adoc' -type f -print0) +adoc_errors=0 ; adoc_warnings=0 +adoc_errors=$(grep -c "ERROR" output.log) +adoc_warnings=$(grep -c "WARNING" output.log) +echo "AsciiDoc format Found ${adoc_errors} errors and ${adoc_warnings} warnings" +if [ "${adoc_errors}" -eq 0 ]; then exit 0; else exit 1; fi