-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
167 lines (152 loc) · 4.79 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
image: docker:1.10.3
services:
- docker:dind
variables:
DB_NAME: postgres
DB_USER: postgres
DB_PASSWORD: postgres
DB_ADDRESS: postgres
DOCKER_DRIVER: overlay2
before_script:
- which apk && apk add --no-cache bash
- export PROJECT_PATH=$(echo $CI_PROJECT_PATH | awk '{print tolower($0)}')
- export TEST_IMAGE_NAME=registry.gitlab.com/$PROJECT_PATH:$CI_COMMIT_SHA
- export MASTER_NAME=registry.gitlab.com/$PROJECT_PATH:latest
- export RC_NAME=registry.gitlab.com/$PROJECT_PATH:rc
- export RELEASE_NAME=registry.gitlab.com/$PROJECT_PATH:release
stages:
- test
- release
- deploy
cache:
paths:
- /root/.cache/pip
run_tests: &run_tests
image: python:3
stage: test
services:
- postgres:9.6
script:
- apt-get update
- apt-get install -y --no-install-recommends libblas-dev liblapack-dev libatlas-base-dev gfortran g++ git
- pip3 install -r requirements.txt
- pip3 install -r test-requirements.txt
- python3 manage.py makemigrations
- py.test -vv --cov --doctest-modules
- sh .ci/no_changes.sh
except:
- master
run_tests_ee:
<<: *run_tests
before_script:
- ./install_deps.sh
variables:
GIT_SUBMODULE_STRATEGY: normal
only:
- branches@gitmate/open-source/gitmate-2
build_image: &build_image
stage: test
script:
- echo "$CI_COMMIT_SHA" > .version
- docker build -t $TEST_IMAGE_NAME .
- docker login -e [email protected] -u gitlab-ci-token -p $CI_JOB_TOKEN registry.gitlab.com
- docker push $TEST_IMAGE_NAME
except:
- master
build_image_ee:
<<: *build_image
before_script:
- export PROJECT_PATH=$(echo $CI_PROJECT_PATH | awk '{print tolower($0)}')
- export TEST_IMAGE_NAME="registry.gitlab.com/$PROJECT_PATH:$CI_COMMIT_SHA-ee"
variables:
GIT_SUBMODULE_STRATEGY: normal
only:
- branches@gitmate/open-source/gitmate-2
push_master_image:
stage: release
script:
- docker login -e [email protected] -u gitlab-ci-token -p $CI_JOB_TOKEN registry.gitlab.com
- ./.ci/push_image.sh $TEST_IMAGE_NAME $MASTER_NAME
- ./.ci/push_image.sh "$TEST_IMAGE_NAME-ee" "$MASTER_NAME-ee"
only:
- master@gitmate/open-source/gitmate-2
push_rc_image:
stage: release
script:
- docker login -e [email protected] -u gitlab-ci-token -p $CI_JOB_TOKEN registry.gitlab.com
- ./.ci/push_image.sh $TEST_IMAGE_NAME $RC_NAME
- ./.ci/push_image.sh "$TEST_IMAGE_NAME-ee" "$RC_NAME-ee"
only:
- /^rc\/.*$/@gitmate/open-source/gitmate-2
push_release_image: &push_release_image
stage: release
script:
- docker login -e [email protected] -u gitlab-ci-token -p $CI_JOB_TOKEN registry.gitlab.com
- ./.ci/push_image.sh $TEST_IMAGE_NAME $RELEASE_NAME
- ./.ci/push_image.sh "$TEST_IMAGE_NAME-ee" "$RELEASE_NAME-ee"
- ./.ci/send_mattermost.sh "$MATTERMOST_RELEASE_WEBHOOK" "'$CI_COMMIT_REF_NAME' is now pushed to release"
when: manual
only:
- /^rc\/.*$/@gitmate/open-source/gitmate-2
push_hotfix_image:
<<: *push_release_image
when: on_success
only:
- /^hotfix\/.*$/@gitmate/open-source/gitmate-2
deploy_master:
stage: deploy
image: debian:9
script:
- which ssh-agent || (apt-get update -y && apt-get install -y --no-install-recommends openssh-client)
- eval $(ssh-agent -s)
- ssh-add <(echo "$DEPLOY_PRIVATE_KEY")
- mkdir -p ~/.ssh
- echo "$DEPLOY_SERVER_HOSTKEYS" > ~/.ssh/known_hosts
- ssh [email protected] -p $SSH_PORT 'bash -s' < .ci/deploy.master.sh
environment:
name: master
url: https://api.master.gitmate.io
dependencies:
- push_master_image
only:
- master@gitmate/open-source/gitmate-2
deploy_rc:
stage: deploy
image: debian:9
script:
- which ssh-agent || (apt-get update -y && apt-get install -y --no-install-recommends openssh-client)
- eval $(ssh-agent -s)
- ssh-add <(echo "$DEPLOY_PRIVATE_KEY")
- mkdir -p ~/.ssh
- echo "$DEPLOY_SERVER_HOSTKEYS" > ~/.ssh/known_hosts
- ssh [email protected] -p $SSH_PORT 'bash -s' < .ci/deploy.rc.sh
environment:
name: rc
url: https://api.rc.gitmate.io
dependencies:
- push_rc_image
only:
- /^rc\/.*$/@gitmate/open-source/gitmate-2
deploy_release: &deploy_release
stage: deploy
image: debian:9
script:
- which ssh-agent || (apt-get update -y && apt-get install -y --no-install-recommends openssh-client)
- eval $(ssh-agent -s)
- ssh-add <(echo "$DEPLOY_PRIVATE_KEY")
- mkdir -p ~/.ssh
- echo "$DEPLOY_SERVER_HOSTKEYS" > ~/.ssh/known_hosts
- ssh [email protected] -p $SSH_PORT 'bash -s' < .ci/deploy.release.sh
environment:
name: release
url: https://api.gitmate.io
dependencies:
- push_release_image
when: manual
only:
- /^rc\/.*$/@gitmate/open-source/gitmate-2
deploy_hotfix:
<<: *deploy_release
when: on_success
only:
- /^hotfix\/.*$/@gitmate/open-source/gitmate-2