.gitlab-ci.yml 7.06 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:
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

118
  script: "scripts/ci-aegir-dev-install-apt-ubuntu-xenial.sh"
119

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

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

140 141 142 143 144 145 146 147

test:debian-stretch-aegir3-cluster-slave-apt:
  stage: test
  image: debian:stretch
  allow_failure: false
  dependencies:
    - build:deb

148 149 150 151 152
  only:
    - 7.x-3.x
    - /^7\.x-3\.\d+\.x/
    - /-runalltests$/

153 154 155 156 157 158 159 160 161
  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

  script: "scripts/ci-aegir-dev-install-apt-debian9-cluster-slave.sh"

helmo's avatar
helmo committed
162 163
test:behat:
  stage: test
164
  image: aegir/hostmaster:packaging_base
helmo's avatar
helmo committed
165 166
  dependencies:
    - build:deb
167
  allow_failure: true
helmo's avatar
helmo committed
168
  variables:
helmo's avatar
helmo committed
169
    AEGIR_TESTS_VERSION: "master"
helmo's avatar
helmo committed
170 171

  before_script:
helmo's avatar
helmo committed
172
    - sudo apt-get update
173 174 175 176
    - 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
helmo committed
177
    - sudo apt-get update
178 179
    - sudo apt-get install --yes docker-ce
    - docker info
helmo's avatar
helmo committed
180 181 182 183 184 185 186 187 188 189
    - 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:
190

helmo's avatar
helmo committed
191 192 193 194
    # Tests are included in the docker-compose.yml file in the tests repo.
    - sudo docker-compose -f docker-compose-provision.yml run hostmaster


195 196 197
#
### Stage "publish"
#
198

helmo's avatar
helmo committed
199 200 201 202 203
publish:unstable-repo:
  stage: publish
  dependencies:
    - build:deb

204 205
  only:
    - 7.x-3.x
206
    - /^7\.x-3\.\d+\.x/
207

helmo's avatar
helmo committed
208 209 210 211
  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
212

helmo's avatar
helmo committed
213 214
    # run ssh-agent
    - eval $(ssh-agent -s)
helmo's avatar
helmo committed
215

helmo's avatar
helmo committed
216 217
    # add ssh key stored in SSH_PRIVATE_KEY variable to the agent store
    - ssh-add <(echo "$SSH_PRIVATE_KEY")
helmo's avatar
helmo committed
218 219

    - mkdir -p ~/.ssh
helmo's avatar
helmo committed
220
    - ls -la /.dockerenv
helmo's avatar
helmo committed
221
    - echo "$SSH_SERVER_HOSTKEYS" > ~/.ssh/known_hosts
helmo's avatar
helmo committed
222
    - cat ~/.ssh/known_hosts
helmo's avatar
helmo committed
223 224 225

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


230 231 232 233
#
### Stage "upgradetest"
#

234 235 236 237 238
# 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
239
    - publish:unstable-repo
240

241 242 243 244
  only:
    - 7.x-3.x
    - /^7\.x-3\.\d+\.x/
    - /-runalltests$/
helmo's avatar
helmo committed
245

246 247 248 249 250
  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
251
    - apt-get install --yes sudo curl cron
252 253

  script:
254
    - "scripts/ci-aegir-stable-install-apt-debian8.sh"
helmo's avatar
helmo committed
255
    # extra step to run the task queue.
helmo's avatar
helmo committed
256
    - sudo su aegir --login --command 'drush @hostmaster php-eval "echo hosting_task_count();"'
helmo's avatar
helmo committed
257
    - sudo su aegir --login --command 'drush @hostmaster hosting-tasks --force'
helmo's avatar
helmo committed
258
    - sudo su aegir --login --command 'drush @hostmaster php-eval "echo hosting_task_count();"'
helmo's avatar
helmo committed
259
    - sudo su aegir --login --command 'drush @hostmaster hosting-tasks --force'
helmo's avatar
helmo committed
260
    - sudo su aegir --login --command 'drush @hostmaster php-eval "echo hosting_task_count();"'
helmo's avatar
helmo committed
261
    - sudo su aegir --login --command 'drush @hostmaster php-eval "echo hosting_task_count_running();"'
helmo's avatar
helmo committed
262 263
    - sleep 2m
    - sudo su aegir --login --command 'drush @hostmaster php-eval "echo hosting_task_count_running();"'
264 265
    # upgrade to the latest version from the unstable repo.
    - rm -v /etc/apt/sources.list.d/aegir-stable.list
266
    - echo "deb http://debian.aegirproject.org unstable main" | sudo tee -a /etc/apt/sources.list.d/aegir-unstable.list
267 268
    - sudo apt-get update
    - sudo apt-get --yes upgrade