.gitlab-ci.yml 1.44 KB
Newer Older
1
image: centos:latest
2
3

services:
4
5
    - redis:3.2-alpine
    - rabbitmq:3.7-alpine
6

Sascha Herzinger's avatar
Sascha Herzinger committed
7

Sascha Herzinger's avatar
Sascha Herzinger committed
8
9
variables:
    PYPI_USER: SECURE
10
11
12
13
14
    PYPI_PASS: SECURE
    DOCKER_USER: SECURE
    DOCKER_PASS: SECURE
    DOCKER_IMAGE_TAG: fractalis:$CI_COMMIT_TAG
    SDIST: fractalis-$CI_COMMIT_TAG.tar.gz
15

Sascha Herzinger's avatar
Sascha Herzinger committed
16
stages:
17
18
    - prepare
    - build
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
25
26
prepare:
  stage: prepare
  script:
      - yum install -y epel-release
      - yum update -y
27
      - yum install -y python34 python34-pip
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
      - pip3 install twine
  artifacts:
      untracked: true

build:
  stage: build
  script:
      - python3 setup.py sdist
      - docker build -t $DOCKER_IMAGE_TAG --build-arg SDIST=$SDIST .
      - docker save $DOCKER_IMAGE_TAG -o image.tar
  artifacts:
      paths:
          - dist/$SDIST
          - image.tar

test:
Sascha Herzinger's avatar
Sascha Herzinger committed
44
    stage: test
45
    script:
46
47
48
49
50
51
52
53
        - 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"
Sascha Herzinger's avatar
Sascha Herzinger committed
54

Sascha Herzinger's avatar
Sascha Herzinger committed
55
56
release:pypi:
    stage: release
Sascha Herzinger's avatar
Sascha Herzinger committed
57
    script:
58
        - twine upload dist/$SDIST -u $PYPI_USER -p $PYPI_PASS
Sascha Herzinger's avatar
Sascha Herzinger committed
59
    only:
Sascha Herzinger's avatar
Sascha Herzinger committed
60
        - tags
61
62
63
64
65
66
67
68
69

release:docker:
    stage: release
    script:
        - docker load -i image.tar
        - docker login -u $DOCKER_USER -p $DOCKER_PASS
        - docker push $DOCKER_IMAGE_TAG
    only:
        - tags