Skip to content

Commit ec3ed5a

Browse files
author
MarcoFalke
committed
Merge #16597: Travis: run full test suite on native macOS
1f6c650 travis: run tests on macOS native (Sjors Provoost) Pull request description: Adds an additional Travis machine to run the functional test suite on native macOS Homebrew is not particularly Travis compatible, but I found some useful hints here: https://discourse.brew.sh/t/best-practice-for-homebrew-on-travis-brew-update-is-5min-to-build-time/5215/11 ACKs for top commit: MarcoFalke: re-ACK 1f6c650 Tree-SHA512: 3f19a1695fac53d4d6c2033a9c20be69294e3a798c84fd9bf6ae2aa7a6d92aa1dad1f62f4ee1ada9413fe7d05ee974050fa030fd2c547f33e0d5c0a3e74f64db
2 parents 048e456 + 1f6c650 commit ec3ed5a

File tree

6 files changed

+109
-18
lines changed

6 files changed

+109
-18
lines changed

.travis.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ cache:
3434
- $TRAVIS_BUILD_DIR/depends/built
3535
- $TRAVIS_BUILD_DIR/depends/sdk-sources
3636
- $TRAVIS_BUILD_DIR/ci/scratch/.ccache
37+
# macOS
38+
- $HOME/Library/Caches/Homebrew
39+
- /usr/local/Homebrew
40+
before_cache:
41+
- if [ "${TRAVIS_OS_NAME}" = "osx" ]; then brew cleanup; fi
42+
# Cache only .git files under "/usr/local/Homebrew" so "brew update" does not take 5min every build
43+
# - if [ "${TRAVIS_OS_NAME}" = "osx" ]; then find /usr/local/Homebrew \! -regex ".+\.git.+" -delete; fi
3744
stages:
3845
- lint
3946
- test
@@ -93,7 +100,7 @@ jobs:
93100
os: osx
94101
# Use the earliest macOS that can build our lint dependencies:
95102
# Xcode 8.3.3, macOS 10.12, JDK 1.8.0_112-b16
96-
# https://docs.travis-ci.com/user/reference/osx/#OS-X-Version
103+
# https://docs.travis-ci.com/user/reference/osx/#macos-version
97104
osx_image: xcode8.3
98105
# TODO: if you're updating osx_image, try using "rvm:" to supply the
99106
# version of ruby required by homebrew. Despite this "rvm:" declaration,
@@ -160,3 +167,13 @@ jobs:
160167
name: 'macOS 10.10 [GOAL: deploy] [no functional tests]'
161168
env: >-
162169
FILE_ENV="./ci/test/00_setup_env_mac.sh"
170+
171+
- stage: test
172+
name: 'macOS 10.14 native [GOAL: install] [GUI: BIP70 enabled] [no depends]'
173+
os: osx
174+
# Use the most recent version:
175+
# Xcode 11, macOS 10.14, JDK 12.0.1
176+
# https://docs.travis-ci.com/user/reference/osx/#macos-version
177+
osx_image: xcode11
178+
env: >-
179+
FILE_ENV="./ci/test/00_setup_env_mac_functional.sh"
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Copyright (c) 2019 The Bitcoin Core developers
4+
# Distributed under the MIT software license, see the accompanying
5+
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
6+
7+
export LC_ALL=C.UTF-8
8+
9+
export HOST=x86_64-apple-darwin14
10+
export BREW_PACKAGES="automake berkeley-db4 libtool boost miniupnpc pkg-config protobuf qt qrencode python3 ccache zeromq"
11+
export PIP_PACKAGES="zmq"
12+
export OSX_SDK=10.11
13+
export RUN_CI_ON_HOST=true
14+
export RUN_UNIT_TESTS=true
15+
export RUN_FUNCTIONAL_TESTS=true
16+
export GOAL="install"
17+
export BITCOIN_CONFIG="--enable-gui --enable-bip70 --enable-reduce-exports --enable-werror"
18+
export NO_DEPENDS=1

ci/test/04_install.sh

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,32 @@
66

77
export LC_ALL=C.UTF-8
88

9+
if [ "$TRAVIS_OS_NAME" == "osx" ]; then
10+
set +o errexit
11+
pushd /usr/local/Homebrew || exit 1
12+
git reset --hard origin/master
13+
popd || exit 1
14+
set -o errexit
15+
${CI_RETRY_EXE} brew update
16+
# brew upgrade returns an error if any of the packages is already up to date
17+
# Failure is safe to ignore, unless we really need an update.
18+
brew upgrade $BREW_PACKAGES || true
19+
20+
# install new packages (brew install returns an error if already installed)
21+
for i in $BREW_PACKAGES; do
22+
if ! brew list | grep -q $i; then
23+
${CI_RETRY_EXE} brew install $i
24+
fi
25+
done
26+
27+
export PATH="/usr/local/opt/ccache/libexec:$PATH"
28+
OPENSSL_PKG_CONFIG_PATH="/usr/local/opt/[email protected]/lib/pkgconfig"
29+
export PKG_CONFIG_PATH=$OPENSSL_PKG_CONFIG_PATH:$PKG_CONFIG_PATH
30+
31+
${CI_RETRY_EXE} pip3 install $PIP_PACKAGES
32+
33+
fi
34+
935
mkdir -p "${BASE_SCRATCH_DIR}"
1036
ccache echo "Creating ccache dir if it didn't already exist"
1137

@@ -42,11 +68,19 @@ else
4268
}
4369
fi
4470

45-
DOCKER_EXEC free -m -h
46-
DOCKER_EXEC echo "Number of CPUs \(nproc\):" \$\(nproc\)
71+
if [ "$TRAVIS_OS_NAME" == "osx" ]; then
72+
top -l 1 -s 0 | awk ' /PhysMem/ {print}'
73+
echo "Number of CPUs: $(sysctl -n hw.logicalcpu)"
74+
else
75+
DOCKER_EXEC free -m -h
76+
DOCKER_EXEC echo "Number of CPUs \(nproc\):" \$\(nproc\)
77+
fi
4778

48-
${CI_RETRY_EXE} DOCKER_EXEC apt-get update
49-
${CI_RETRY_EXE} DOCKER_EXEC apt-get install --no-install-recommends --no-upgrade -y $PACKAGES $DOCKER_PACKAGES
79+
80+
if [ "$TRAVIS_OS_NAME" != "osx" ]; then
81+
${CI_RETRY_EXE} DOCKER_EXEC apt-get update
82+
${CI_RETRY_EXE} DOCKER_EXEC apt-get install --no-install-recommends --no-upgrade -y $PACKAGES $DOCKER_PACKAGES
83+
fi
5084

5185
if [ "$USE_BUSY_BOX" = "true" ]; then
5286
echo "Setup to use BusyBox utils"

ci/test/05_before_script.sh

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,28 @@
66

77
export LC_ALL=C.UTF-8
88

9-
DOCKER_EXEC echo \> \$HOME/.bitcoin # Make sure default datadir does not exist and is never read by creating a dummy file
9+
# Make sure default datadir does not exist and is never read by creating a dummy file
10+
if [ "$TRAVIS_OS_NAME" == "osx" ]; then
11+
echo > $HOME/Library/Application\ Support/Bitcoin
12+
else
13+
DOCKER_EXEC echo \> \$HOME/.bitcoin
14+
fi
1015

11-
mkdir -p depends/SDKs depends/sdk-sources
16+
if [ "$TRAVIS_OS_NAME" != "osx" ]; then
17+
18+
mkdir -p depends/SDKs depends/sdk-sources
19+
20+
if [ -n "$OSX_SDK" ] && [ ! -f depends/sdk-sources/MacOSX${OSX_SDK}.sdk.tar.gz ]; then
21+
curl --location --fail $SDK_URL/MacOSX${OSX_SDK}.sdk.tar.gz -o depends/sdk-sources/MacOSX${OSX_SDK}.sdk.tar.gz
22+
fi
23+
if [ -n "$OSX_SDK" ] && [ -f depends/sdk-sources/MacOSX${OSX_SDK}.sdk.tar.gz ]; then
24+
tar -C depends/SDKs -xf depends/sdk-sources/MacOSX${OSX_SDK}.sdk.tar.gz
25+
fi
26+
if [[ $HOST = *-mingw32 ]]; then
27+
DOCKER_EXEC update-alternatives --set $HOST-g++ \$\(which $HOST-g++-posix\)
28+
fi
29+
if [ -z "$NO_DEPENDS" ]; then
30+
DOCKER_EXEC CONFIG_SHELL= make $MAKEJOBS -C depends HOST=$HOST $DEP_OPTS
31+
fi
1232

13-
if [ -n "$OSX_SDK" ] && [ ! -f depends/sdk-sources/MacOSX${OSX_SDK}.sdk.tar.gz ]; then
14-
curl --location --fail $SDK_URL/MacOSX${OSX_SDK}.sdk.tar.gz -o depends/sdk-sources/MacOSX${OSX_SDK}.sdk.tar.gz
15-
fi
16-
if [ -n "$OSX_SDK" ] && [ -f depends/sdk-sources/MacOSX${OSX_SDK}.sdk.tar.gz ]; then
17-
tar -C depends/SDKs -xf depends/sdk-sources/MacOSX${OSX_SDK}.sdk.tar.gz
18-
fi
19-
if [[ $HOST = *-mingw32 ]]; then
20-
DOCKER_EXEC update-alternatives --set $HOST-g++ \$\(which $HOST-g++-posix\)
21-
fi
22-
if [ -z "$NO_DEPENDS" ]; then
23-
DOCKER_EXEC CONFIG_SHELL= make $MAKEJOBS -C depends HOST=$HOST $DEP_OPTS
2433
fi

ci/test/06_script_a.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ fi
2020
END_FOLD
2121

2222
mkdir -p build
23+
24+
# Temporarily disable errexit, because Travis macOS fails without error message
25+
set +o errexit
2326
cd build || (echo "could not enter build directory"; exit 1)
27+
set -o errexit
2428

2529
BEGIN_FOLD configure
2630
DOCKER_EXEC ../configure --cache-file=config.cache $BITCOIN_CONFIG_ALL $BITCOIN_CONFIG || ( cat config.log && false)
@@ -30,7 +34,9 @@ BEGIN_FOLD distdir
3034
DOCKER_EXEC make distdir VERSION=$HOST
3135
END_FOLD
3236

37+
set +o errexit
3338
cd "bitcoin-$HOST" || (echo "could not enter distdir bitcoin-$HOST"; exit 1)
39+
set -o errexit
3440

3541
BEGIN_FOLD configure
3642
DOCKER_EXEC ./configure --cache-file=../config.cache $BITCOIN_CONFIG_ALL $BITCOIN_CONFIG || ( cat config.log && false)
@@ -43,4 +49,6 @@ BEGIN_FOLD build
4349
DOCKER_EXEC make $MAKEJOBS $GOAL || ( echo "Build failure. Verbose build follows." && DOCKER_EXEC make $GOAL V=1 ; false )
4450
END_FOLD
4551

52+
set +o errexit
4653
cd ${BASE_BUILD_DIR} || (echo "could not enter travis build dir $BASE_BUILD_DIR"; exit 1)
54+
set -o errexit

ci/test/06_script_b.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66

77
export LC_ALL=C.UTF-8
88

9+
# Temporarily disable errexit, because Travis macOS fails without error message
10+
set +o errexit
911
cd "build/bitcoin-$HOST" || (echo "could not enter distdir build/bitcoin-$HOST"; exit 1)
12+
set -o errexit
1013

1114
if [ -n "$QEMU_USER_CMD" ]; then
1215
BEGIN_FOLD wrap-qemu
@@ -46,4 +49,6 @@ if [ "$RUN_FUZZ_TESTS" = "true" ]; then
4649
END_FOLD
4750
fi
4851

52+
set +o errexit
4953
cd ${BASE_BUILD_DIR} || (echo "could not enter travis build dir $BASE_BUILD_DIR"; exit 1)
54+
set -o errexit

0 commit comments

Comments
 (0)