-
Notifications
You must be signed in to change notification settings - Fork 3
/
.gitlab-ci.yml
95 lines (88 loc) · 2.31 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
variables:
PYPI_USER: secure
PYPI_PASS: secure
DOCKER_USER: secure
DOCKER_PASS: secure
DOCKER_DRIVER: overlay2
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
stages:
- build_sdist
- build_image
- test
- release
build:sdist:
stage: build_sdist
image: python:3.6-alpine
script:
- python3 setup.py sdist
artifacts:
expire_in: 1h
paths:
- dist/
build:image:
stage: build_image
image: docker:latest
services:
- docker:dind
tags:
- privileged
script:
- docker build -t $DOCKER_USER/$DOCKER_IMAGE_TAG -f docker/Dockerfile --build-arg SDIST=dist/$SDIST .
- docker save $DOCKER_USER/$DOCKER_IMAGE_TAG -o image.tar
dependencies:
- build:sdist
artifacts:
expire_in: 1h
paths:
- image.tar
test:
stage: test
image: docker:latest
tags:
- privileged
services:
- redis:3.2-alpine
- rabbitmq:3.7-alpine
- docker:dind
script:
- docker load -i image.tar
- >
docker run
$DOCKER_USER/$DOCKER_IMAGE_TAG
sh -c "
printf \"REDIS_HOST='$REDIS_PORT_6379_TCP_ADDR'\nBROKER_URL='amqp://guest:guest@$RABBITMQ_PORT_5672_TCP_ADDR:5672//'\nCELERY_RESULT_BACKEND='redis://$REDIS_PORT_6379_TCP_ADDR:6379'\"
> /config.py
&& export FRACTALIS_CONFIG=/config.py
&& celery worker -D -A fractalis:celery -l debug --concurrency=1
&& pytest --color=yes --verbose --capture=no --cov=/usr/lib/python3.6/site-packages/fractalis tests/
"
dependencies:
- build:image
release:pypi:
stage: release
image: python:3.6-alpine
script:
- pip3 install twine
- twine upload dist/$SDIST -u $PYPI_USER -p $PYPI_PASS
dependencies:
- build:sdist
only:
- tags
release:docker:
stage: release
image: docker:latest
services:
- docker:dind
tags:
- privileged
script:
- docker load -i image.tar
- docker login -u $DOCKER_USER -p $DOCKER_PASS
- docker push $DOCKER_USER/$DOCKER_IMAGE_TAG
dependencies:
- build:image
only:
- tags