-
Notifications
You must be signed in to change notification settings - Fork 6
/
wercker.yml
94 lines (93 loc) · 3.66 KB
/
wercker.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
box: cosyverif/environment:master
build:
steps:
- script:
name: "Build server"
code: |
./bin/build-server --in-ci --prefix=/app
- script:
name: "Build client"
code: |
./bin/build-client --in-ci --prefix=/app
- script:
name: "Fix permissions"
code: |
chown -R root.users /app
- script:
name: "Check server"
code: |
export CPATH="/app/include:${CPATH}"
export LIBRARY_PATH="/app/lib:${LIBRARY_PATH}"
export LD_LIBRARY_PATH="/app/lib:${LD_LIBRARY_PATH}"
/app/bin/cosy-check --output=. --test-format=junit
- script:
name: "Check client"
code: |
export CPATH="/app/include:${CPATH}"
export LIBRARY_PATH="/app/lib:${LIBRARY_PATH}"
export LD_LIBRARY_PATH="/app/lib:${LD_LIBRARY_PATH}"
/app/bin/cosy-server start --port=8080 --clean
./cosy-client-*.sh --target client
./tests/user.sh default ./client/bin/cosy --server=http://127.0.0.1:8080/
/app/bin/cosy-server stop
deploy:
luarocks:
- script:
name: Upload to luarocks
code: |
tag=$(git describe --tags --abbrev=0)
count=$(git rev-list --count HEAD ^"${tag}")
cd rockspec
sed -e "s/master-1/${tag}-${count}/" cosy-client-master-1.rockspec > cosy-client-"${tag}"-"${count}".rockspec
sed -e "s/master-1/${tag}-${count}/" cosy-master-1.rockspec > cosy-"${tag}"-"${count}".rockspec
/app/bin/luarocks upload cosy-client-"${tag}"-"${count}".rockspec --api-key=$LUAROCKS_API_KEY
/app/bin/luarocks upload cosy-"${tag}"-"${count}".rockspec --api-key=$LUAROCKS_API_KEY
steps:
- add-to-known_hosts:
hostname: $DEPLOY_SERVER
- mktemp:
envvar: PRIVATEKEY_PATH
- create-file:
name: Write key
filename: $PRIVATEKEY_PATH
content: $KEYPAIR_PRIVATE
overwrite: true
hide-from-log: true
- script:
name: Stop
code: |
ssh -i $PRIVATEKEY_PATH $DEPLOY_USERNAME@$DEPLOY_SERVER <<EOF
"./install/$WERCKER_GIT_BRANCH/bin/cosy-server" stop --alias="$WERCKER_GIT_BRANCH" || true
EOF
- script:
name: Create directories
code: |
ssh -i $PRIVATEKEY_PATH $DEPLOY_USERNAME@$DEPLOY_SERVER <<EOF
mkdir -p "/home/cosy/sources"
mkdir -p "/home/cosy/install"
mkdir -p "/home/cosy/.cosy"
mkdir -p "/home/cosy/.cosy/$WERCKER_GIT_BRANCH"
EOF
- script:
name: Build
code: |
ssh -i $PRIVATEKEY_PATH $DEPLOY_USERNAME@$DEPLOY_SERVER <<EOF
rm -rf "sources/$WERCKER_GIT_BRANCH"
git clone "https://github.com/$WERCKER_GIT_OWNER/$WERCKER_GIT_REPOSITORY" "sources/$WERCKER_GIT_BRANCH"
cd "sources/$WERCKER_GIT_BRANCH"
git checkout "$WERCKER_GIT_BRANCH"
./bin/build-server --prefix="/home/cosy/install/$WERCKER_GIT_BRANCH"
EOF
- script:
name: Copy database
code: |
if [ "$WERCKER_GIT_BRANCH" != "master" ]; then
ssh -i $PRIVATEKEY_PATH $DEPLOY_USERNAME@$DEPLOY_SERVER <<EOF
cp "/home/cosy/.cosy/master/redis.db" "/home/cosy/.cosy/$WERCKER_GIT_BRANCH/redis.db" || true
cp "/home/cosy/.cosy/master/redis.append" "/home/cosy/.cosy/$WERCKER_GIT_BRANCH/redis.append" || true
EOF
fi
- script:
name: Start
code: |
ssh -f -i $PRIVATEKEY_PATH $DEPLOY_USERNAME@$DEPLOY_SERVER "./install/$WERCKER_GIT_BRANCH/bin/cosy-server" start --alias="$WERCKER_GIT_BRANCH" --port="$DEPLOY_PORT"