Skip to content

Commit b4a3158

Browse files
committed
changes
1 parent 3e58b7a commit b4a3158

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

.travis.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ jobs:
1919
- gem install asciidoctor asciidoctor-diagram rouge
2020
- pip3 install pyyaml aura.tar.gz
2121
script:
22-
# Fail if Asciidoctor encounters errors. Pass otherwise. Run only if there are modified AsciiDoc files
23-
- if ! [[ -z $(git diff --name-only HEAD~1 HEAD --diff-filter=d '*.adoc' ':(exclude)_unused_topics/*') ]]; then chmod +x ./scripts/check-asciidoctor-build.sh && ./scripts/check-asciidoctor-build.sh; fi
22+
# Fail if Asciidoctor encounters errors. Pass otherwise.
23+
- chmod +x ./scripts/check-asciidoctor-build.sh
24+
- ./scripts/check-asciidoctor-build.sh || travis_terminate 1
2425

2526
- stage: build
2627
if: branch IN (main, enterprise-4.13, enterprise-4.14)

scripts/check-asciidoctor-build.sh

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#!/bin/bash
22

3-
set -e
4-
53
# ensure asciidoctor is installed
64
if ! command -v asciidoctor &>/dev/null ;
75
then
@@ -11,7 +9,6 @@ fi
119

1210
# get the *.adoc modules and assemblies in the pull request
1311
FILES=$(git diff --name-only HEAD~1 HEAD --diff-filter=d "*.adoc" ':(exclude)_unused_topics/*')
14-
1512
REPO_PATH=$(git rev-parse --show-toplevel)
1613

1714
# get the modules in the PR, search for assemblies that include them, and concat with any updated assemblies files
@@ -24,8 +21,10 @@ check_updated_assemblies () {
2421
# Exit 0 if there are no modified assemblies
2522
if [[ -z "${UPDATED_ASSEMBLIES}" ]]
2623
then
24+
echo "No updated assemblies found! ✅"
2725
exit 0
2826
fi
27+
update_log
2928
# subtract $REPO_PATH from path with bash substring replacement
3029
UPDATED_ASSEMBLIES=${UPDATED_ASSEMBLIES//"$REPO_PATH/"/}
3130
fi
@@ -42,14 +41,23 @@ check_updated_assemblies () {
4241
if grep -rq "$PAGE" --include "*.yml" _topic_maps ; then
4342
# validate the assembly
4443
echo "Validating $ASSEMBLY ... 🚨"
45-
VALIDATION_ERROR=$(asciidoctor "$ASSEMBLY" -a source-highlighter=rouge -a icons! -o /tmp/out.html -v --failure-level WARN --trace)
44+
RED='\033[0;31m'
45+
NC='\033[0m'
46+
OUTPUT=$(asciidoctor "$ASSEMBLY" -a source-highlighter=rouge -a icons! -o /tmp/out.html -v --failure-level WARN --trace 2>&1)
47+
4648
# check assemblies and fail if errors are reported
47-
if [[ -z "$VALIDATION_ERROR" ]];
49+
if [[ $? != 0 ]];
4850
then
51+
echo -e "${RED}$OUTPUT${NC}"
52+
echo "Validation errors found! ❌"
53+
exit 1
54+
else
4955
echo "No errors found! ✅"
56+
exit 0
5057
fi
5158
else
5259
echo "$ASSEMBLY is not in a topic_map, skipping validation... 😙"
60+
exit 0
5361
fi
5462
done
5563
}
@@ -71,8 +79,8 @@ update_log () {
7179
# check assemblies and fail if errors are reported
7280
if [ -n "${FILES}" ] ;
7381
then
74-
update_log
7582
check_updated_assemblies
7683
else
7784
echo "No modified AsciiDoc files found! 🥳"
85+
exit 0
7886
fi

0 commit comments

Comments
 (0)