|
6 | 6 | # documentation: a pull request that does not change any file in doc/ or
|
7 | 7 | # examples/ folder should be skipped unless the "[doc: build]" is found the
|
8 | 8 | # commit message.
|
9 |
| -python build_tools/circle/check_build_doc.py |
10 |
| -build_type=$? |
| 9 | + |
| 10 | +get_build_type() { |
| 11 | + if [ -z "$CIRCLE_SHA1" ] |
| 12 | + then |
| 13 | + echo SKIP: undefined CIRCLE_SHA1 |
| 14 | + return |
| 15 | + fi |
| 16 | + commit_msg=$(git log --format=%B -n 1 $CIRCLE_SHA1) |
| 17 | + if [ -z "$commit_msg" ] |
| 18 | + then |
| 19 | + echo QUICK BUILD: failed to inspect commit $CIRCLE_SHA1 |
| 20 | + return |
| 21 | + fi |
| 22 | + if [[ "$commit_msg" =~ '.*[doc skip].*' ]] |
| 23 | + then |
| 24 | + echo SKIP: [doc skip] marker found |
| 25 | + return |
| 26 | + fi |
| 27 | + if [[ "$commit_msg" =~ '.*[doc build].*' ]] |
| 28 | + then |
| 29 | + echo BUILD: [doc build] marker found |
| 30 | + return |
| 31 | + fi |
| 32 | + if [ -z "$CI_PULL_REQUEST" ] |
| 33 | + then |
| 34 | + echo BUILD: not a pull request |
| 35 | + return |
| 36 | + fi |
| 37 | + git_range="origin/master...$CIRCLE_SHA1" |
| 38 | + git fetch origin master >&2 |
| 39 | + filenames=$(git diff --name-only $git_range) |
| 40 | + if [ -z "$filenames" ] |
| 41 | + then |
| 42 | + echo QUICK BUILD: failed to get changed filenames for $git_range |
| 43 | + return |
| 44 | + fi |
| 45 | + if echo "$filenames" | grep -q -e ^examples/ -e ^doc/ |
| 46 | + then |
| 47 | + echo BUILD: detected doc/ or examples/ filename modified in $git_range: $(echo "$filenames" | grep -e ^examples/ -e ^doc/ | head -n1) |
| 48 | + return |
| 49 | + fi |
| 50 | + echo QUICK BUILD: no doc/ or examples/ filename modified in $git_range: |
| 51 | + echo "$filenames" |
| 52 | +} |
| 53 | + |
11 | 54 | touch ~/log.txt # the "test" segment needs this file
|
12 |
| -BUILD=0 |
13 |
| -QUICK=1 |
14 |
| -SKIP=2 |
15 |
| -if [ $build_type = $SKIP ] |
| 55 | + |
| 56 | +build_type=$(get_build_type) |
| 57 | +if [[ "$build_type" =~ ^SKIP ]] |
16 | 58 | then
|
17 | 59 | exit 0
|
18 | 60 | fi
|
19 | 61 |
|
20 | 62 | if [[ "$CIRCLE_BRANCH" =~ ^master$|^[0-9]+\.[0-9]+\.X$ && -z "$CI_PULL_REQUEST" ]]
|
21 | 63 | then
|
22 | 64 | MAKE_TARGET=dist # PDF linked into HTML
|
23 |
| -elif [ $build_type = $QUICK ] |
| 65 | +elif [[ "$build_type" =~ ^QUICK ]] |
24 | 66 | then
|
25 | 67 | MAKE_TARGET=html-noplot
|
26 | 68 | else
|
|
0 commit comments