forked from contiki-ng/contiki-ng
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.yml
89 lines (84 loc) · 4.6 KB
/
.travis.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# Setup environment for Docker
language: generic
services: docker
dist: trusty
notifications:
email: false
git:
depth: false
# Environment setup before test script. Runs for each build
before_install:
# Construct the correct container image tag corresponding to this branch/pull
- CONTIKER_TAG=`git log -1 --oneline -- tools/docker/ | cut -d" " -f1`
- DOCKER_IMG=$DOCKER_BASE_IMG:$CONTIKER_TAG
# Try to download the image from dockerhub. If it works, use it.
#
# If however it fails then we are most likely looking at a branch or pull
# that touched tools/docker. In this case, build the image.
#
# Any build error will count as Travis test failure.
#
# If the test was triggered by a branch update (e.g. a PR merge) then push
# the new image to dockerhub. This will only happen for builds against
# contiki-ng/contiki-ng, not for builds on forks.
- echo "Will use $DOCKER_IMG for this run"
- >
echo "Pulling image $DOCKER_IMG from dockerhub";
docker pull $DOCKER_IMG;
if [ $? != 0 ]; then
echo $CONTIKER_TAG "does not exist or pull failed";
echo "This is normal for PR builds and for builds on forks";
echo "Building from dockerfile";
docker build tools/docker -t $DOCKER_IMG;
if [ $? != 0 ]; then
echo "Failed to build Docker image"
exit 1
fi
if [ $TRAVIS_REPO_SLUG == contiki-ng/contiki-ng ] && [ $TRAVIS_PULL_REQUEST == false ]; then
echo "This is a branch build that updates the container. Push image to Dockerhub"
echo $DOCKERHUB_PASSWD | docker login --username contiker --password-stdin
docker push $DOCKER_IMG;
if [ $TRAVIS_BRANCH == develop ] || [ $TRAVIS_BRANCH == master ]; then
echo "This is a merge in branch $TRAVIS_BRANCH";
echo "Push also $DOCKER_BASE_IMG:$TRAVIS_BRANCH";
docker tag $DOCKER_IMG $DOCKER_BASE_IMG:$TRAVIS_BRANCH;
docker push $DOCKER_BASE_IMG:$TRAVIS_BRANCH;
fi
fi
fi
# Create a directory for out of tree tests and clone the test repo therein
# The directory will need created unconditionally so we can always chgrp and
# mount it, even if empty. Checkout a pre-defined version.
- mkdir -p $OUT_OF_TREE_TEST_PATH
- if [ ${TEST_NAME} = "Builds" ] ; then
git clone --depth 1 https://github.com/contiki-ng/out-of-tree-tests $OUT_OF_TREE_TEST_PATH &&
(cd $OUT_OF_TREE_TEST_PATH && git checkout $OUT_OF_TREE_TEST_VER)
fi
# Set permissions for Docker mount
- sudo chgrp -hR 1000 $CNG_HOST_PATH $OUT_OF_TREE_TEST_PATH
# The test script for each build
script:
- 'printf "\n\n>>>>> Running suite: $TEST_NAME ($TESTS) <<<<<\n"'
- for TEST in $TESTS; do printf "\n\n--- Running test $TEST:\n"; docker run --privileged --sysctl net.ipv6.conf.all.disable_ipv6=0 -v $OUT_OF_TREE_TEST_PATH:/home/user/out-of-tree-tests -v $CNG_HOST_PATH:/home/user/contiki-ng -ti $DOCKER_IMG bash --login -c "make -C tests/??-$TEST"; done
# Check outcome of the test
- 'printf "\n\n>>>>>> Checking all tests <<<<<\n"'
- RET=0
- for TEST in $TESTS; do $CNG_HOST_PATH/tests/check-test.sh $CNG_HOST_PATH/tests/??-$TEST || RET=1; done
- exit $RET
# Environment variables
env:
# Global environment variables, i.e., set for all builds
global:
- DOCKER_BASE_IMG='contiker/contiki-ng'
- CNG_HOST_PATH=`pwd`
- OUT_OF_TREE_TEST_PATH=$HOME/out-of-tree-tests
- OUT_OF_TREE_TEST_VER=2869ae7
# Encrypted environment variables.
# Only available on builds of contiki-ng/contiki-ng branches, not PRs or forks.
- secure: 0nrV5yjpT2kE19Hlm7t619Qbmyjx/G7bSUI1c+U3kZbyuxnRlASjVcDN5uPBoimIfGiBRI0nRq690BogAJt4EKwbC1Dy8kC1XD8mRtQ2AIZ6PHaUoG9iS5sBhFBQK0XkB83bwh6omRn/04O0uuX74ooSWT7fDrWxi/y5+0ysXK6gRtOhdrJ3FU5OkNVewX8NeCdx3pOWhMOtXWdFkMIi1XRdDnvMM5/hHlHMkdXXtaZQX9UsK3Q3DSjPRLZjKRiOlcx9MIg2ebh9ITmd2Du2p2q/LKtoutJckvhbKQPWcZi/B+1ZTSff0FHBIg+EYxf6TeFuia7XSTWH7sr2CDCCtcvSR9bB5yW6jdmGfa8Af8I1TCBuqoSUo0Re50BZBZF7COleEh+IojbjXn2CIDMg5rT4Sh3qcMGvFn9OW1cz5h5UNSOk7EIAXXPcI7Aloxh2sBo4/DrvvbfIsKrvxV9Fx4bdyNtR7dZ7xsoOw6L0zttC3K9naf3VAOeBAyjBiRwm0tWxJC/buhTsKlYrthhyUrwLtYAFL4UHcazvz57hY/cEzR2X6F//9Hp7HFoNtn1E36doX3ZfeI22yxHMo9SYW7O69C45wbhJ29lAA9XXbYVyGBKFkY8C1NCZ0Xckt9H8/Ow5Sz8HmW/NNBJCn0Fsx+jezdGc4ED5naugNbLAyNg=
# Each line in the 'matrix' triggers a separate Travis build
matrix:
- TEST_NAME='Builds' TESTS='documentation compile-base compile-arm-ports compile-nxp-ports compile-tools out-of-tree-build'
- TEST_NAME='Cooja simulations' TESTS='rpl-lite rpl-classic simulation-base ipv6 ieee802154'
- TEST_NAME='Cooja + script' TESTS='tun-rpl-br'
- TEST_NAME='Script tests' TESTS='script-base native-runs ipv6-nbr coap-lwm2m packet-parsing'