.gitlab-ci.yml 1.83 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
  artifacts:
      paths:
          - dist/$SDIST

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

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

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

release:docker:
    stage: release
74
    image: docker:dind
75
76
    tags:
        - privileged
77
78
79
80
    script:
        - docker load -i image.tar
        - docker login -u $DOCKER_USER -p $DOCKER_PASS
        - docker push $DOCKER_IMAGE_TAG
81
82
    dependencies:
        - build:image
83
84
    only:
        - tags