.gitlab-ci.yml 2.34 KB
Newer Older
Sascha Herzinger's avatar
Sascha Herzinger committed
1
2
variables:
    PYPI_USER: SECURE
3
4
5
    PYPI_PASS: SECURE
    DOCKER_USER: SECURE
    DOCKER_PASS: SECURE
Sascha Herzinger's avatar
Sascha Herzinger committed
6
7
    DOCKER_DRIVER: overlay2

8
before_script:
Sascha Herzinger's avatar
Sascha Herzinger committed
9
    - FRACTALIS_VERSION=$(grep version setup.py | grep -o "[0-9]\+.[0-9]\+.[0-9]\+")
10
    - DOCKER_IMAGE_TAG="fractalis:$FRACTALIS_VERSION"
Sascha Herzinger's avatar
Sascha Herzinger committed
11
    - SDIST=fractalis-$FRACTALIS_VERSION.tar.gz
12

Sascha Herzinger's avatar
Sascha Herzinger committed
13
stages:
14
15
    - build_sdist
    - build_image
Sascha Herzinger's avatar
Sascha Herzinger committed
16
    - test
Sascha Herzinger's avatar
Sascha Herzinger committed
17
    - release
Sascha Herzinger's avatar
Sascha Herzinger committed
18

19
20
21
build:sdist:
  stage: build_sdist
  image: python:3.6-alpine
22
23
  script:
      - python3 setup.py sdist
24
  artifacts:
25
      expire_in: 1h
26
      paths:
Sascha Herzinger's avatar
Sascha Herzinger committed
27
          - dist/
28
29
30

build:image:
  stage: build_image
Sascha Herzinger's avatar
Sascha Herzinger committed
31
  image: docker:latest
32
33
  services:
      - docker:dind
34
35
  tags:
      - privileged
36
  script:
Sascha Herzinger's avatar
Sascha Herzinger committed
37
      - docker build -t $DOCKER_USER/$DOCKER_IMAGE_TAG -f docker/Dockerfile --build-arg SDIST=dist/$SDIST .
Sascha Herzinger's avatar
Sascha Herzinger committed
38
      - docker save $DOCKER_USER/$DOCKER_IMAGE_TAG -o image.tar
39
40
  dependencies:
      - build:sdist
41
  artifacts:
42
      expire_in: 1h
43
44
45
46
      paths:
          - image.tar

test:
Sascha Herzinger's avatar
Sascha Herzinger committed
47
    stage: test
Sascha Herzinger's avatar
Sascha Herzinger committed
48
    image: docker:latest
49
50
    tags:
        - privileged
51
52
53
    services:
        - redis:3.2-alpine
        - rabbitmq:3.7-alpine
54
        - docker:dind
55
    script:
56
        - docker load -i image.tar
Sascha Herzinger's avatar
Sascha Herzinger committed
57
        - env
Sascha Herzinger's avatar
Sascha Herzinger committed
58
        - >
59
60
          docker run
          $DOCKER_USER/$DOCKER_IMAGE_TAG
61
          sh -c "
Sascha Herzinger's avatar
Sascha Herzinger committed
62
63
          env
          && printf \"REDIS_HOST='$REDIS_PORT_6379_TCP_ADDR'\nBROKER_URL='amqp://guest:guest@$RABBITMQ_PORT_5672_TCP_ADDR:5672//'\nCELERY_RESULT_BACKEND='redis://$REDIS_PORT_6379_TCP_ADDR:6379'\"
64
65
66
          > /config.py
          && export FRACTALIS_CONFIG=/config.py
          && celery worker -D -A fractalis:celery -l debug --concurrency=1
67
          && pytest --color=yes --verbose --capture=no --cov=/usr/lib/python3.4/site-packages/fractalis tests/
68
          "
69
70
    dependencies:
        - build:image
Sascha Herzinger's avatar
Sascha Herzinger committed
71

Sascha Herzinger's avatar
Sascha Herzinger committed
72
73
release:pypi:
    stage: release
74
    image: python:3.6-alpine
Sascha Herzinger's avatar
Sascha Herzinger committed
75
    script:
76
        - pip3 install twine
Sascha Herzinger's avatar
Sascha Herzinger committed
77
        - twine upload dist/$SDIST -u $PYPI_USER -p $PYPI_PASS
78
79
    dependencies:
        - build:sdist
Sascha Herzinger's avatar
Sascha Herzinger committed
80
    only:
Sascha Herzinger's avatar
Sascha Herzinger committed
81
        - tags
82
83
84

release:docker:
    stage: release
Sascha Herzinger's avatar
Sascha Herzinger committed
85
    image: docker:latest
86
87
    services:
        - docker:dind
88
89
    tags:
        - privileged
90
91
92
    script:
        - docker load -i image.tar
        - docker login -u $DOCKER_USER -p $DOCKER_PASS
Sascha Herzinger's avatar
Sascha Herzinger committed
93
        - docker push $DOCKER_USER/$DOCKER_IMAGE_TAG
94
95
    dependencies:
        - build:image
96
97
    only:
        - tags