Skip to content

Commit 820aaa4

Browse files
committed
Try not to exit the build when timeout is reached
1 parent 9e05f3a commit 820aaa4

File tree

3 files changed

+59
-15
lines changed

3 files changed

+59
-15
lines changed

.travis.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ install: |
8585
python setup.py sdist
8686
else
8787
build_wheel $REPO_DIR $PLAT
88+
ret_code=$?
8889
fi
8990
9091
set +x
@@ -105,8 +106,18 @@ script: |
105106
trap ERR
106107
test "$rc" -eq 0
107108
109+
after_failure: |
110+
# after_failure
111+
echo "Error code after <install>:" $ret_code
112+
108113
after_success: |
109114
# Upload wheels to pypi if tag is set
115+
if [[ $SDIST != 0 ]]; then
116+
echo "Error code after <install>:" $ret_code
117+
if [[ $ret_code != 0 ]]; then
118+
exit $ret_code
119+
fi
120+
fi
110121
111122
set -x; set +e
112123

travis_config.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@ echo "=== Loading config.sh === "
77

88
# To see build progress
99
function build_wheel {
10-
build_bdist_wheel $@
10+
if [ -n "$IS_OSX" ]; then
11+
source travis_osx_build.sh
12+
build_bdist_osx_wheel $@ || return $?
13+
else
14+
build_bdist_wheel $@
15+
fi
1116
}
1217

1318
function bdist_wheel_cmd {
1419
# copied from multibuild's common_utils.sh
1520
# add osx deployment target so it doesnt default to 10.6
1621
local abs_wheelhouse=$1
17-
if [ -n "$IS_OSX" ]; then
18-
source travis_osx_build.sh
19-
build_bdist_osx_wheel . $@ || return $?
20-
else
21-
CI_BUILD=1 pip wheel --verbose --wheel-dir="$PWD/dist" . $BDIST_PARAMS
22-
fi
22+
CI_BUILD=1 pip wheel --verbose --wheel-dir="$PWD/dist" . $BDIST_PARAMS
2323
cp dist/*.whl $abs_wheelhouse
2424
if [ -z "$IS_OSX" ]; then
2525
TOOLS_PATH=/opt/_internal/tools

travis_osx_build.sh

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,47 @@ function package_name() {
1010
wheel_name=$name
1111
}
1212

13+
# Terminate the build but ensure saving the cache
14+
function goto_exit {
15+
local EXIT_CODE=${1:-1}
16+
17+
echo "Exiting build"
18+
19+
# Can't just `exit` because that would terminate the build without saving the cache
20+
# Have to replace further actions with no-ops
21+
22+
local MESSAGE=""; if [ "$EXIT_CODE" -ne 0 ]; then
23+
MESSAGE='Building package took too long. Restart the build in Travis UI to continue from cache.'
24+
fi
25+
26+
set +e
27+
28+
eval '
29+
function install_run {'\
30+
"$(if [ -n "$MESSAGE" ]; then
31+
echo ' echo -e "\n'"$MESSAGE"'\n"'
32+
fi)"\
33+
'
34+
# Travis runs user scripts via `eval` i.e. in the same shell process.
35+
# So have to unset errexit in order to get to cache save stage
36+
set +e
37+
return '"$EXIT_CODE"'
38+
}'
39+
}
40+
1341
function pre_build_osx {
1442
local repo_dir=$(abspath ${1:-$REPO_DIR})
1543
local build_dir="$repo_dir/opencv/build"
1644
local num_cpus=$(sysctl -n hw.ncpu)
1745
num_cpus=${num_cpus:-4}
1846
local travis_start_time=$(($TRAVIS_TIMER_START_TIME/10**9))
19-
local time_limit=$((30*60))
47+
local time_limit=$((46*60))
2048

2149
cd "$repo_dir"
2250
git submodule sync
2351
git submodule update --init --recursive opencv
2452
git submodule update --init --recursive opencv_contrib
2553

26-
pip install scikit-build
27-
pip install numpy
28-
2954
if [ ! -d "$build_dir" ]; then
3055
mkdir "$build_dir"
3156
fi
@@ -126,13 +151,15 @@ function pre_build_osx {
126151
opencv_alphamat
127152
opencv_stitching
128153
opencv_gapi
154+
all
129155
)
130156
for m in "${CV_MODULES[@]}"; do
131157
if make help | grep -w "$m"; then
132158
# Check time limit (3min should be enough for a module to built)
133159
local projected_time=$(($(date +%s) - travis_start_time + 3 * 60))
134160
if [ $projected_time -ge $time_limit ]; then
135-
echo "*** Not enough time to build $m: $((projected_time/60))m (${projected_time}s)"
161+
ccache -s
162+
goto_exit
136163
return 1
137164
fi
138165
make -j${num_cpus} "$m"
@@ -141,6 +168,7 @@ function pre_build_osx {
141168
fi
142169
done
143170
make -j${num_cpus}
171+
ccache -s
144172
}
145173

146174
function build_osx {
@@ -176,9 +204,14 @@ function build_osx {
176204
function build_bdist_osx_wheel {
177205
local repo_dir=$(abspath ${1:-$REPO_DIR})
178206
[ -z "$repo_dir" ] && echo "repo_dir not defined" && exit 1
207+
local wheelhouse=$(abspath ${WHEEL_SDIR:-wheelhouse})
208+
start_spinner
209+
if [ -n "$(is_function "pre_build")" ]; then pre_build; fi
210+
stop_spinner
211+
pip install scikit-build
212+
pip install numpy
179213
pre_build_osx "$repo_dir" || return $?
180-
if [ -n "$BUILD_DEPENDS" ]; then
181-
pip install $(pip_opts) $BUILD_DEPENDS
182-
fi
183214
build_osx "$repo_dir"
215+
cp "$repo_dir"/dist/*.whl "$wheelhouse"
216+
repair_wheelhouse "$wheelhouse"
184217
}

0 commit comments

Comments
 (0)