forked from CounterpartyXCP/counterparty-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.yml
56 lines (50 loc) · 2.69 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
sudo: required
services:
- docker
env:
global:
# define DOCKER_USERNAME and DOCKER_PASSWORD
- secure: "NZZCFpX/ubtrMHxU3C6+HkV+mrSUIAqRLXKySBiUJeiKaOsiVUl1AMd1cKQOrDp59dIFmjMvH+HGFbAKt3QvTcTImx0yye09bsXNKUKIQbVElnoZvkP6pZSxXAFcmjZdUGTfMSMkLukrXHgLb5ob2ziBCinJBoG57tgcUJnoZTc="
- secure: "d4TXRnQ4QffUFILVN6Hn7DA55unGDk0H6vZsmDRxP3ucLrUC/j8ko3Tm9jDeHZvVxGUe/e0dNXQ1WjaialCpB/h+rrnCEFExk9+oeUhhzn9GVOp488jqoiIwQxYM8cEh5I8Fh8lztBwaLnaI/MgRougFuOs3Ocf3v2IhBgvcwGs="
before_install:
- sudo apt-get -qq update
# add coveralls
- sudo apt-get -y install python3 python3-pip
- sudo pip3 install coveralls
# upgrade docker, for build argument support
- sudo apt-get install -o Dpkg::Options::="--force-confold" --force-yes -y docker-ce
- docker version
- docker ps -a
# get the current PR and branch name
- sudo apt-get -y install jq
- export PR=https://api.github.com/repos/$TRAVIS_REPO_SLUG/pulls/$TRAVIS_PULL_REQUEST
- export BRANCH=$(if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then echo $TRAVIS_BRANCH; else echo `curl -s $PR | jq -r .head.ref`; fi)
- echo $PR
- echo $BRANCH
# determine the docker image tag name ("nopush" being a placeholder to signify the image will not be pushed to dockerhub)
- export DOCKER_TAG="nopush"
- |
if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
if [ "$BRANCH" == "master" ]; then export DOCKER_TAG="latest"; fi
if [ "$BRANCH" == "develop" ]; then export DOCKER_TAG="develop"; fi
fi
- echo $DOCKER_TAG
# try to check out the same branch for counterparty-lib (if it exists), and fallback to the develop branch if not
- if curl --output /dev/null --silent --head --fail "https://github.com/CounterpartyXCP/counterparty-cli/tree/$BRANCH"; then export DOCKERFILE_CLI_BRANCH="$BRANCH"; else export DOCKERFILE_CLI_BRANCH="develop"; fi
- echo $DOCKERFILE_CLI_BRANCH
# build docker image
- docker build -t counterparty/counterparty-server:$DOCKER_TAG --build-arg CLI_BRANCH="$DOCKERFILE_CLI_BRANCH" .
script:
# run the test suite in the docker container we just made
- docker run --entrypoint=/bin/bash counterparty/counterparty-server:$DOCKER_TAG -c "cd /counterparty-lib/counterpartylib; py.test --verbose --skiptestbook=all --cov-config=../.coveragerc --cov-report=term-missing --cov=./"
after_success:
- coveralls
# if it's master or develop, then push the appropirately tagged docker image (otherwise don't push anything)
- |
if [ "$DOCKER_TAG" != "nopush" ]; then
docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD";
docker push counterparty/counterparty-server:$DOCKER_TAG;
fi
notifications:
slack:
secure: cl0G5fWZNnIK5VQ6BPZ4RtwVO2/nfvX/zjhljfF6cQ20OKyvyiJHq+e67fl2pkCKDlqlEqSWaQJ6G52YzUpDQmf+o7qpH6YnkFxSqYp5h4YF1hJw4sCHJ7bVSLrjogWxU8QaNvH7YpL4YkGe+WOau2FgoIZOcMt6hhKrvWclfuc=