.gitlab-ci.yml 1.89 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
8
9
    DOCKER_DRIVER: overlay2

services:
    - docker:dind
10
11
12
13

before_script:
    - FRACTALIS_VERSION=$(grep version setup.py | grep -o "[0-9]\.[0-9]\.[0-9]")
    - DOCKER_IMAGE_TAG="fractalis:$FRACTALIS_VERSION"
Sascha Herzinger's avatar
Sascha Herzinger committed
14
    - SDIST=dist/fractalis-$FRACTALIS_VERSION.tar.gz
15

Sascha Herzinger's avatar
Sascha Herzinger committed
16
stages:
17
18
    - build_sdist
    - build_image
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:sdist:
  stage: build_sdist
  image: python:3.6-alpine
25
26
  script:
      - python3 setup.py sdist
27
28
  artifacts:
      paths:
Sascha Herzinger's avatar
Sascha Herzinger committed
29
          - $SDIST
30
31
32

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

test:
Sascha Herzinger's avatar
Sascha Herzinger committed
46
    stage: test
Sascha Herzinger's avatar
Sascha Herzinger committed
47
    image: docker:latest
48
49
    tags:
        - privileged
50
51
52
    services:
        - redis:3.2-alpine
        - rabbitmq:3.7-alpine
53
    script:
54
55
        - docker load -i image.tar
        - >
56
          docker run DOCKER_IMAGE_TAG
57
58
59
60
61
          -e REDIS_HOST=redis -e RABBITMQ_HOST=rabbitmq
          sh -c "celery worker -D -A fractalis:celery
                && pip3 install -r requirements.txt
                && flake8
                && pytest tests"
62
63
    dependencies:
        - build:image
Sascha Herzinger's avatar
Sascha Herzinger committed
64

Sascha Herzinger's avatar
Sascha Herzinger committed
65
66
release:pypi:
    stage: release
67
    image: python:3.6-alpine
Sascha Herzinger's avatar
Sascha Herzinger committed
68
    script:
69
        - pip3 install twine
Sascha Herzinger's avatar
Sascha Herzinger committed
70
        - twine upload $SDIST -u $PYPI_USER -p $PYPI_PASS
71
72
    dependencies:
        - build:sdist
Sascha Herzinger's avatar
Sascha Herzinger committed
73
    only:
Sascha Herzinger's avatar
Sascha Herzinger committed
74
        - tags
75
76
77

release:docker:
    stage: release
Sascha Herzinger's avatar
Sascha Herzinger committed
78
    image: docker:latest
79
80
    tags:
        - privileged
81
82
83
84
    script:
        - docker load -i image.tar
        - docker login -u $DOCKER_USER -p $DOCKER_PASS
        - docker push $DOCKER_IMAGE_TAG
85
86
    dependencies:
        - build:image
87
88
    only:
        - tags