.gitlab-ci.yml 2.08 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
9
10
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
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 .
38
      - docker save $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
57
        - docker load -i image.tar
        - >
58
          docker run
59
60
          -e REDIS_HOST=$REDIS_PORT_6379_TCP_ADDR
          -e RABBITMQ_HOST=$RABBITMQ_PORT_5672_TCP_ADDR
61
          $DOCKER_IMAGE_TAG
Sascha Herzinger's avatar
Sascha Herzinger committed
62
          sh -c "celery worker -D -A fractalis:celery -l debug --concurrency=1
63
64
65
          && pip3 install -r requirements.txt
          && flake8
          && pytest tests"
66
67
    dependencies:
        - build:image
Sascha Herzinger's avatar
Sascha Herzinger committed
68

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

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