cibuild.sh 3.17 KB
Newer Older
1 2
#!/bin/sh

Carlos Martín Nieto committed
3 4
set -x

5
if [ -n "$COVERITY" ];
Ben Straub committed
6 7 8 9 10
then
	./script/coverity.sh;
	exit $?;
fi

11
if [ "$TRAVIS_OS_NAME" = "osx" ]; then
12
	export PKG_CONFIG_PATH=$(ls -d /usr/local/Cellar/{curl,zlib}/*/lib/pkgconfig | paste -s -d':' -)
13 14 15 16 17

	# Set up a ramdisk for us to put our test data on to speed up tests on macOS
	export CLAR_TMP="$HOME"/_clar_tmp
	mkdir -p $CLAR_TMP

18 19
	# 5*2M sectors aka ~5GB of space
	device=$(hdiutil attach -nomount ram://$((5 * 2 * 1024 * 1024)))
20 21
	newfs_hfs $device
	mount -t hfs $device $CLAR_TMP
22 23
fi

24 25 26 27 28
# Should we ask Travis to cache this file?
curl -L https://github.com/ethomson/poxyproxy/releases/download/v0.1.0/poxyproxy-0.1.0.jar >poxyproxy.jar || exit $?
# Run this early so we know it's ready by the time we need it
java -jar poxyproxy.jar -d --port 8080 --credentials foo:bar &

29 30 31
mkdir _build
cd _build
# shellcheck disable=SC2086
32
cmake .. -DBUILD_EXAMPLES=ON -DCMAKE_INSTALL_PREFIX=../_install $OPTIONS || exit $?
33 34 35 36 37 38 39 40
make -j2 install || exit $?

# If this platform doesn't support test execution, bail out now
if [ -n "$SKIP_TESTS" ];
then
	exit $?;
fi

41
# Create a test repo which we can use for the online::push tests
42 43 44
mkdir "$HOME"/_temp
git init --bare "$HOME"/_temp/test.git
git daemon --listen=localhost --export-all --enable=receive-pack --base-path="$HOME"/_temp "$HOME"/_temp 2>/dev/null &
45 46
export GITTEST_REMOTE_URL="git://localhost/test.git"

47
# Run the test suite
48
ctest -V -R libgit2_clar || exit $?
49 50 51 52 53

# Now that we've tested the raw git protocol, let's set up ssh to we
# can do the push tests over it

killall git-daemon
54

55 56 57 58 59 60 61
# Set up sshd
mkdir ~/sshd/
cat >~/sshd/sshd_config<<-EOF
	Port 2222
	ListenAddress 0.0.0.0
	Protocol 2
	HostKey ${HOME}/sshd/id_rsa
62
	PidFile ${HOME}/sshd/pid
63 64 65 66 67 68 69 70 71 72 73
	RSAAuthentication yes
	PasswordAuthentication yes
	PubkeyAuthentication yes
	ChallengeResponseAuthentication no
	# Required here as sshd will simply close connection otherwise
	UsePAM no
EOF
ssh-keygen -t rsa -f ~/sshd/id_rsa -N "" -q
/usr/sbin/sshd -f ~/sshd/sshd_config

# Set up keys
74 75
ssh-keygen -t rsa -f ~/.ssh/id_rsa -N "" -q
cat ~/.ssh/id_rsa.pub >>~/.ssh/authorized_keys
76 77 78
while read algorithm key comment; do
    echo "[localhost]:2222 $algorithm $key" >>~/.ssh/known_hosts
done <~/sshd/id_rsa.pub
79

80 81 82
# Get the fingerprint for localhost and remove the colons so we can parse it as
# a hex number. The Mac version is newer so it has a different output format.
if [ "$TRAVIS_OS_NAME" = "osx" ]; then
83
    export GITTEST_REMOTE_SSH_FINGERPRINT=$(ssh-keygen -E md5 -F '[localhost]:2222' -l | tail -n 1 | cut -d ' ' -f 3 | cut -d : -f2- | tr -d :)
84
else
85
    export GITTEST_REMOTE_SSH_FINGERPRINT=$(ssh-keygen -F '[localhost]:2222' -l | tail -n 1 | cut -d ' ' -f 2 | tr -d ':')
86
fi
87

88
# Use the SSH server
89
export GITTEST_REMOTE_URL="ssh://localhost:2222/$HOME/_temp/test.git"
90 91 92 93
export GITTEST_REMOTE_USER=$USER
export GITTEST_REMOTE_SSH_KEY="$HOME/.ssh/id_rsa"
export GITTEST_REMOTE_SSH_PUBKEY="$HOME/.ssh/id_rsa.pub"
export GITTEST_REMOTE_SSH_PASSPHRASE=""
94 95
ctest -V -R libgit2_clar-ssh || exit $?

96 97 98 99
# Use the proxy we started at the beginning
export GITTEST_REMOTE_PROXY_URL="localhost:8080"
export GITTEST_REMOTE_PROXY_USER="foo"
export GITTEST_REMOTE_PROXY_PASS="bar"
100
ctest -V -R libgit2_clar-proxy_credentials || exit $?
101

102
kill $(cat "$HOME/sshd/pid")