forked from BytemarkHosting/symbiosis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
214 lines (186 loc) · 4.75 KB
/
.gitlab-ci.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
stages:
- test
- package
- publish
- install
.test: &test
stage: test
image: $CI_REGISTRY/docker-images/layers:stretch-ruby
script:
- adduser --home=/srv --shell=/bin/bash --no-create-home --disabled-login --gecos='Symbiosis Administrator,,,' admin
- chown admin.admin /srv
- cp test/internal-test.d/conf-stretch/sources.list /etc/apt/sources.list.d/
- "[ -z \"$TEST_DEPS\" ] || (apt-get update ; apt-get install $TEST_DEPS)"
- export PACKAGE=${CI_BUILD_NAME##test:}
- cd $PACKAGE
- "[ ! -f Makefile ] || make test"
test:backup:
<<: *test
test:common:
variables:
TEST_DEPS: ruby ruby-acme-client ruby-linux-netlink ruby-cracklib ruby-erubis ruby-mocha ruby-webmock ruby-test-unit openssl cracklib-runtime ruby-diffy
<<: *test
test:cron:
<<: *test
test:dns:
variables:
TEST_DEPS: ruby-linux-netlink ruby-erubis ruby-diffy
<<: *test
test:doc:
<<: *test
test:email:
variables:
TEST_DEPS: exim4-daemon-heavy dovecot-common dovecot-core dovecot-sieve dovecot-managesieved dovecot-imapd dovecot-pop3d ruby-linux-netlink ruby-eventmachine ruby-cracklib cracklib-runtime ruby-mocha
<<: *test
test:firewall:
variables:
TEST_DEPS: ruby-linux-netlink ruby-sqlite3 netbase iptables
<<: *test
test:ftpd:
variables:
TEST_DEPS: ruby-linux-netlink
<<: *test
test:httpd:
variables:
RUBYOPT: -v
TEST_DEPS: ruby-linux-netlink ruby-erubis apache2 ruby-diffy golang-go
<<: *test
test:meta:
<<: *test
test:monit:
variables:
TEST_DEPS: ruby-sqlite3 ruby-log4r ruby-dbus-systemd
<<: *test
test:mysql:
<<: *test
test:phpmyadmin:
<<: *test
test:updater:
<<: *test
test:webmail:
<<: *test
test:xmpp:
<<: *test
.package: &package
image: $CI_REGISTRY/docker-images/layers:stretch-deb
stage: package
script:
- cp symbiosis.list /etc/apt/sources.list.d/
- apt-get update
- export PACKAGE=${CI_BUILD_NAME##package:}
- echo "$CI_BUILD_NAME" - "$PACKAGE" - "${CI_BUILD_NAME##package:}"
- cd $PACKAGE
- package
artifacts:
paths:
- pkg/
package:common:
<<: *package
package:backup:
<<: *package
package:cron:
<<: *package
package:dns:
<<: *package
package:doc:
<<: *package
package:email:
<<: *package
package:firewall:
<<: *package
package:ftpd:
<<: *package
package:httpd:
<<: *package
package:meta:
<<: *package
package:monit:
<<: *package
package:mysql:
<<: *package
package:phpmyadmin:
<<: *package
package:updater:
<<: *package
package:webmail:
<<: *package
package:xmpp:
<<: *package
publish:
stage: publish
variables:
RSYNC_HOSTNAME: repo.bytemark.co.uk
image: $CI_REGISTRY/docker-images/layers:stretch-publish
script:
- publish
# fails on stretch for the time being - see issue #57 for updates
.install: &install
stage: install
tags:
- systemd-containers
before_script:
- MACHINE=$CI_BUILD_ID-symbiosis-$DEBIAN_RELEASE-$ACTION
- HOSTNAME=$MACHINE.localdomain
- RUN_ARGS="--wait --quiet --pty --machine $MACHINE"
- |
if [ "$ACTION" = "dist-upgrade" ]; then
machinectl clone ${OLD_DEBIAN_RELEASE} $MACHINE
else
machinectl clone ${DEBIAN_RELEASE} $MACHINE
fi
- machinectl start $MACHINE
- |
while [ "$IP" = "" ]; do
export IP=$(get-machine-ip $MACHINE)
sleep 3
done
- machinectl copy-to $MACHINE test/internal-test.d /root/test.d
script:
- |
cat > run-test <<END_OF_INTERNAL_TEST
#!/bin/bash
set -e
export ACTION=$ACTION
export DEBIAN_RELEASE=$DEBIAN_RELEASE
export OLD_DEBIAN_RELEASE=$OLD_DEBIAN_RELEASE
export BRANCH_NAME=$CI_BUILD_REF_SLUG
export HOSTNAME=$HOSTNAMR
echo "$HOSTNAME" | tee /etc/hostname
echo "$IP $HOSTNAME" | tee -a /etc/hosts
hostname $HOSTNAME
/bin/run-parts --exit-on-error /root/test.d/
END_OF_INTERNAL_TEST
- sed -e 's/32;/34;/g' -i run-test
- chmod +x run-test
- machinectl copy-to $MACHINE run-test /run-test
- ssh -o StrictHostKeyChecking=false -o UserKnownHostsFile=/dev/null root@$IP /run-test
- run-parts --verbose --exit-on-error test/external-test.d
after_script:
- MACHINE=$CI_BUILD_ID-symbiosis-$DEBIAN_RELEASE-$ACTION
- |
while machinectl status $MACHINE > /dev/null; do
machinectl stop $MACHINE || true
sleep 1
done
- machinectl remove $MACHINE
dependencies: []
variables: &installvars
DEBIAN_RELEASE: stretch
OLD_DEBIAN_RELEASE: jessie
install:fresh-install:
<<: *install
variables:
<<: *installvars
ACTION: install
install:upgrade:
<<: *install
allow_failure: true
variables:
<<: *installvars
ACTION: upgrade
install:dist-upgrade:
<<: *install
allow_failure: true
variables:
<<: *installvars
ACTION: dist-upgrade