.gitlab-ci.yml 2.48 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 21 22 23 24 25 26 27 28 29 30 31 32 33
  - 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
  - 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
34 35
    - 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
36 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
    - docker-compose -p $CI_PIPELINE_IID -f docker-compose-common.yml -f docker-compose-ci.yml up --build --exit-code-from tests
51
  after_script:
52 53 54 55 56 57 58 59 60 61 62 63
    - 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"'
64
      when: always
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
    - when: manual
  allow_failure: true

zork-cleanup:
  stage: docker-cleanup
  script:
    - df -h /
    - docker system df
    - docker image prune -a -f # TODO: prune cache, volumes if necessary
    - docker system df
    - df -h /
  rules:
  - if: '$CI_PIPELINE_SOURCE == "schedule"'
    when: always
  - when: manual
  allow_failure: true