.gitlab-ci.yml 5.52 KB
Newer Older
Patrick J Cherry's avatar
Patrick J Cherry committed
1
stages:
2
  - test
Patrick J Cherry's avatar
Patrick J Cherry committed
3
  - package
Patrick J Cherry's avatar
Patrick J Cherry committed
4
  - publish
telyn's avatar
telyn committed
5
  - install
6

Patrick J Cherry's avatar
Patrick J Cherry committed
7
.test: &test
8
  stage: test
Paul Cammish's avatar
Paul Cammish committed
9
  image: debian:stretch
10
  script:
Paul Cammish's avatar
Paul Cammish committed
11
12
13
    - apt-get update && apt-get install -q -yy rake devscripts rdoc graphviz ruby-dev
    - curl -L https://secure.bytemark.co.uk/key/repositories-2006.key | apt-key add -
    - curl -L https://secure.bytemark.co.uk/key/repositories-2014.key | apt-key add -
14
    - adduser --home=/srv --shell=/bin/bash --no-create-home --disabled-login --gecos='Symbiosis Administrator,,,' admin
Patrick J Cherry's avatar
Patrick J Cherry committed
15
    - chown admin.admin /srv
16
    - cp test/internal-test.d/conf-stretch/sources.list /etc/apt/sources.list.d/
Paul Cammish's avatar
Paul Cammish committed
17
    - "[ -z \"$TEST_DEPS\" ] || (apt-get update ; apt-get install -q -yy $TEST_DEPS)"
18
19
    - export PACKAGE=${CI_BUILD_NAME##test:}
    - cd $PACKAGE
Patrick J Cherry's avatar
Patrick J Cherry committed
20
    - "[ ! -f Makefile ] || make test"
21
22
23

test:backup:
  <<: *test
24

25
26
test:common:
  variables:
27
    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
28
  <<: *test
29

30
31
test:cron:
  <<: *test
32

33
test:dns:
34
  variables:
Patrick J Cherry's avatar
Patrick J Cherry committed
35
    TEST_DEPS: ruby-linux-netlink ruby-erubis ruby-diffy
36
  <<: *test
37

38
39
test:doc:
  <<: *test
40

41
test:email:
42
  variables:
43
    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
44
  <<: *test
45

46
test:firewall:
47
  variables:
Patrick J Cherry's avatar
Patrick J Cherry committed
48
    TEST_DEPS: ruby-linux-netlink ruby-sqlite3 netbase iptables
49
  <<: *test
50

51
test:ftpd:
52
53
  variables:
    TEST_DEPS: ruby-linux-netlink
54
  <<: *test
55

56
test:httpd:
57
  variables:
Patrick J Cherry's avatar
Patrick J Cherry committed
58
    RUBYOPT: -v
59
    TEST_DEPS: ruby-linux-netlink ruby-erubis apache2 ruby-diffy golang-go
60
  <<: *test
61

62
63
test:meta:
  <<: *test
64

65
test:monit:
Patrick J Cherry's avatar
Patrick J Cherry committed
66
  variables:
Patrick J Cherry's avatar
Patrick J Cherry committed
67
    TEST_DEPS: ruby-sqlite3 ruby-log4r ruby-dbus-systemd
68
  <<: *test
69

70
71
test:mysql:
  <<: *test
72

73
74
test:phpmyadmin:
  <<: *test
75

76
77
test:updater:
  <<: *test
78

79
80
test:webmail:
  <<: *test
81

82
83
test:xmpp:
  <<: *test
Patrick J Cherry's avatar
Patrick J Cherry committed
84
85

.package: &package
Paul Cammish's avatar
Paul Cammish committed
86
  image: debian:stretch
Patrick J Cherry's avatar
Patrick J Cherry committed
87
88
  stage: package
  script:
Paul Cammish's avatar
Paul Cammish committed
89
90
91
92
    - apt-get update && apt-get install -q -yy rake devscripts rdoc graphviz ruby-dev
    - curl -L https://secure.bytemark.co.uk/key/repositories-2006.key | apt-key add -
    - curl -L https://secure.bytemark.co.uk/key/repositories-2014.key | apt-key add -
    - apt-get update && apt-get install -q -yy gem2deb txt2man dh-systemd apache2-dev libcap-dev php7.0-common dh-golang golang-go
Patrick J Cherry's avatar
Patrick J Cherry committed
93
94
95
    - export PACKAGE=${CI_BUILD_NAME##package:}
    - echo "$CI_BUILD_NAME" -  "$PACKAGE" - "${CI_BUILD_NAME##package:}"
    - cd $PACKAGE
Paul Cammish's avatar
Paul Cammish committed
96
97
98
99
    - dpkg-buildpackage --no-sign --build=full
    - cd ..
    - mkdir pkg
    - mv $(git ls-files --others -x '*/') pkg
100
101
102
  artifacts:
    paths:
      - pkg/
Patrick J Cherry's avatar
Patrick J Cherry committed
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

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
Patrick J Cherry's avatar
Patrick J Cherry committed
136

Paul Cammish's avatar
Paul Cammish committed
137
# We publish to an artifact that should be usable as a Debian repository as-is
Patrick J Cherry's avatar
Patrick J Cherry committed
138
publish:
Paul Cammish's avatar
Paul Cammish committed
139
  image: debian:stretch
Patrick J Cherry's avatar
Patrick J Cherry committed
140
141
  stage: publish
  script:
Paul Cammish's avatar
Paul Cammish committed
142
143
144
145
146
147
    - apt-get update && apt-get install -q -yy dpkg-dev
    - dpkg-scanpackages pkg > pkg/Packages
    - gzip -k pkg/Packages
  artifacts:
    paths:
      - pkg/*
Patrick J Cherry's avatar
Patrick J Cherry committed
148

telyn's avatar
telyn committed
149
# fails on stretch for the time being - see issue #57 for updates
150
151
.install: &install
  stage: install
152
  tags:
telyn's avatar
telyn committed
153
154
    - systemd-containers
  before_script:
155
    - MACHINE=$CI_BUILD_ID-symbiosis-$DEBIAN_RELEASE-$ACTION
telyn's avatar
telyn committed
156
    - HOSTNAME=$MACHINE.localdomain
telyn's avatar
telyn committed
157
    - RUN_ARGS="--wait --quiet --pty --machine $MACHINE"
telyn's avatar
telyn committed
158
    - |
telyn's avatar
telyn committed
159
      if [ "$ACTION" = "dist-upgrade" ]; then
telyn's avatar
telyn committed
160
        machinectl clone ${OLD_DEBIAN_RELEASE} $MACHINE
telyn's avatar
telyn committed
161
162
      else
        machinectl clone ${DEBIAN_RELEASE} $MACHINE
telyn's avatar
telyn committed
163
      fi
164
    - machinectl start $MACHINE
telyn's avatar
telyn committed
165
    - |
166
      while [ "$IP" = "" ]; do
telyn's avatar
telyn committed
167
168
          export IP=$(get-machine-ip $MACHINE)
          sleep 3
169
      done
telyn's avatar
telyn committed
170
    - machinectl copy-to $MACHINE test/internal-test.d /root/test.d
171
  script:
172
    - |
173
      cat > run-test <<END_OF_INTERNAL_TEST
174
      #!/bin/bash
175
      set -e
176

telyn's avatar
exports    
telyn committed
177
178
179
180
      export ACTION=$ACTION
      export DEBIAN_RELEASE=$DEBIAN_RELEASE
      export OLD_DEBIAN_RELEASE=$OLD_DEBIAN_RELEASE
      export BRANCH_NAME=$CI_BUILD_REF_SLUG
telyn's avatar
telyn committed
181
      export HOSTNAME=$HOSTNAMR
182

telyn's avatar
telyn committed
183
184
185
      echo "$HOSTNAME" | tee /etc/hostname
      echo "$IP $HOSTNAME" | tee -a /etc/hosts
      hostname $HOSTNAME
186

187
      /bin/run-parts --exit-on-error /root/test.d/
188
      END_OF_INTERNAL_TEST
189
    - sed -e 's/32;/34;/g' -i run-test
190
191
    - chmod +x run-test
    - machinectl copy-to $MACHINE run-test /run-test
telyn's avatar
telyn committed
192
    - ssh -o StrictHostKeyChecking=false -o UserKnownHostsFile=/dev/null root@$IP /run-test
193
    - run-parts --verbose --exit-on-error test/external-test.d
telyn's avatar
telyn committed
194
  after_script:
195
    - MACHINE=$CI_BUILD_ID-symbiosis-$DEBIAN_RELEASE-$ACTION
196
197
198
199
200
    - |
      while machinectl status $MACHINE > /dev/null; do
          machinectl stop $MACHINE || true
          sleep 1
      done
telyn's avatar
telyn committed
201
    - machinectl remove $MACHINE
202
  dependencies: []
telyn's avatar
telyn committed
203
  variables: &installvars
telyn's avatar
telyn committed
204
205
    DEBIAN_RELEASE: stretch
    OLD_DEBIAN_RELEASE: jessie
Paul Cammish's avatar
Paul Cammish committed
206
  when: manual
207

208
209
install:fresh-install:
  <<: *install
telyn's avatar
telyn committed
210
  variables:
telyn's avatar
telyn committed
211
    <<: *installvars
telyn's avatar
telyn committed
212
    ACTION: install
telyn's avatar
telyn committed
213
214
215

install:upgrade:
  <<: *install
216
  allow_failure: true
telyn's avatar
telyn committed
217
  variables:
telyn's avatar
telyn committed
218
    <<: *installvars
telyn's avatar
telyn committed
219
    ACTION: upgrade
220

telyn's avatar
telyn committed
221
install:dist-upgrade:
222
  <<: *install
223
  allow_failure: true
telyn's avatar
telyn committed
224
  variables:
telyn's avatar
telyn committed
225
    <<: *installvars
telyn's avatar
telyn committed
226
    ACTION: dist-upgrade
Patrick J Cherry's avatar
Patrick J Cherry committed
227