.gitlab-ci.yml 7.46 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
26
  image: bobey/docker-gitlab-ci-runner-php7
helmo's avatar
helmo committed
27 28
  allow_failure: false

helmo's avatar
helmo committed
29
  script:
30
    - composer require overtrue/phplint
helmo's avatar
helmo committed
31 32 33
    - 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


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
test:debian-jessie-aegir3-apt:
  stage: test
  image: debian:jessie
helmo's avatar
helmo committed
68
  allow_failure: true
69 70
  dependencies:
    - build:deb
71
  only:
72
    - 7.x-3.x
73
    - /^7\.x-3\.\d+\.x/
74
    - /-runalltests$/
75 76 77 78 79 80 81 82

  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

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

helmo's avatar
helmo committed
85 86 87
test:debian-stretch-aegir3-apt:
  stage: test
  image: debian:stretch
88
  allow_failure: false
helmo's avatar
helmo committed
89 90 91
  dependencies:
    - build:deb

helmo's avatar
helmo committed
92 93 94 95 96
  only:
    - 7.x-3.x
    - /^7\.x-3\.\d+\.x/
    - /-runalltests$/

helmo's avatar
helmo committed
97 98 99 100 101 102 103
  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
104
  script: "scripts/ci-aegir-dev-install-apt-debian9.sh"
helmo's avatar
helmo committed
105

106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
test:debian-buster-aegir3-apt:
  stage: test
  image: debian:buster
  allow_failure: false
  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

  script: "scripts/ci-aegir-dev-install-apt-debian10.sh"

122 123 124 125 126
test:ubuntu-xenial-aegir3-apt:
  stage: test
  image: ubuntu:xenial
  dependencies:
    - build:deb
helmo's avatar
helmo committed
127

128
  only:
129
    - 7.x-3.x
130
    - /^7\.x-3\.\d+\.x/
131
    - /-runalltests$/
132 133 134 135 136 137 138 139

  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

140
  script: "scripts/ci-aegir-dev-install-apt-ubuntu-xenial.sh"
141

142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
test:ubuntu-bionic-aegir3-apt:
  stage: test
  image: ubuntu:bionic
  dependencies:
    - build:deb

  only:
    - 7.x-3.x
    - /^7\.x-3\.\d+\.x/
    - /-runalltests$/

  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
160
  script: "scripts/ci-aegir-dev-install-apt-ubuntu-bionic.sh"
161

162
test:cluster-slave-debian-stretch-apt:
163 164 165 166 167 168
  stage: test
  image: debian:stretch
  allow_failure: false
  dependencies:
    - build:deb

169 170 171 172 173
  only:
    - 7.x-3.x
    - /^7\.x-3\.\d+\.x/
    - /-runalltests$/

174 175 176 177 178 179 180 181 182
  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
183 184
test:behat:
  stage: test
185
  image: aegir/hostmaster:packaging_base
helmo's avatar
helmo committed
186 187
  dependencies:
    - build:deb
188
  allow_failure: true
helmo's avatar
helmo committed
189
  variables:
helmo's avatar
helmo committed
190
    AEGIR_TESTS_VERSION: "master"
helmo's avatar
helmo committed
191 192

  before_script:
helmo's avatar
helmo committed
193
    - sudo apt-get update
194 195 196 197
    - 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
198
    - sudo apt-get update
199 200
    - sudo apt-get install --yes docker-ce
    - docker info
helmo's avatar
helmo committed
201 202 203 204 205 206 207 208 209 210
    - 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:
211

helmo's avatar
helmo committed
212 213 214 215
    # Tests are included in the docker-compose.yml file in the tests repo.
    - sudo docker-compose -f docker-compose-provision.yml run hostmaster


216 217 218
#
### Stage "publish"
#
219

helmo's avatar
helmo committed
220 221 222 223 224
publish:unstable-repo:
  stage: publish
  dependencies:
    - build:deb

225 226
  only:
    - 7.x-3.x
227
    - /^7\.x-3\.\d+\.x/
228

helmo's avatar
helmo committed
229 230 231 232
  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
233

helmo's avatar
helmo committed
234 235
    # run ssh-agent
    - eval $(ssh-agent -s)
helmo's avatar
helmo committed
236

helmo's avatar
helmo committed
237 238
    # add ssh key stored in SSH_PRIVATE_KEY variable to the agent store
    - ssh-add <(echo "$SSH_PRIVATE_KEY")
helmo's avatar
helmo committed
239 240

    - mkdir -p ~/.ssh
helmo's avatar
helmo committed
241
    - ls -la /.dockerenv
helmo's avatar
helmo committed
242
    - echo "$SSH_SERVER_HOSTKEYS" > ~/.ssh/known_hosts
helmo's avatar
helmo committed
243
    - cat ~/.ssh/known_hosts
helmo's avatar
helmo committed
244 245 246

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


251 252 253 254
#
### Stage "upgradetest"
#

255
# Upgrade the latest stable Aegir to our unstable repo.
256
upgradetest:debian-stretch-aegir3-apt-upgrade:
257
  stage: upgradetest
258
  image: debian:stretch
259
  dependencies:
helmo's avatar
helmo committed
260
    - publish:unstable-repo
261

262 263 264 265
  only:
    - 7.x-3.x
    - /^7\.x-3\.\d+\.x/
    - /-runalltests$/
helmo's avatar
helmo committed
266

267 268 269 270 271
  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
272
    - apt-get install --yes sudo curl cron
273 274

  script:
275
    - "scripts/ci-aegir-stable-install-apt-debian9.sh"
helmo's avatar
helmo committed
276
    # extra step to run the task queue.
helmo's avatar
helmo committed
277
    - sudo su aegir --login --command 'drush @hostmaster php-eval "echo hosting_task_count();"'
helmo's avatar
helmo committed
278
    - sudo su aegir --login --command 'drush @hostmaster hosting-tasks --force'
helmo's avatar
helmo committed
279
    - sudo su aegir --login --command 'drush @hostmaster php-eval "echo hosting_task_count();"'
helmo's avatar
helmo committed
280
    - sudo su aegir --login --command 'drush @hostmaster hosting-tasks --force'
helmo's avatar
helmo committed
281
    - sudo su aegir --login --command 'drush @hostmaster php-eval "echo hosting_task_count();"'
helmo's avatar
helmo committed
282
    - sudo su aegir --login --command 'drush @hostmaster php-eval "echo hosting_task_count_running();"'
helmo's avatar
helmo committed
283 284
    - sleep 2m
    - sudo su aegir --login --command 'drush @hostmaster php-eval "echo hosting_task_count_running();"'
285 286
    # upgrade to the latest version from the unstable repo.
    - rm -v /etc/apt/sources.list.d/aegir-stable.list
helmo's avatar
helmo committed
287
    - echo "deb [signed-by=/usr/share/keyrings/aegir-archive-keyring.gpg] http://debian.aegirproject.org unstable main" | sudo tee -a /etc/apt/sources.list.d/aegir-unstable.list
288
    - sudo apt-get update
289
    - sudo apt-get --yes dist-upgrade