.gitlab-ci.yml 6.5 KB
Newer Older
1
2
3
4
5
6
#
# CI for Aegir Hosting System
#
# For docs see http://docs.aegirproject.org
# and http://docs.aegirproject.org/en/3.x/community/release-process/#setting-up-a-gitlab-runner

7
8
9
10
11
12
# Is performed before the scripts in the stages step
before_script:
  - source /etc/profile

# Defines stages which are to be executed
stages:
helmo's avatar
helmo committed
13
  - syntax
14
15
  - build
  - test
helmo's avatar
helmo committed
16
  - publish
17
  - upgradetest
18

19

helmo's avatar
helmo committed
20
21
22
23
#
### Stage syntax
#

helmo's avatar
helmo committed
24
syntax:lint:
helmo's avatar
helmo committed
25
  stage: syntax
helmo's avatar
helmo committed
26
  image: bobey/docker-gitlab-ci-runner-php5.6
helmo's avatar
helmo committed
27
28
  allow_failure: false

helmo's avatar
helmo committed
29
30
31
32
33
  script:
    - composer require phplint/phplint
    - echo "Syntax checking PHP files"
    - echo "For more information http://www.icosaedro.it/phplint/"
    - vendor/bin/phplint ./ --exclude "vendor"
helmo's avatar
helmo committed
34

35
36
37
38
#
### Stage "build"
#

39
40
build:deb:
  stage: build
41
  image: aegir/hostmaster:packaging_base
42
43
44
  script:
    - export commit=$(git log -n 1 --oneline | sed 's/ .*$//')
    - export version=$(sed -ne 's/^[^(]*(\([^)]*\)).*/\1/;1p' debian/changelog)
45
46
    - export new_version="${version}+${CI_BUILD_ID}.${commit}"
    - dch -D unstable --newversion "$new_version" "automatic GitLab CI build ${CI_BUILD_ID}"
47
48
49
    - dpkg-buildpackage
    - mkdir build
    - mv -v ../aegir3*.deb build/
50
    - mv -v ../aegir-archive-keyring*.deb build/
helmo's avatar
helmo committed
51
    - mv -v ../aegir3*.tar.gz build/
helmo's avatar
helmo committed
52
    - mv -v ../aegir3*.dsc build/
helmo's avatar
helmo committed
53
    - mv -v ../aegir3*.changes build/
54
55
56
57
58
59
60

  # The files which are to be made available in GitLab as artifacts.
  artifacts:
    paths:
      - build/*


61
62
63
64
#
### Stage "test"
#

65
66
67
68
69
test:debian-jessie-aegir3-apt:
  stage: test
  image: debian:jessie
  dependencies:
    - build:deb
70
  only:
helmo's avatar
helmo committed
71
    - 7.x-3.x
72
    - /^7\.x-3\.\d+\.x/
73
    - /-runalltests$/
74
75
76
77
78
79
80
81

  before_script:
    - apt-get update
    # Avoid ERROR: invoke-rc.d: policy-rc.d denied execution of start.
    - echo "#!/bin/sh" > /usr/sbin/policy-rc.d
    - echo "exit 0" >> /usr/sbin/policy-rc.d
    - apt-get install --yes sudo curl

82
  script: "scripts/ci-aegir-dev-install-apt-debian8.sh"
83

helmo's avatar
helmo committed
84
85
86
test:debian-stretch-aegir3-apt:
  stage: test
  image: debian:stretch
87
  allow_failure: false
helmo's avatar
helmo committed
88
89
90
91
92
93
94
95
96
97
  dependencies:
    - build:deb

  before_script:
    - apt-get update
    # Avoid ERROR: invoke-rc.d: policy-rc.d denied execution of start.
    - echo "#!/bin/sh" > /usr/sbin/policy-rc.d
    - echo "exit 0" >> /usr/sbin/policy-rc.d
    - apt-get install --yes sudo curl

helmo's avatar
helmo committed
98
  script: "scripts/ci-aegir-dev-install-apt-debian9.sh"
helmo's avatar
helmo committed
99

100
101
102
103
104
test:ubuntu-xenial-aegir3-apt:
  stage: test
  image: ubuntu:xenial
  dependencies:
    - build:deb
helmo's avatar
helmo committed
105

106
  only:
107
    - 7.x-3.x
108
    - /^7\.x-3\.\d+\.x/
109
    - /-runalltests$/
110
111
112
113
114
115
116
117

  before_script:
    - apt-get update
    # Avoid ERROR: invoke-rc.d: policy-rc.d denied execution of start.
    - echo "#!/bin/sh" > /usr/sbin/policy-rc.d
    - echo "exit 0" >> /usr/sbin/policy-rc.d
    - apt-get install --yes sudo curl

helmo's avatar
helmo committed
118
  script: "scripts/ci-aegir-dev-install-apt-ubuntu-xenial.sh"
119

helmo's avatar
helmo committed
120
test:ubuntu-artful-aegir3-apt:
helmo's avatar
helmo committed
121
122
123
124
  stage: test
  image: ubuntu:artful
  dependencies:
    - build:deb
125

126
  only:
127
128
    - 7.x-3.x
    - /^7\.x-3\.\d+\.x/
129
    - /-runalltests$/
helmo's avatar
helmo committed
130
131
132
133
134
135
136
137

  before_script:
    - apt-get update
    # Avoid ERROR: invoke-rc.d: policy-rc.d denied execution of start.
    - echo "#!/bin/sh" > /usr/sbin/policy-rc.d
    - echo "exit 0" >> /usr/sbin/policy-rc.d
    - apt-get install --yes sudo curl

helmo's avatar
helmo committed
138
  script: "scripts/ci-aegir-dev-install-apt-ubuntu-artful.sh"
helmo's avatar
helmo committed
139

helmo's avatar
helmo committed
140
141
test:behat:
  stage: test
helmo's avatar
helmo committed
142
  image: aegir/hostmaster:packaging_base
helmo's avatar
helmo committed
143
144
  dependencies:
    - build:deb
145
  allow_failure: true
helmo's avatar
helmo committed
146
  variables:
helmo's avatar
syntax?    
helmo committed
147
    AEGIR_TESTS_VERSION: "master"
helmo's avatar
helmo committed
148
149

  before_script:
helmo's avatar
helmo committed
150
    - sudo apt-get update
helmo's avatar
helmo committed
151
152
153
154
    - sudo apt-get install --yes apt-transport-https ca-certificates curl gnupg2 software-properties-common
    - curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
    - sudo apt-key fingerprint 0EBFCD88
    - sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"
helmo's avatar
sudo    
helmo committed
155
    - sudo apt-get update
helmo's avatar
helmo committed
156
157
    - sudo apt-get install --yes docker-ce
    - docker info
helmo's avatar
helmo committed
158
159
160
161
162
163
164
165
166
167
    - git clone http://github.com/aegir-project/tests.git tests
    - cd tests
    - git checkout $AEGIR_TESTS_VERSION

      # Run prepare scripts.
    - cd travis
    - sudo bash prepare-docker.sh
    - bash prepare-testenv.sh

  script:
helmo's avatar
helmo committed
168

helmo's avatar
helmo committed
169
170
171
172
    # Tests are included in the docker-compose.yml file in the tests repo.
    - sudo docker-compose -f docker-compose-provision.yml run hostmaster


173
174
175
#
### Stage "publish"
#
helmo's avatar
helmo committed
176

helmo's avatar
helmo committed
177
178
179
180
181
publish:unstable-repo:
  stage: publish
  dependencies:
    - build:deb

182
183
  only:
    - 7.x-3.x
184
    - /^7\.x-3\.\d+\.x/
185

helmo's avatar
helmo committed
186
187
188
189
  image: ruby:2.1
  before_script:
    # install ssh-agent
    - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
helmo's avatar
helmo committed
190

helmo's avatar
helmo committed
191
192
    # run ssh-agent
    - eval $(ssh-agent -s)
helmo's avatar
helmo committed
193

helmo's avatar
helmo committed
194
195
    # add ssh key stored in SSH_PRIVATE_KEY variable to the agent store
    - ssh-add <(echo "$SSH_PRIVATE_KEY")
helmo's avatar
helmo committed
196
197

    - mkdir -p ~/.ssh
helmo's avatar
helmo committed
198
    - ls -la /.dockerenv
helmo's avatar
typo    
helmo committed
199
    - echo "$SSH_SERVER_HOSTKEYS" > ~/.ssh/known_hosts
helmo's avatar
helmo committed
200
    - cat ~/.ssh/known_hosts
helmo's avatar
helmo committed
201
202
203

  script:
    - ls -lah build/*
helmo's avatar
helmo committed
204
    - scp build/* ci@aegir0.aegir.coop:/var/www/repos/incoming/
helmo's avatar
helmo committed
205
      # reprepro should pick this up in seconds and update the repository index.
206
207


208
209
210
211
#
### Stage "upgradetest"
#

212
213
214
215
216
# Upgrade the latest stable Aegir to our unstable repo.
upgradetest:debian-jessie-aegir3-apt-upgrade:
  stage: upgradetest
  image: debian:jessie
  dependencies:
helmo's avatar
helmo committed
217
    - publish:unstable-repo
218

helmo's avatar
helmo committed
219
220
  when: manual

221
222
223
224
225
  before_script:
    - apt-get update
    # Avoid ERROR: invoke-rc.d: policy-rc.d denied execution of start.
    - echo "#!/bin/sh" > /usr/sbin/policy-rc.d
    - echo "exit 0" >> /usr/sbin/policy-rc.d
helmo's avatar
helmo committed
226
    - apt-get install --yes sudo curl cron
227
228

  script:
229
    - "scripts/ci-aegir-stable-install-apt-debian8.sh"
helmo's avatar
helmo committed
230
    # extra step to run the task queue.
helmo's avatar
helmo committed
231
    - sudo su aegir --login --command 'drush @hostmaster php-eval "echo hosting_task_count();"'
helmo's avatar
helmo committed
232
    - sudo su aegir --login --command 'drush @hostmaster hosting-tasks --force'
helmo's avatar
helmo committed
233
    - sudo su aegir --login --command 'drush @hostmaster php-eval "echo hosting_task_count();"'
helmo's avatar
helmo committed
234
    - sudo su aegir --login --command 'drush @hostmaster hosting-tasks --force'
helmo's avatar
helmo committed
235
    - sudo su aegir --login --command 'drush @hostmaster php-eval "echo hosting_task_count();"'
helmo's avatar
debug    
helmo committed
236
    - sudo su aegir --login --command 'drush @hostmaster php-eval "echo hosting_task_count_running();"'
helmo's avatar
helmo committed
237
238
    - sleep 2m
    - sudo su aegir --login --command 'drush @hostmaster php-eval "echo hosting_task_count_running();"'
239
240
    # upgrade to the latest version from the unstable repo.
    - rm -v /etc/apt/sources.list.d/aegir-stable.list
helmo's avatar
helmo committed
241
    - echo "deb http://debian.aegirproject.org unstable main" | sudo tee -a /etc/apt/sources.list.d/aegir-unstable.list
242
243
    - sudo apt-get update
    - sudo apt-get --yes upgrade