.gitlab-ci.yml 2.57 KB
Newer Older
1 2 3 4 5
image: frolvlad/alpine-glibc

variables:
  DOCKERHUB_USERNAME: deichman

6
before_script:
7 8 9 10 11 12 13 14 15 16 17 18 19 20
  - echo -n "START :" && date -u +'%Y-%m-%dT%H:%M:%SZ'
  - apk add --update --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing make docker curl bash git
  - curl -L "https://github.com/docker/compose/releases/download/1.25.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
  - chmod +x /usr/local/bin/docker-compose
  - echo $DOCKERHUB_PASSWORD|docker login -u $DOCKERHUB_USERNAME --password-stdin
  - export DOCKER_BUILDKIT=1
  - export COMPOSE_DOCKER_CLI_BUILD=1
  - export TAG=${CI_COMMIT_TAG:-latest}

stages:
  - docker-cleanup
  - test
  - push
  - deploy-test
21
  - deploy-dynamic
22 23 24 25 26 27 28 29 30 31 32 33 34
  - sanity
  - deploy-stage
  - deploy-prod
  - patch
  - patch-prod

include:
  - "/gitlab-ci/push-jobs.yml"
  - "/gitlab-ci/deploy-jobs.yml"

.ssh-setup:
  before_script:
    - apk add --update --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing make docker curl bash git figlet
35 36
    - curl -L "https://github.com/docker/compose/releases/download/1.25.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
    - chmod +x /usr/local/bin/docker-compose
37 38 39 40 41 42 43 44 45 46 47 48 49 50
    - 'which ssh-agent || ( apk add --update --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing openssh-client git )'
    - eval $(ssh-agent -s)
    - echo "$SSH_KEY" | tr -d '\r' | ssh-add - > /dev/null
    - mkdir -p ~/.ssh
    - chmod 700 ~/.ssh
    - echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
    - chmod 644 ~/.ssh/known_hosts
    - export APPLICATION_NAME=${APPLICATION_NAME}

e2e-tests:
  tags:
    - e2e
  script:
    - cd e2e-tests
51
    - bash prepareBaselines.sh
52
    - docker-compose -p $CI_PIPELINE_IID -f docker-compose-common.yml -f docker-compose-ci.yml up --build --exit-code-from tests
53
  after_script:
54 55 56 57 58 59 60 61 62 63 64 65
    - cd e2e-tests
    - docker-compose -p $CI_PIPELINE_IID -f docker-compose-common.yml -f docker-compose-ci.yml down -v --rmi local
    - echo -n "END :" && date -u +'%Y-%m-%dT%H:%M:%SZ'
  artifacts:
    when: always
    expire_in: 1 week
    paths:
      - e2e-tests/cypress/videos/
      - e2e-tests/cypress/screenshots/
  stage: test
  rules:
    - if: '$CI_PIPELINE_SOURCE == "schedule"'
66
      when: always
67 68 69
    - when: manual
  allow_failure: true

70
# TODO: prune volumes if necessary
71 72 73 74 75
zork-cleanup:
  stage: docker-cleanup
  script:
    - df -h /
    - docker system df
76 77
    - docker image prune -a -f
    - docker builder prune -f --filter "until=72h"
78 79 80 81 82 83 84
    - docker system df
    - df -h /
  rules:
  - if: '$CI_PIPELINE_SOURCE == "schedule"'
    when: always
  - when: manual
  allow_failure: true