-
Notifications
You must be signed in to change notification settings - Fork 3
/
.gitlab-ci.yml
212 lines (194 loc) · 6.95 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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
stages:
- dockerbuild
- test
- build
- package
- publish
variables:
CARGO_FLAGS: "--release"
RUST_VERSION: 1.43.0
PACKAGE_VERSION: 0.1.13
# Helpers / Anchors
.docker_micro:
tags:
- docker-machine
- large
.kaniko_build:
tags:
- docker-machine
- micro
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
script:
- if [ "$CI_COMMIT_REF_SLUG" == 'master' ]; then KANIKO_ARGS="--destination $CI_REGISTRY_IMAGE/${DOCKER_IMAGE_NAME}:latest $KANIKO_ARGS"; fi
- echo "${KANIKO_ARGS}"
- |
echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" \
> /kaniko/.docker/config.json
- |
echo "-----BEGIN CERTIFICATE-----
MIIFJTCCAw2gAwIBAgIUMI0Z8YSLeRq8pZks40O3Dq2m8TIwDQYJKoZIhvcNAQEL
BQAwGjEYMBYGA1UEAxMPRXZlcm55bSBSb290IENBMB4XDTE3MTAxM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hXa3xTxD3gpCQZ6Bz04KlcLfZd5jzbI741bVDyF
a1n46bEyuqV4SsNJWI/FGokJCNcZH66njBQBaQAccZ7xB9vWU9yjIYtGQDDvSm6J
SC2knrQri0vv4QLUSc1LS6AlWWSQxcCpcdO+OzIFGsf5bVmYN6J4R3COY5NyQ+yn
pOSN2NOh5h3ZrYAxm3i4Il0orVLveVcTVDGeAgZUII4YLJi/01RHGqit3aCuApSh
bzFTZ5FldFss+JX9iAhqpFDbHLgae0F3QmYEnGilt/PzO4j23QJo3FZKeruQLH7P
L9aOgN6S2+Akbbm9YTc59yzU5TZMxANwTdaYFWFqk/8nKgZiBR1l8jnWTlWnm86A
qVssH3DLKwiYrWSOHRzGuN5BmPXxxtKQJlwAXt0wJE3puUkaJSRo7CJQ3QNMoKDe
OjzXc9WvkFIXr3Eui8UTiHB/WT7N4o8hmVN404akGfWE0YNwRVfWpjGdew6g0tZi
lFnjUUk49av67um43JHcinT5NFPuleZzkjaL/D8ueOrjXQDy05rwVdgmw9pXog4B
Tw6APXtEnjfD2H8HOpOX/7ef4gWK0O1Q7A==
-----END CERTIFICATE-----" >> /kaniko/ssl/certs/ca-certificates.crt
- |
/kaniko/executor ${KANIKO_ARGS} --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/${DOCKERFILE_PATH} \
--destination $CI_REGISTRY_IMAGE/${DOCKER_IMAGE_NAME}:${CI_COMMIT_REF_SLUG}
# Jobs
mysql-wallet-storage-buildtools:
extends: .kaniko_build
stage: dockerbuild
variables:
DOCKERFILE_PATH: mysql-wallet-storage-buildtools.dockerfile
DOCKER_IMAGE_NAME: mysql-wallet-storage-buildtools
KANIKO_ARGS: "--build-arg RUST_VERSION=${RUST_VERSION}"
only:
refs:
- master
- /^docker-.*/
changes:
- .gitlab-ci.yml
- mysql-wallet-storage-buildtools.dockerfile
#dry-mode: compile but don't actually run tests.
.test-dry:
extends: .docker_micro
stage: test
script:
- cargo --version
- rustc --version
- cd libmysqlstorage
- cargo clean
- RUST_BACKTRACE=1 cargo test ${CARGO_FLAGS} --no-run
test-dry-from-latest:
extends: .test-dry
image: ${CI_REGISTRY_IMAGE}/mysql-wallet-storage-buildtools:latest
except:
refs:
- /^docker-.*/
test-dry-from-branch:
extends: .test-dry
image: ${CI_REGISTRY_IMAGE}/mysql-wallet-storage-buildtools:${CI_COMMIT_REF_SLUG}
only:
refs:
- /^docker-.*/
#compile and run tests
.test:
extends: .docker_micro
stage: test
variables:
MYSQL_DATABASE: "wallet"
MYSQL_ROOT_PASSWORD: "root"
DB_NAME: "wallet"
DB_READ_HOST: "mysql"
DB_WRITE_HOST: "mysql"
DB_USER: "root"
DB_PASS: "root"
DB_PORT: "3306"
script:
- cargo --version
- rustc --version
- mysql -h ${DB_READ_HOST} -u ${DB_USER} -p${DB_PASS} < db_scripts/schema/change_scripts/wallet_schema_creation.2018-05-07.sql
- echo "show tables;" | mysql -h ${DB_READ_HOST} -u ${DB_USER} -p${DB_PASS} wallet
- echo "create user 'test' identified with mysql_native_password by 'test' require none" | mysql -h ${DB_READ_HOST} -u ${DB_USER} -p${DB_PASS}
- echo "grant all on wallet.* to 'test'" | mysql -h ${DB_READ_HOST} -u ${DB_USER} -p${DB_PASS}
- cd libmysqlstorage
- cargo clean
- DB_USER=test DB_PASS=test RUST_TEST_THREADS=1 RUST_BACKTRACE=1 RUST_LOG=trace cargo test ${CARGO_FLAGS}
.test-mysql-5.7:
extends: .test
services:
- name: mysql:5
alias: mysql
test-mysql-5.7-from-latest:
extends: .test-mysql-5.7
image: ${CI_REGISTRY_IMAGE}/mysql-wallet-storage-buildtools:latest
except:
refs:
- /^docker-.*/
test-mysql-5.7-from-branch:
extends: .test-mysql-5.7
image: ${CI_REGISTRY_IMAGE}/mysql-wallet-storage-buildtools:${CI_COMMIT_REF_SLUG}
only:
refs:
- /^docker-.*/
.test-mysql-8:
extends: .test
services:
- name: mysql:8
test-mysql-8-from-latest:
extends: .test-mysql-8
image: ${CI_REGISTRY_IMAGE}/mysql-wallet-storage-buildtools:latest
except:
refs:
- /^docker-.*/
test-mysql-8-from-branch:
extends: .test-mysql-8
image: ${CI_REGISTRY_IMAGE}/mysql-wallet-storage-buildtools:${CI_COMMIT_REF_SLUG}
only:
refs:
- /^docker-.*/
.build-and-package:
extends: .docker_micro
stage: package
artifacts:
paths:
- libmysqlstorage/target
script:
- cd libmysqlstorage
- cargo install cargo-deb
- cargo deb
- cd target/debian
- echo ${CI_COMMIT_REF_SLUG}
- ./../../../devops/finalize_package.sh ${PACKAGE_VERSION} ${CI_PIPELINE_IID} ${CI_COMMIT_REF_SLUG}
build-and-package-from-latest:
extends: .build-and-package
image: ${CI_REGISTRY_IMAGE}/mysql-wallet-storage-buildtools:latest
except:
refs:
- /^docker-.*/
build-and-package-from-branch:
extends: .build-and-package
image: ${CI_REGISTRY_IMAGE}/mysql-wallet-storage-buildtools:${CI_COMMIT_REF_SLUG}
only:
refs:
- /^docker-.*/
publish:
image: ${CI_REGISTRY_IMAGE}/mysql-wallet-storage-buildtools:latest
only:
refs:
- master@dev/mysql-wallet-storage
- stable@dev/mysql-wallet-storage
extends: .docker_micro
stage: publish
artifacts:
paths:
- libmysqlstorage/target
script:
- devops/publish.sh "${KRK_USERNAME}:${KRK_PASSWORD}" libmysqlstorage*.deb https://kraken.corp.evernym.com/repo/portal_dev/upload
- devops/publish.sh "${KRK_USERNAME}:${KRK_PASSWORD}" libmysqlstorage*.deb https://kraken.corp.evernym.com/repo/agency_dev/upload