.gitlab-ci.yml 1.73 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
6
7
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"
    - SDIST=fractalis-$FRACTALIS_VERSION.tar.gz
11

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

18
19
20
build:sdist:
  stage: build_sdist
  image: python:3.6-alpine
21
22
  script:
      - python3 setup.py sdist
23
24
25
26
27
28
29
30
  artifacts:
      paths:
          - dist/$SDIST

build:image:
  stage: build_image
  image: docker:dind
  script:
31
32
      - docker build -t $DOCKER_IMAGE_TAG --build-arg SDIST=$SDIST .
      - docker save $DOCKER_IMAGE_TAG -o image.tar
33
34
  dependencies:
      - build:sdist
35
36
37
38
39
  artifacts:
      paths:
          - image.tar

test:
Sascha Herzinger's avatar
Sascha Herzinger committed
40
    stage: test
41
42
43
44
    image: docker:dind
    services:
        - redis:3.2-alpine
        - rabbitmq:3.7-alpine
45
    script:
46
47
        - docker load -i image.tar
        - >
48
          docker run DOCKER_IMAGE_TAG
49
50
51
52
53
          -e REDIS_HOST=redis -e RABBITMQ_HOST=rabbitmq
          sh -c "celery worker -D -A fractalis:celery
                && pip3 install -r requirements.txt
                && flake8
                && pytest tests"
54
55
    dependencies:
        - build:image
Sascha Herzinger's avatar
Sascha Herzinger committed
56

Sascha Herzinger's avatar
Sascha Herzinger committed
57
58
release:pypi:
    stage: release
59
    image: python:3.6-alpine
Sascha Herzinger's avatar
Sascha Herzinger committed
60
    script:
61
        - pip3 install twine
62
        - twine upload dist/$SDIST -u $PYPI_USER -p $PYPI_PASS
63
64
    dependencies:
        - build:sdist
Sascha Herzinger's avatar
Sascha Herzinger committed
65
    only:
Sascha Herzinger's avatar
Sascha Herzinger committed
66
        - tags
67
68
69

release:docker:
    stage: release
70
    image: docker:dind
71
72
73
74
    script:
        - docker load -i image.tar
        - docker login -u $DOCKER_USER -p $DOCKER_PASS
        - docker push $DOCKER_IMAGE_TAG
75
76
    dependencies:
        - build:image
77
78
    only:
        - tags