.gitlab-ci.yml 5.32 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 19 20 21 22 23
  script:
    - export commit=$(git log -n 1 --oneline | sed 's/ .*$//')
    - export version=$(sed -ne 's/^[^(]*(\([^)]*\)).*/\1/;1p' debian/changelog)
    - export new_version="${version}+${CI_BUILD_ID}.${commit}"
    - dch -D unstable --newversion "$new_version" "automatic GitLab CI build ${CI_BUILD_ID}"
    - 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

  # 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
40 41 42
  only:
    - 7.x-3.x
    - triggers
43 44 45 46 47 48 49 50 51 52

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

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

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

72 73 74 75 76
test:ubuntu-xenial-aegir3-apt:
  stage: test
  image: ubuntu:xenial
  dependencies:
    - build:deb
77 78 79
  only:
    - 7.x-3.x
    - triggers
80 81 82 83 84 85 86 87 88 89

  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
90 91
test:behat:
  stage: test
92
  image: aegir/hostmaster:packaging_base
helmo's avatar
helmo committed
93 94 95
  dependencies:
    - build:deb
  variables:
helmo's avatar
syntax?  
helmo committed
96
    AEGIR_TESTS_VERSION: "master"
helmo's avatar
helmo committed
97 98

  before_script:
helmo's avatar
helmo committed
99 100 101 102 103 104
    - 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"
    - sudo apt-get update
    - sudo apt-get install docker-ce
helmo's avatar
helmo committed
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
    - 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:

    # 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
121 122 123 124 125 126 127

publish:unstable-repo:
  stage: publish
  dependencies:
    - build:deb
  allow_failure: true

128 129 130
  only:
    - 7.x-3.x

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

helmo's avatar
helmo committed
136 137
    # run ssh-agent
    - eval $(ssh-agent -s)
helmo's avatar
helmo committed
138

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

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

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


# 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
158
    - publish:unstable-repo
159

helmo's avatar
helmo committed
160 161
  when: manual

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

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