Skip to content

Commit e7a5b66

Browse files
native-apiskvark
authored andcommitted
Fix/improve travis_osx_brew_cache & caching logic
* fix built bottle & metadata cleanup when bottle is missing * -e mode for before_cache step * faster finish when already the latest version
1 parent 10c7cfa commit e7a5b66

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

.travis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ script: |
619619
620620
before_cache: |
621621
# Cleanup dirs to be cached
622-
set -x
622+
set -e; set -x
623623
if [ -n "$IS_OSX" ]; then
624624
625625
# When Taps is cached, this dir causes "Error: file exists" on `brew update`
@@ -630,7 +630,7 @@ before_cache: |
630630
brew_cache_cleanup
631631
632632
fi
633-
set +x
633+
set +x; set +e
634634
635635
after_success: |
636636
# Upload wheels to pypi if requested

travis_osx_brew_cache.sh

+9-6
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ function brew_install_and_cache_within_time_limit {
4141

4242
local BUILD_FROM_SOURCE INCLUDE_BUILD
4343

44+
if brew list --versions "$PACKAGE" && ! (brew outdated | grep -qx "$PACKAGE"); then
45+
echo "Already installed and the latest version: $PACKAGE"
46+
return 0
47+
fi
48+
49+
4450
_brew_is_bottle_available "$PACKAGE" || BUILD_FROM_SOURCE=1
4551
[ -n "$BUILD_FROM_SOURCE" ] && INCLUDE_BUILD="--include-build" || true
4652

@@ -152,7 +158,7 @@ function brew_add_local_bottles {
152158
)
153159
fi
154160

155-
if [ -n "$BOTTLE" ]; then rm "$BOTTLE"; fi
161+
if [ -n "$BOTTLE" -a -n "$BOTTLE_EXISTS" ]; then rm "$BOTTLE"; fi
156162
rm -f "$BOTTLE_LINK"
157163
rm "$JSON"
158164

@@ -295,17 +301,14 @@ function _brew_is_bottle_available {
295301

296302
function _brew_install_and_cache {
297303
# Install bottle or make and cache bottle.
298-
# assumes that deps were already installed.
304+
# assumes that deps were already installed
305+
# and not already the latest version
299306

300307
local PACKAGE;PACKAGE="${1:?}"
301308
local USE_BOTTLE;USE_BOTTLE="${2:?}"
302309
local VERB
303310

304311
if brew list --versions "$PACKAGE"; then
305-
if ! (brew outdated | grep -qx "$PACKAGE"); then
306-
echo "Already the latest version: $PACKAGE"
307-
return 0
308-
fi
309312
VERB=upgrade
310313
else
311314
VERB=install

0 commit comments

Comments
 (0)