.gitlab-ci.yml 1.51 KB
Newer Older
1
image: centos:7
2
3

services:
4
5
    - redis:3.2-alpine
    - rabbitmq:3.7-alpine
6
    - docker:dind
7

Sascha Herzinger's avatar
Sascha Herzinger committed
8

Sascha Herzinger's avatar
Sascha Herzinger committed
9
10
variables:
    PYPI_USER: SECURE
11
12
13
14
15
    PYPI_PASS: SECURE
    DOCKER_USER: SECURE
    DOCKER_PASS: SECURE
    DOCKER_IMAGE_TAG: fractalis:$CI_COMMIT_TAG
    SDIST: fractalis-$CI_COMMIT_TAG.tar.gz
16

Sascha Herzinger's avatar
Sascha Herzinger committed
17
stages:
18
    - build
Sascha Herzinger's avatar
Sascha Herzinger committed
19
    - test
Sascha Herzinger's avatar
Sascha Herzinger committed
20
    - release
Sascha Herzinger's avatar
Sascha Herzinger committed
21

22
23
24
build:
  stage: build
  script:
25
26
      - yum install -y epel-release
      - yum update -y
27
      - yum install -y python34 python34-pip
28
      - pip3 install setuptools
29
30
31
32
33
34
35
36
37
      - python3 setup.py sdist
      - docker build -t $DOCKER_IMAGE_TAG --build-arg SDIST=$SDIST .
      - docker save $DOCKER_IMAGE_TAG -o image.tar
  artifacts:
      paths:
          - dist/$SDIST
          - image.tar

test:
Sascha Herzinger's avatar
Sascha Herzinger committed
38
    stage: test
39
    script:
40
41
42
43
44
45
46
47
        - docker load -i image.tar
        - >
          docker run fractalis:$CI_COMMIT_TAG
          -e REDIS_HOST=redis -e RABBITMQ_HOST=rabbitmq
          sh -c "celery worker -D -A fractalis:celery
                && pip3 install -r requirements.txt
                && flake8
                && pytest tests"
Sascha Herzinger's avatar
Sascha Herzinger committed
48

Sascha Herzinger's avatar
Sascha Herzinger committed
49
50
release:pypi:
    stage: release
Sascha Herzinger's avatar
Sascha Herzinger committed
51
    script:
52
53
54
55
        - yum install -y epel-release
        - yum update -y
        - yum install -y python34 python34-pip
        - pip3 install twine
56
        - twine upload dist/$SDIST -u $PYPI_USER -p $PYPI_PASS
Sascha Herzinger's avatar
Sascha Herzinger committed
57
    only:
Sascha Herzinger's avatar
Sascha Herzinger committed
58
        - tags
59
60
61
62
63
64
65
66
67

release:docker:
    stage: release
    script:
        - docker load -i image.tar
        - docker login -u $DOCKER_USER -p $DOCKER_PASS
        - docker push $DOCKER_IMAGE_TAG
    only:
        - tags