.gitlab-ci.yml 1.63 KB
Newer Older
Sascha Herzinger's avatar
Sascha Herzinger committed
1
2
variables:
    PYPI_USER: SECURE
3
4
5
6
7
    PYPI_PASS: SECURE
    DOCKER_USER: SECURE
    DOCKER_PASS: SECURE
    DOCKER_IMAGE_TAG: fractalis:$CI_COMMIT_TAG
    SDIST: fractalis-$CI_COMMIT_TAG.tar.gz
8

Sascha Herzinger's avatar
Sascha Herzinger committed
9
stages:
10
11
    - build_sdist
    - build_image
Sascha Herzinger's avatar
Sascha Herzinger committed
12
    - test
Sascha Herzinger's avatar
Sascha Herzinger committed
13
    - release
Sascha Herzinger's avatar
Sascha Herzinger committed
14

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

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

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

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

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