forked from openedx/edx-documentation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_tests.sh
executable file
·116 lines (95 loc) · 3.23 KB
/
run_tests.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/bin/bash
# Each documentation project is in a directory in the en_us folder.
# To generate docs for a project, Go to a project directory and
# run `make HTML` and `make latexpdf`.
# To test a subset of projects you can pass them in as command line
# arguments to this script. For example:
# `./run_tests.sh en_us/install_operations` would only run tests on
# the install operations project.
# The directory that this script is located in.
BASE_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
# FAILED_BUILDS are builds that had either a SPHINX_ERROR
# or a BUILD_ERROR
FAILED_BUILDS=()
# BUILD_ERRORS are errors that resulted in the doc build
# exiting with a non-zero exit status.
BUILD_ERRORS=0
# SPHINX_ERRORS are errors that are reported by sphinx
# but do not cause the doc build to return a non-zero exit
# status. These are considered a build failure from a CI
# perspective though.
SPHINX_ERRORS=0
# SPHINX_WARNING are warning messages generated by sphinx
# while building the docs. They should not cause the CI
# build to fail.
SPHINX_WARNINGS=0
projects=($@)
if [ ${#projects[@]} -eq 0 ]
then
projects=(
"en_us/course_authors"
"en_us/data"
"en_us/developers"
"en_us/edx_style_guide"
"en_us/install_operations"
"en_us/olx"
"en_us/open_edx_release_notes"
"en_us/ORA2"
"en_us/release_notes"
"en_us/students"
"en_us/video"
)
fi
for project in "${projects[@]}"; do
cd $BASE_DIR/$project
echo "--> Starting build for $PWD"
project_build_status=0
# Make sure log dir exists
err_log_dir=$BASE_DIR/test_root/$project
err_log_file=$err_log_dir/err.log
mkdir -p $err_log_dir
# Generate html docs.
# -w writes warnings and errors to the specified file in
# addition to stderr.
# -n runs in nit-picky mode.
# -E Don’t use a saved environment (the structure caching all
# cross-references), but rebuild it completely.
make html SPHINXOPTS="-E -n -w $err_log_file"
if [ $? -gt 0 ]; then
project_build_status=1
BUILD_ERRORS=$((BUILD_ERRORS + 1))
fi
# Get errors and warnings from the error log
IFS=$'\n' read -d '' -r -a error_log < $err_log_file
num_errors=`echo ${error_log[@]} | grep -o 'ERROR:' | wc -l`
num_warnings=`echo ${error_log[@]} | grep -o 'WARNING:' | wc -l`
echo SPHINX ERRORS: $num_errors
echo SPHINX WARNINGS: $num_warnings
echo
if [ $num_errors -gt 0 ]; then
project_build_status=1
SPHINX_ERRORS=$((SPHINX_ERRORS + num_errors))
fi
if [ $num_warnings -gt 0 ]; then
SPHINX_WARNINGS=$((SPHINX_WARNINGS + num_warnings))
fi
if [ $project_build_status -gt 0 ]; then
FAILED_BUILDS+=($project)
fi
done
# Report and exit with the correct code
echo '********** All builds done ************'
echo TOTAL SPHINX ERRORS: $SPHINX_ERRORS
echo TOTAL SPHINX WARNINGS: $SPHINX_WARNINGS
echo OTHER BUILD ERRORS: $BUILD_ERRORS
EXIT_STATUS=0
if [ ${#FAILED_BUILDS[@]} -gt 0 ]; then
echo "There were errors while building the following projects:"
for project in "${FAILED_BUILDS[@]}"; do
echo $project
done
EXIT_STATUS=1
else
echo "All builds passed."
fi
exit $EXIT_STATUS