8000 [MRG] CI make html-noplot when doc/ and examples/ not modified (#7923) · sergeyf/scikit-learn@af726e6 · GitHub
[go: up one dir, main page]

Skip to content

Commit af726e6

Browse files
jnothmansergeyf
authored andcommitted
[MRG] CI make html-noplot when doc/ and examples/ not modified (scikit-learn#7923)
1 parent 5fc6d50 commit af726e6

File tree

2 files changed

+73
-81
lines changed

2 files changed

+73
-81
lines changed

build_tools/circle/build_doc.sh

Lines changed: 73 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,82 @@
22
set -x
33
set -e
44

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
1367
exit 0
1468
fi
1569

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
1781
# notation in the HTML documentation
1882
sudo -E apt-get -yq update
1983
sudo -E apt-get -yq remove texlive-binaries --purge
@@ -53,11 +117,5 @@ source activate testenv
53117
# Build and install scikit-learn in dev mode
54118
python setup.py develop
55119

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
62120
# The pipefail is requested to propagate exit code
63121
set -o pipefail && cd doc && make $MAKE_TARGET 2>&1 | tee ~/log.txt

build_tools/circle/check_build_doc.py

Lines changed: 0 additions & 66 deletions
This file was deleted.

0 commit comments

Comments
 (0)
0