-
Notifications
You must be signed in to change notification settings - Fork 0
/
.drone.yml
223 lines (205 loc) · 6.09 KB
/
.drone.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
213
214
215
216
217
218
219
220
221
222
223
---
kind: pipeline
type: docker
name: default
environment:
DATABASE_HOST: postgres-1
DATABASE_NAME: opertusmundi
DATABASE_USER: &database_user opertusmundi
BPM_REST_USERNAME: admin
#
# Steps
#
steps:
- name: checkout-submodules
image: alpine/git:v2.30.1
when:
event:
- push
- tag
commands:
- git submodule init
- git submodule update --recursive
- git submodule status
- name: setup-database
image: postgres:10.14-alpine
when:
event:
- push
environment:
DATABASE_POSTGRES_PASSWORD:
from_secret: database_postgres_password
DATABASE_PASSWORD:
from_secret: database_password
commands:
- export PGHOST=$${DATABASE_HOST}
- (t=30; while ! pg_isready -U postgres -t 5; do t=$((t - 1)); test $${t} -ne 0; sleep 3s; done)
# Setup client
- touch ~/.pgpass
- chmod og-rwx ~/.pgpass
- echo "$${DATABASE_HOST}:5432:*:postgres:$${DATABASE_POSTGRES_PASSWORD}" >> ~/.pgpass
- echo "$${DATABASE_HOST}:5432:*:$${DATABASE_USER}:$${DATABASE_PASSWORD}" >> ~/.pgpass
# Create user/database for tests
- echo "CREATE USER \"$${DATABASE_USER}\" WITH PASSWORD '$${DATABASE_PASSWORD}'" | psql -U postgres
- echo "CREATE DATABASE \"$${DATABASE_NAME}\" WITH OWNER \"$${DATABASE_USER}\"" | psql -U postgres
- echo "CREATE EXTENSION \"postgis\"" | psql -U postgres -d $${DATABASE_NAME}
- echo "CREATE EXTENSION \"uuid-ossp\"" | psql -U postgres -d $${DATABASE_NAME}
- psql -U postgres -l -A -t
- psql -U $${DATABASE_USER} -d $${DATABASE_NAME} -A -t -c '\d'
- name: migrate-database
image: flyway/flyway:7.7
when:
event:
- push
environment:
FLYWAY_USER: *database_user
FLYWAY_PASSWORD:
from_secret: database_password
FLYWAY_SCHEMAS: public,web
FLYWAY_DEFAULT_SCHEMA: public
FLYWAY_BASELINE_VERSION: '1_0_0'
FLYWAY_TABLE: _schema_version
FLYWAY_BASELINE_ON_MIGRATE: 'true'
commands:
- export FLYWAY_URL=jdbc:postgresql://$${DATABASE_HOST}:5432/$${DATABASE_NAME}?
- export FLYWAY_LOCATIONS=filesystem:$${PWD}/cli/src/main/resources/db/migration
- flyway info
- flyway migrate
- name: resolve-deps
#image: maven:3.8.6-eclipse-temurin-17-alpine
image: opertusmundi/java-commons-builder:1.1
when:
event:
- push
environment: {}
volumes:
- name: maven-repo
path: /root/.m2
commands:
- mvn -B -pl common install
- mvn -B dependency:resolve
- name: generate-configuration-for-testing
image: busybox:1.32
when:
event:
- push
environment:
DATABASE_PASSWORD:
from_secret: database_password
JWT_SECRET:
from_secret: jwt_secret
BPM_REST_PASSWORD:
from_secret: bpm_rest_password
OAUTH_GITHUB_CLIENT_ID:
from_secret: oauth_github_client_id
OAUTH_GITHUB_CLIENT_SECRET:
from_secret: oauth_github_client_secret
commands:
# Generate configuration for testing
- cd api-gateway
- mkdir ./config
- config_file=./config/application-testing.properties
- >-
( echo "spring.datasource.url=jdbc:postgresql://$${DATABASE_HOST}:5432/$${DATABASE_NAME}";
echo "spring.datasource.username=$${DATABASE_USER}";
echo "spring.datasource.password=$${DATABASE_PASSWORD}";
echo
echo "spring.security.oauth2.client.registration.opertusmundi.provider=github";
echo "spring.security.oauth2.client.registration.opertusmundi.client-id=$${OAUTH_GITHUB_CLIENT_ID}";
echo "spring.security.oauth2.client.registration.opertusmundi.client-secret=$${OAUTH_GITHUB_CLIENT_SECRET}";
echo
echo "opertus-mundi.bpm.worker.rest.base-url = http://bpm-server:8000/engine-rest";
echo "opertus-mundi.bpm.worker.rest.username = $${BPM_REST_USERNAME}";
echo "opertus-mundi.bpm.worker.rest.password = $${BPM_REST_PASSWORD}";
echo
echo "opertusmundi.feign.jwt.secret = $${JWT_SECRET}";
) | tee $${config_file}
- name: tests
#image: maven:3.8.6-eclipse-temurin-17-alpine
image: opertusmundi/java-commons-builder:1.1
when:
event:
- push
environment: {}
volumes:
- name: maven-repo
path: /root/.m2
commands:
- cd api-gateway
- ls -hal ./config
- >-
mvn -B test -DenableCiProfile -DenableJavaBuildProfile -Dlog4j.configurationFile=classpath:config/log4j2.xml
#- name: integration-tests
# #image: maven:3.8.6-eclipse-temurin-17-alpine
# image: opertusmundi/java-commons-builder:1.1
# when:
# event:
# - push
# environment: {}
# volumes:
# - name: maven-repo
# path: /root/.m2
# commands:
# - cd api-gateway
# - ls -hal ./config
# # Todo mvn integration-test
# - >-
# mvn -B test -DenableJavaBuildProfile -DenableCiProfile -Dlog4j.configurationFile=classpath:config/log4j2.xml -Dtest=eu.opertusmundi.web.integration.ApplicationITCase
- name: prepare-tags
image: busybox:1.32
when:
event:
- tag
commands:
- tags_file=$(mktemp)
- echo ${DRONE_TAG} | grep -e '^[0-9]\+[.][0-9]\+[.][0-9]\+\([_-][a-z0-9][-.a-z0-9]*\)\?$' | tee -a $${tags_file}
- echo ${DRONE_TAG} | grep -o -e '^[0-9]\+[.][0-9]\+[.][0-9]\+' | tee -a $${tags_file}
- cat $${tags_file} | xargs echo | tr '[:blank:]' ',' | tr -d '\n' | tee .tags && echo
- name: publish-image-1
image: plugins/docker
when:
event:
- tag
settings:
debug: true
username:
from_secret: docker_username
password:
from_secret: docker_password
repo: opertusmundi/api-gateway
mirror: http://registry-mirror:5000
build_args: &build_args
- git_url=${DRONE_GIT_HTTP_URL}
- git_commit=${DRONE_COMMIT}
- git_tags=${DRONE_TAG}
- git_build_time=${DRONE_BUILD_STARTED}
#- name: publish-image-2
# image: plugins/docker
# when:
# event:
# - tag
# settings:
# debug: true
# username:
# from_secret: registry_username
# password:
# from_secret: registry_password
# repo: registry-dev-1-opertusmundi:30474/opertusmundi/api-gateway
# mirror: http://registry-mirror:5000
# registry: registry-dev-1-opertusmundi:30474
# build_args: *build_args
#
# Services
#
services:
- name: postgres-1
image: postgis/postgis:10-3.0-alpine
environment:
POSTGRES_PASSWORD:
from_secret: database_postgres_password
#
# Volumes
#
volumes:
- name: maven-repo
temp: {}