-
Notifications
You must be signed in to change notification settings - Fork 0
/
ci_setup.sh
executable file
·66 lines (61 loc) · 1.68 KB
/
ci_setup.sh
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
#!/usr/bin/env bash
# Remove all containers and volumes
echo "Docker cleanup"
docker-compose down --rmi all -v --remove-orphans
sudo docker volume prune -f
if [ -v "$CHANGE_ID" ]
then
BRANCH="$GIT_BRANCH"
else
BRANCH="origin/pr/$CHANGE_ID"
fi
echo "CHANGE_ID: ${CHANGE_ID}"
# check if custom ckan image should be built
git diff -s --exit-code ./ckan
if [ $? == 1 ]; then
CKAN_IMAGE_TAG="$CHANGE_BRANCH"
export CKAN_IMAGE_TAG
echo "CKAN_IMAGE_TAG: ${CKAN_IMAGE_TAG}"
fi
echo "Preparing environment"
cd ../
# add adx script to PATH
export PATH=$WORKSPACE/adx_develop/:$PATH
# disable db restart during test setup
export SKIP_DB_RESTART=True
# prepare environment
cp "$WORKSPACE"/adx_develop/dev.env "$WORKSPACE"/adx_develop/.env
# Init submodules
adx init
# Setup environment
yes | adx setup
git fetch origin +refs/pull/*/merge:refs/remotes/origin/pr/* && git checkout "${BRANCH}"
cd "$WORKSPACE"/adx_develop/ && git fetch origin +refs/pull/*/merge:refs/remotes/origin/pr/* && git checkout "${BRANCH}"
cd "$WORKSPACE" || exit
echo "running ./adx build"
adx build
echo "running ./adx up"
adx up
echo "Running ./adx testsetup"
adx testsetup
echo "Show docker-compose containers"
adx dc ps
echo "Waiting for CKAN container"
counter=0
while ! docker logs ckan |grep 'CKAN bootstrapping finished, environment ready';
do
((counter=counter+1))
if [ $counter -ge 80 ]; then
echo "This is taking too long, break!"
echo "Some logs first:"
echo "CKAN container logs:"
docker logs ckan
echo "DB container logs:"
docker logs db
echo "List of containers:"
adx dc ps
exit 1
fi
echo "Bootstraping not finished, pass $counter"
sleep 10
done