-
Notifications
You must be signed in to change notification settings - Fork 8
/
.gitlab-ci.yml
129 lines (118 loc) · 3.04 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
variables:
ANSIBLE_FORCE_COLOR: 'true'
RELEASE_TAG: yourlabs/crudlfap:$CI_COMMIT_REF_NAME
IMAGE_TAG: yourlabs/crudlfap:$CI_COMMIT_SHA
build:
stage: build
image: docker:stable
before_script:
- echo "$DOCKER_PASS" | docker login -u $DOCKER_USER --password-stdin
script:
- docker pull yourlabs/crudlfap:master || true
- docker build -t $IMAGE_TAG .
- docker push $IMAGE_TAG
after_script:
- docker logout
build-test:
image:
name: $IMAGE_TAG
entrypoint: ["/bin/sh", "-c"]
stage: test
script:
- pip install -e .[project]
- pip install pytest pytest-cov pytest-asyncio pytest-django
- pytest -vv --cov src --cov-report=xml:coverage.xml --cov-report=term-missing --strict -r fEsxXw src
.deploy: &deploy
before_script:
- mkdir -p ~/.ssh; echo "$CI_SSH_KEY" > ~/.ssh/id_ed25519; echo "$SSH_FINGERPRINTS" > ~/.ssh/known_hosts; chmod 700 ~/.ssh; chmod 600 ~/.ssh/*
script:
- set -x
- export HOST=$(echo $CI_ENVIRONMENT_URL | sed s@^.*://@@)
- export PROTO=$(echo $CI_ENVIRONMENT_URL | sed s@:.*@@)
- export CI_PROJECT_SLUG=$(echo $CI_PROJECT_NAME | sed s@[/.]@-@g)
- export ANSIBLE_HOST_KEY_CHECKING=False
- bigsudo yourlabs.compose
compose_django_build=
compose_django_image=$IMAGE_TAG
wait_grep=uwsgi
pull=no
$DEPLOY
crudlfap@ci.yourlabs.io
| tee deploy.log
- grep unreachable=0 deploy.log &> /dev/null
- grep failed=0 deploy.log &> /dev/null
review-deploy:
image: yourlabs/ansible
stage: test
environment:
name: test/$CI_COMMIT_REF_NAME
url: http://${CI_ENVIRONMENT_SLUG}.crudlfap.ci.yourlabs.io
variables:
DEPLOY: >
compose=docker-compose.yml,docker-compose.traefik.yml
lifetime=86400
project=$CI_ENVIRONMENT_SLUG
except:
- tags
- master
<<: *deploy
master-deploy:
image: yourlabs/ansible
stage: deploy
environment:
name: master
url: https://master.crudlfap.ci.yourlabs.io
variables:
DEPLOY: >
compose=docker-compose.yml,docker-compose.traefik.yml,docker-compose.persist.yml
home=/home/crudlfap-master
only:
refs:
- master
<<: *deploy
demo:
image: yourlabs/ansible
stage: deploy
environment:
name: demo
url: https://demo.crudlfap.ci.yourlabs.io
variables:
DEPLOY: >
compose=docker-compose.yml,docker-compose.traefik.yml,docker-compose.persist.yml
home=/home/crudlfap-demo
only: [tags]
<<: *deploy
docs:
stage: build
image: yourlabs/python-arch
artifacts:
expire_in: 2 days
when: always
paths: [public]
script:
- pip install -r docs/requirements.txt
- pushd docs && make html && popd
- mv docs/_build/html public
py-qa:
stage: build
image: yourlabs/python-arch
script: tox -e qa
py-test:
stage: build
image: yourlabs/python-arch
script:
- tox -e py310-dj40
- codecov-bash -e TOXENV -f coverage.xml
pypi:
stage: deploy
image: yourlabs/python-arch
script: pypi-release
only: [tags]
pages:
stage: test
image: alpine:latest
artifacts:
paths: [public]
only:
- master
script: find public