|
2 | 2 | set -x
|
3 | 3 | set -e
|
4 | 4 |
|
5 |
| -# Introspect the commit to know whether or not we should skip building the |
6 |
| -# documentation: a pull request that does not change any file in doc/ or |
7 |
| -# examples/ folder should be skipped unless the "[doc: build]" is found the |
8 |
| -# commit message. |
9 |
| -BUILD_DOC=`python build_tools/circle/check_build_doc.py` |
10 |
| -echo -e $BUILD_DOC |
11 |
| -if [[ $BUILD_DOC == "SKIP:"* ]]; then |
12 |
| - touch ~/log.txt # the "test" segment needs that file |
| 5 | +# Decide what kind of documentation build to run, and run it. |
| 6 | +# |
| 7 | +# If the last commit message has a "[doc skip]" marker, do not build |
| 8 | +# the doc. On the contrary if a "[doc build]" marker is found, build the doc |
| 9 | +# instead of relying on the subsequent rules. |
| 10 | +# |
| 11 | +# We always build the documentation for jobs that are not related to a specific |
| 12 | +# PR (e.g. a merge to master or a maintenance branch). |
| 13 | +# |
| 14 | +# If this is a PR, do a full build if there are some files in this PR that are |
| 15 | +# under the "doc/" or "examples/" folders, otherwise perform a quick build. |
| 16 | +# |
| 17 | +# If the inspection of the current commit fails for any reason, the default |
| 18 | +# behavior is to quick build the documentation. |
| 19 | + |
| 20 | +get_build_type() { |
| 21 | + if [ -z "$CIRCLE_SHA1" ] |
| 22 | + then |
| 23 | + echo SKIP: undefined CIRCLE_SHA1 |
| 24 | + return |
| 25 | + fi |
| 26 | + commit_msg=$(git log --format=%B -n 1 $CIRCLE_SHA1) |
| 27 | + if [ -z "$commit_msg" ] |
| 28 | + then |
| 29 | + echo QUICK BUILD: failed to inspect commit $CIRCLE_SHA1 |
| 30 | + return |
| 31 | + fi |
| 32 | + if [[ "$commit_msg" =~ \[doc\ skip\] ]] |
| 33 | + then |
| 34 | + echo SKIP: [doc skip] marker found |
| 35 | + return |
| 36 | + fi |
| 37 | + if [[ "$commit_msg" =~ \[doc\ build\] ]] |
| 38 | + then |
| 39 | + echo BUILD: [doc build] marker found |
| 40 | + return |
| 41 | + fi |
| 42 | + if [ -z "$CI_PULL_REQUEST" ] |
| 43 | + then |
| 44 | + echo BUILD: not a pull request |
| 45 | + return |
| 46 | + fi |
| 47 | + git_range="origin/master...$CIRCLE_SHA1" |
| 48 | + git fetch origin master >&2 || (echo QUICK BUILD: failed to get changed filenames for $git_range; return) |
| 49 | + filenames=$(git diff --name-only $git_range) |
| 50 | + if [ -z "$filenames" ] |
| 51 | + then |
| 52 | + echo QUICK BUILD: no changed filenames for $git_range |
| 53 | + return |
| 54 | + fi |
| 55 | + if echo "$filenames" | grep -q -e ^examples/ -e ^doc/ |
| 56 | + then |
| 57 | + echo BUILD: detected doc/ or examples/ filename modified in $git_range: $(echo "$filenames" | grep -e ^examples/ -e ^doc/ | head -n1) |
| 58 | + return |
| 59 | + fi |
| 60 | + echo QUICK BUILD: no doc/ or examples/ filename modified in $git_range: |
| 61 | + echo "$filenames" |
| 62 | +} |
| 63 | + |
| 64 | +build_type=$(get_build_type) |
| 65 | +if [[ "$build_type" =~ ^SKIP ]] |
| 66 | +then |
13 | 67 | exit 0
|
14 | 68 | fi
|
15 | 69 |
|
16 |
| -# Installing required system packages to support the rendering of match |
| 70 | +if [[ "$CIRCLE_BRANCH" =~ ^master$|^[0-9]+\.[0-9]+\.X$ && -z "$CI_PULL_REQUEST" ]] |
| 71 | +then |
| 72 | + MAKE_TARGET=dist # PDF linked into HTML |
| 73 | +elif [[ "$build_type" =~ ^QUICK ]] |
| 74 | +then |
| 75 | + MAKE_TARGET=html-noplot |
| 76 | +else |
| 77 | + MAKE_TARGET=html |
| 78 | +fi |
| 79 | + |
| 80 | +# Installing required system packages to support the rendering of math |
17 | 81 | # notation in the HTML documentation
|
18 | 82 | sudo -E apt-get -yq update
|
19 | 83 | sudo -E apt-get -yq remove texlive-binaries --purge
|
@@ -53,11 +117,5 @@ source activate testenv
|
53 | 117 | # Build and install scikit-learn in dev mode
|
54 | 118 | python setup.py develop
|
55 | 119 |
|
56 |
| -if [[ "$CIRCLE_BRANCH" =~ ^master$|^[0-9]+\.[0-9]+\.X$ && -z "$CI_PULL_REQUEST" ]] |
57 |
| -then |
58 |
| - MAKE_TARGET=dist |
59 |
| -else |
60 |
| - MAKE_TARGET=html |
61 |
| -fi |
62 | 120 | # The pipefail is requested to propagate exit code
|
63 | 121 | set -o pipefail && cd doc && make $MAKE_TARGET 2>&1 | tee ~/log.txt
|
0 commit comments