This repository has been archived by the owner on Jun 21, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
.drone.yml
125 lines (122 loc) · 5.11 KB
/
.drone.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
kind: pipeline
name: default
steps:
- name: integration
image: enigmampc/docker-client
privileged: true
volumes:
- name: sock
path: /var/run/docker.sock
commands:
- export MATCHING_BRANCH_CORE="$(git ls-remote --heads https://github.com/enigmampc/enigma-core.git ${DRONE_BRANCH} | wc -l)"
- export MATCHING_BRANCH_CONTRACT="$(git ls-remote --heads https://github.com/enigmampc/enigma-contract.git ${DRONE_BRANCH} | wc -l)"
- export MATCHING_BRANCH_DOCKER="$(git ls-remote --heads https://github.com/enigmampc/docker-environment.git ${DRONE_BRANCH} | wc -l)"
- export MATCHING_BRANCH_INTEGRATION="$(git ls-remote --heads https://github.com/enigmampc/integration-tests.git ${DRONE_BRANCH} | wc -l)"
- export DOCKER_TAG=p2p_${DRONE_BUILD_NUMBER}
- |
if [[ "$MATCHING_BRANCH_DOCKER" -eq 1 ]]; then
# which includes master and develop because these always exist
git clone --single-branch --branch ${DRONE_BRANCH} https://github.com/enigmampc/docker-environment.git
else
# otherwise we are on a feature branch, and we will build against develop
git clone --single-branch --branch develop https://github.com/enigmampc/docker-environment.git
fi
- cd docker-environment
- cp .env.template .env
- sed -i "s/COMPOSE_PROJECT_NAME=.*/COMPOSE_PROJECT_NAME=enigma_p2p_${DRONE_BUILD_NUMBER}/" .env
- sed -i "s/DOCKER_TAG=latest/DOCKER_TAG=${DOCKER_TAG}/" .env
- |
/bin/bash -c '
declare -a PROJECTS=(contract client)
declare -A DOCKER_IMAGES=([contract]=contract [client]=client)
declare -A PROJECT_BRANCH_FOUND=([contract]=$MATCHING_BRANCH_CONTRACT [client]=$MATCHING_BRANCH_INTEGRATION)
for project in $${PROJECTS[@]}; do
DOCKER_IMAGE="enigmampc/$${DOCKER_IMAGES[$project]}"
if [ "$${PROJECT_BRANCH_FOUND[$project]}" -eq 0 ]; then
docker pull "$DOCKER_IMAGE:develop"
docker tag "$DOCKER_IMAGE:develop" "$DOCKER_IMAGE:$DOCKER_TAG"
else
if [[ "$project" == "contract" ]]; then
make clone-contract BRANCH=${DRONE_BRANCH}
make build-contract DOCKER_TAG=$DOCKER_TAG
else
make clone-client-solo BRANCH=${DRONE_BRANCH}
make build-client DOCKER_TAG=$DOCKER_TAG
fi
fi
done'
- make clone-p2p BRANCH=${DRONE_BRANCH}
- |
if [[ "$MATCHING_BRANCH_CORE" -eq 1 ]]; then
make clone-core BRANCH=${DRONE_BRANCH}
make build-core DOCKER_TAG=$DOCKER_TAG
make clone-km BRANCH=${DRONE_BRANCH}
make build-km DOCKER_TAG=$DOCKER_TAG
else
docker pull enigmampc/key_management_hw:develop
docker tag "enigmampc/key_management_hw:develop" "enigmampc/key_management_hw:$DOCKER_TAG"
docker pull enigmampc/core-artifact-hw:develop
docker tag "enigmampc/core-artifact-hw:develop" "enigmampc/core-artifact-hw:$DOCKER_TAG"
fi
- make build-worker DOCKER_TAG=$DOCKER_TAG
- export NODES=3
- SGX_MODE=HW docker-compose -f docker-compose.yml -f docker-compose.hw.yml up --scale worker=$NODES &
- sleep 240
- docker-compose exec -T client make test
- name: deploy
image: enigmampc/docker-client
depends_on:
- integration
when:
branch:
- develop
- master
privileged: true
volumes:
- name: sock
path: /var/run/docker.sock
environment:
USERNAME:
from_secret: username
PASSWORD:
from_secret: password
commands:
- cd docker-environment
- echo $PASSWORD | docker login -u $USERNAME --password-stdin
- if [[ ${DRONE_BRANCH} == "master" ]]; then export DOCKER_TAG=latest; else export DOCKER_TAG=develop; fi
- make clone-core BRANCH=${DRONE_BRANCH}
- make clone-p2p BRANCH=${DRONE_BRANCH}
- make clone-km BRANCH=${DRONE_BRANCH}
- make build-core SGX_MODE=SW DOCKER_TAG=$DOCKER_TAG
- make build-km SGX_MODE=SW DOCKER_TAG=$DOCKER_TAG
- make build-worker SGX_MODE=SW DOCKER_TAG=$DOCKER_TAG
- make build-core DOCKER_TAG=$DOCKER_TAG
- make build-km DOCKER_TAG=$DOCKER_TAG
- make build-worker DOCKER_TAG=$DOCKER_TAG
- docker push enigmampc/core-artifact-sw:$DOCKER_TAG
- docker push enigmampc/worker_sw:$DOCKER_TAG
- docker push enigmampc/key_management_sw:$DOCKER_TAG
- docker push enigmampc/core-artifact-hw:$DOCKER_TAG
- docker push enigmampc/worker_hw:$DOCKER_TAG
- docker push enigmampc/key_management_hw:$DOCKER_TAG
- name: cleanup
image: enigmampc/docker-client
privileged: true
volumes:
- name: sock
path: /var/run/docker.sock
depends_on:
- deploy
when:
status:
- success
- failure
commands:
- cd docker-environment
- export DOCKER_TAG=p2p_${DRONE_BUILD_NUMBER}
- docker-compose -f docker-compose.yml -f docker-compose.hw.yml down -v --rmi all --remove-orphans
- docker rmi -f enigmampc/core-artifact-hw:$DOCKER_TAG
volumes:
- name: sock
host:
path: /var/run/docker.sock