.gitlab-ci.yml 6.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 13 14
# Is performed before the scripts in the stages step
before_script:
  - source /etc/profile

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

18 19 20 21 22

#
### Stage "build"
#

23 24
build:deb:
  stage: build
25
  image: aegir/hostmaster:packaging_base
26 27 28
  script:
    - export commit=$(git log -n 1 --oneline | sed 's/ .*$//')
    - export version=$(sed -ne 's/^[^(]*(\([^)]*\)).*/\1/;1p' debian/changelog)
29 30
    - export new_version="${version}+${CI_BUILD_ID}.${commit}"
    - dch -D unstable --newversion "$new_version" "automatic GitLab CI build ${CI_BUILD_ID}"
31 32 33
    - dpkg-buildpackage
    - mkdir build
    - mv -v ../aegir3*.deb build/
34
    - mv -v ../aegir-archive-keyring*.deb build/
helmo's avatar
helmo committed
35
    - mv -v ../aegir3*.tar.gz build/
helmo's avatar
helmo committed
36
    - mv -v ../aegir3*.dsc build/
helmo's avatar
helmo committed
37
    - mv -v ../aegir3*.changes build/
38 39 40 41 42 43 44

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


45 46 47 48
#
### Stage "test"
#

49 50 51 52 53
test:debian-jessie-aegir3-apt:
  stage: test
  image: debian:jessie
  dependencies:
    - build:deb
54 55
  only:
    - 7.x-3.x
56 57 58 59 60 61 62 63

  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

64
  script: "scripts/ci-aegir-dev-install-apt-debian8.sh"
65

helmo's avatar
helmo committed
66 67 68 69 70 71 72 73 74 75 76 77 78 79
test:debian-stretch-aegir3-apt:
  stage: test
  image: debian:stretch
  allow_failure: true
  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
80
  script: "scripts/ci-aegir-dev-install-apt-debian9.sh"
helmo's avatar
helmo committed
81

82 83 84 85 86
test:ubuntu-xenial-aegir3-apt:
  stage: test
  image: ubuntu:xenial
  dependencies:
    - build:deb
87 88
  only:
    - 7.x-3.x
89 90 91 92 93 94 95 96

  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

97
  script: "scripts/ci-aegir-dev-install-apt-ubuntu-xenial.sh"
98

99
test:ubuntu-artful-aegir3-apt:
helmo's avatar
helmo committed
100 101 102 103 104 105 106 107 108 109 110 111 112
  stage: test
  image: ubuntu:artful
  dependencies:
    - build:deb
  allow_failure: true

  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

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

helmo's avatar
helmo committed
115 116
test:behat:
  stage: test
117
  image: aegir/hostmaster:packaging_base
helmo's avatar
helmo committed
118 119
  dependencies:
    - build:deb
120
  allow_failure: true
helmo's avatar
helmo committed
121
  variables:
helmo's avatar
helmo committed
122
    AEGIR_TESTS_VERSION: "master"
helmo's avatar
helmo committed
123 124

  before_script:
helmo's avatar
helmo committed
125
    - sudo apt-get update
126 127 128 129
    - 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
130
    - sudo apt-get update
131 132
    - sudo apt-get install --yes docker-ce
    - docker info
helmo's avatar
helmo committed
133 134 135 136 137 138 139 140 141 142
    - 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:
143

helmo's avatar
helmo committed
144 145 146 147
    # Tests are included in the docker-compose.yml file in the tests repo.
    - sudo docker-compose -f docker-compose-provision.yml run hostmaster


148 149 150
#
### Stage "publish"
#
151

helmo's avatar
helmo committed
152 153 154 155 156 157
publish:unstable-repo:
  stage: publish
  dependencies:
    - build:deb
  allow_failure: true

158 159
  only:
    - 7.x-3.x
160
    - /^7\.x-3\.\d+\.x/
161

helmo's avatar
helmo committed
162 163 164 165
  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
166

helmo's avatar
helmo committed
167 168
    # run ssh-agent
    - eval $(ssh-agent -s)
helmo's avatar
helmo committed
169

helmo's avatar
helmo committed
170 171
    # add ssh key stored in SSH_PRIVATE_KEY variable to the agent store
    - ssh-add <(echo "$SSH_PRIVATE_KEY")
helmo's avatar
helmo committed
172 173

    - mkdir -p ~/.ssh
helmo's avatar
helmo committed
174
    - ls -la /.dockerenv
helmo's avatar
helmo committed
175
    - echo "$SSH_SERVER_HOSTKEYS" > ~/.ssh/known_hosts
helmo's avatar
helmo committed
176
    - cat ~/.ssh/known_hosts
helmo's avatar
helmo committed
177 178 179

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


184 185 186 187
#
### Stage "upgradetest"
#

188 189 190 191 192
# 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
193
    - publish:unstable-repo
194

helmo's avatar
helmo committed
195 196
  when: manual

197 198 199 200 201
  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
202
    - apt-get install --yes sudo curl cron
203 204

  script:
205
    - "scripts/ci-aegir-stable-install-apt-debian8.sh"
helmo's avatar
helmo committed
206
    # extra step to run the task queue.
helmo's avatar
helmo committed
207
    - sudo su aegir --login --command 'drush @hostmaster php-eval "echo hosting_task_count();"'
helmo's avatar
helmo committed
208
    - sudo su aegir --login --command 'drush @hostmaster hosting-tasks --force'
helmo's avatar
helmo committed
209
    - sudo su aegir --login --command 'drush @hostmaster php-eval "echo hosting_task_count();"'
helmo's avatar
helmo committed
210
    - sudo su aegir --login --command 'drush @hostmaster hosting-tasks --force'
helmo's avatar
helmo committed
211
    - sudo su aegir --login --command 'drush @hostmaster php-eval "echo hosting_task_count();"'
helmo's avatar
helmo committed
212
    - sudo su aegir --login --command 'drush @hostmaster php-eval "echo hosting_task_count_running();"'
helmo's avatar
helmo committed
213 214
    - sleep 2m
    - sudo su aegir --login --command 'drush @hostmaster php-eval "echo hosting_task_count_running();"'
215 216
    # upgrade to the latest version from the unstable repo.
    - rm -v /etc/apt/sources.list.d/aegir-stable.list
217
    - echo "deb http://debian.aegirproject.org unstable main" | sudo tee -a /etc/apt/sources.list.d/aegir-unstable.list
218 219
    - sudo apt-get update
    - sudo apt-get --yes upgrade