.gitlab-ci.yml 5.18 KB
Newer Older
1 2 3 4 5 6 7 8
# 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
9
  - publish
10
  - upgradetest
11 12 13 14

# Stage "build"
build:deb:
  stage: build
15
  image: aegir/hostmaster:packaging_base
16 17 18
  script:
    - export commit=$(git log -n 1 --oneline | sed 's/ .*$//')
    - export version=$(sed -ne 's/^[^(]*(\([^)]*\)).*/\1/;1p' debian/changelog)
19 20


21 22 23
    - dpkg-buildpackage
    - mkdir build
    - mv -v ../aegir3*.deb build/
helmo's avatar
helmo committed
24
    - mv -v ../aegir3*.tar.gz build/
helmo's avatar
helmo committed
25
    - mv -v ../aegir3*.dsc build/
helmo's avatar
helmo committed
26
    - mv -v ../aegir3*.changes build/
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47

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


# Stage "test"
test:debian-jessie-aegir3-apt:
  stage: test
  image: debian:jessie
  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

48
  script: "scripts/ci-aegir-dev-install-apt-debian8.sh"
49

helmo's avatar
helmo committed
50 51 52 53 54 55
test:debian-stretch-aegir3-apt:
  stage: test
  image: debian:stretch
  allow_failure: true
  dependencies:
    - build:deb
56 57
  only:
    - 7.x-3.x
helmo's avatar
helmo committed
58 59 60 61 62 63 64 65

  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
66
  script: "scripts/ci-aegir-dev-install-apt-debian9.sh"
helmo's avatar
helmo committed
67

68 69 70 71 72
test:ubuntu-xenial-aegir3-apt:
  stage: test
  image: ubuntu:xenial
  dependencies:
    - build:deb
73 74
  only:
    - 7.x-3.x
75 76 77 78 79 80 81 82 83 84

  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-ubuntu.sh"

helmo's avatar
helmo committed
85 86
test:behat:
  stage: test
helmo's avatar
helmo committed
87
  image: aegir/hostmaster:packaging_base
helmo's avatar
helmo committed
88 89
  dependencies:
    - build:deb
90
  allow_failure: true
helmo's avatar
helmo committed
91
  variables:
helmo's avatar
syntax?  
helmo committed
92
    AEGIR_TESTS_VERSION: "master"
helmo's avatar
helmo committed
93 94

  before_script:
helmo's avatar
helmo committed
95
    - sudo apt-get update
helmo's avatar
helmo committed
96 97 98 99
    - 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
100
    - sudo apt-get update
helmo's avatar
helmo committed
101 102
    - sudo apt-get install --yes docker-ce
    - docker info
helmo's avatar
helmo committed
103 104 105 106 107 108 109 110 111 112
    - 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
113

helmo's avatar
helmo committed
114 115 116 117
    # Tests are included in the docker-compose.yml file in the tests repo.
    - sudo docker-compose -f docker-compose-provision.yml run hostmaster


helmo's avatar
helmo committed
118 119


helmo's avatar
helmo committed
120 121 122 123 124 125
publish:unstable-repo:
  stage: publish
  dependencies:
    - build:deb
  allow_failure: true

126 127 128
  only:
    - 7.x-3.x

helmo's avatar
helmo committed
129 130 131 132
  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
133

helmo's avatar
helmo committed
134 135
    # run ssh-agent
    - eval $(ssh-agent -s)
helmo's avatar
helmo committed
136

helmo's avatar
helmo committed
137 138
    # add ssh key stored in SSH_PRIVATE_KEY variable to the agent store
    - ssh-add <(echo "$SSH_PRIVATE_KEY")
helmo's avatar
helmo committed
139 140

    - mkdir -p ~/.ssh
helmo's avatar
helmo committed
141
    - ls -la /.dockerenv
helmo's avatar
typo  
helmo committed
142
    - echo "$SSH_SERVER_HOSTKEYS" > ~/.ssh/known_hosts
helmo's avatar
helmo committed
143
    - cat ~/.ssh/known_hosts
helmo's avatar
helmo committed
144 145 146

  script:
    - ls -lah build/*
helmo's avatar
helmo committed
147
    - scp build/* ci@aegir0.aegir.coop:/var/www/repos/incoming/
helmo's avatar
helmo committed
148
      # reprepro should pick this up in seconds and update the repository index.
149 150 151 152 153 154 155


# 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
156
    - publish:unstable-repo
157

helmo's avatar
helmo committed
158 159
  when: manual

160 161 162 163 164
  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
165
    - apt-get install --yes sudo curl cron
166 167

  script:
168
    - "scripts/ci-aegir-stable-install-apt-debian8.sh"
helmo's avatar
helmo committed
169
    # extra step to run the task queue.
helmo's avatar
helmo committed
170
    - sudo su aegir --login --command 'drush @hostmaster php-eval "echo hosting_task_count();"'
helmo's avatar
helmo committed
171
    - sudo su aegir --login --command 'drush @hostmaster hosting-tasks --force'
helmo's avatar
helmo committed
172
    - sudo su aegir --login --command 'drush @hostmaster php-eval "echo hosting_task_count();"'
helmo's avatar
helmo committed
173
    - sudo su aegir --login --command 'drush @hostmaster hosting-tasks --force'
helmo's avatar
helmo committed
174
    - sudo su aegir --login --command 'drush @hostmaster php-eval "echo hosting_task_count();"'
helmo's avatar
debug  
helmo committed
175
    - sudo su aegir --login --command 'drush @hostmaster php-eval "echo hosting_task_count_running();"'
helmo's avatar
helmo committed
176 177
    - sleep 2m
    - sudo su aegir --login --command 'drush @hostmaster php-eval "echo hosting_task_count_running();"'
178 179
    # upgrade to the latest version from the unstable repo.
    - rm -v /etc/apt/sources.list.d/aegir-stable.list
helmo's avatar
helmo committed
180
    - echo "deb http://debian2.aegirproject.org unstable main" | sudo tee -a /etc/apt/sources.list.d/aegir-unstable.list
181 182
    - sudo apt-get update
    - sudo apt-get --yes upgrade