-
Notifications
You must be signed in to change notification settings - Fork 76
/
Copy pathconfig.yml
436 lines (375 loc) · 11.3 KB
/
config.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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
version: 2.1
filters: &filters
filters:
tags:
only: /^v[0-9]+(\.[0-9]+)*$/
filters__tags: &filters__tags
filters:
branches:
ignore: /.*/
tags:
only: /^v[0-9]+(\.[0-9]+)*$/
workflows:
test:
jobs:
- cache:
<<: *filters
- build:
<<: *filters
requires:
- cache
- test--15:
<<: *filters
requires:
- cache
- test--14:
<<: *filters
requires:
- cache
- test--13:
<<: *filters
requires:
- cache
- test--12:
<<: *filters
requires:
- cache
- test--11:
<<: *filters
requires:
- cache
- test--10:
<<: *filters
requires:
- cache
- test--migrations:
<<: *filters
requires:
- cache
- test--tap-github:
<<: *filters
requires:
- test--12
- test-release:
<<: *filters__tags
requires:
- test--tap-github
- test--migrations
- build
- approve-release:
<<: *filters__tags
type: approval
requires:
- test-release
- release:
<<: *filters__tags
requires:
- approve-release
cache: &cache deps-v7-{{ checksum "poetry.lock" }}-{{ checksum ".circleci/config.yml" }}
py: &py python:3.7.15-bullseye
restore__cache: &restore__cache
restore_cache:
keys:
- *cache
# Simple checkout command to pull external forks.
# The CircleCI util does not work without setting up SSH keys
# which we technically do not need for open-source repos.
checkout_command: &checkout_command
run:
name: checkout
command: |
git clone https://github.com/datamill-co/target-postgres .
if [[ "$CIRCLE_BRANCH" =~ ^pull\/* ]]; then
git fetch origin refs/pull/${CIRCLE_PR_NUMBER}/head
git checkout ${CIRCLE_SHA1}
else
git checkout ${CIRCLE_BRANCH}
fi
install_poetry: &install_poetry
run:
name: Install poetry
command: |
export POETRY_HOME=/opt/poetry
python -m venv $POETRY_HOME
$POETRY_HOME/bin/pip install -U pip
$POETRY_HOME/bin/pip install poetry==1.2.2
$POETRY_HOME/bin/poetry --version
test__base: &test__base
working_directory: /code/
steps:
- *checkout_command
- *restore__cache
- *install_poetry
- attach_workspace:
at: "./"
- run:
name: Run Tests
command: |
source venv/target-postgres/bin/activate
pytest --verbose tests/unit
environment:
POSTGRES_HOST: localhost
POSTGRES_DATABASE: target_postgres_test
POSTGRES_USERNAME: postgres
POSTGRES_PASSWORD: postgres
- store_artifacts:
path: target/test-results
destination: raw-test-output
jobs:
cache:
working_directory: /code/
docker:
- image: *py
steps:
- *checkout_command
- *restore__cache
- *install_poetry
- run:
name: Install target-postgres
command: |
python -m venv venv/target-postgres
source venv/target-postgres/bin/activate
pip install -U pip
/opt/poetry/bin/poetry install --with tests
deactivate
- run:
name: Install older versions of target-postgres for migration testing
command: ./tests/migrations/scripts/install_schema_versions.sh
- run:
name: Install tap-github
command: |
python -m venv venv/tap-github
source venv/tap-github/bin/activate
pip install -U pip
pip install git+https://github.com/MeltanoLabs/tap-github.git@v1.1.0
deactivate
- run:
name: Install tap-postgres
command: |
python -m venv venv/tap-postgres
source venv/tap-postgres/bin/activate
pip install -U pip
pip install tap-postgres
deactivate
- save_cache:
key: *cache
paths:
- "./venv"
- "/usr/local/bin"
- "/usr/local/lib/python3.7/site-packages"
- "/opt/poetry"
- persist_to_workspace:
root: "./"
paths:
- "./venv"
test--15:
<<: *test__base
docker:
- image: *py
- image: postgres:15.0
environment:
POSTGRES_DB: target_postgres_test
POSTGRES_PASSWORD: postgres
test--14:
<<: *test__base
docker:
- image: *py
- image: postgres:14.5
environment:
POSTGRES_DB: target_postgres_test
POSTGRES_PASSWORD: postgres
test--13:
<<: *test__base
docker:
- image: *py
- image: postgres:13.8
environment:
POSTGRES_DB: target_postgres_test
POSTGRES_PASSWORD: postgres
test--12:
<<: *test__base
docker:
- image: *py
- image: postgres:12.12
environment:
POSTGRES_DB: target_postgres_test
POSTGRES_PASSWORD: postgres
test--11:
<<: *test__base
docker:
- image: *py
- image: postgres:11.17-bullseye
environment:
POSTGRES_DB: target_postgres_test
POSTGRES_PASSWORD: postgres
test--10:
<<: *test__base
docker:
- image: *py
- image: postgres:10.22-bullseye
environment:
POSTGRES_DB: target_postgres_test
POSTGRES_PASSWORD: postgres
test--tap-github:
working_directory: /code/
docker:
- image: *py
- image: postgres:12.12
environment:
POSTGRES_DB: target_postgres_test
POSTGRES_PASSWORD: postgres
steps:
- *checkout_command
- *restore__cache
- attach_workspace:
at: "./"
- run:
name: Setup artifacts folder
command: mkdir -p /code/artifacts/data
- run:
name: Setup tap-github
working_directory: /code/.circleci/integration/tap-github
command: sed "s/REPLACE_ME/$TAP_GITHUB_TOKEN/" config-template.json > config.json
- run:
name: Tap -> Data
command: |
source venv/tap-github/bin/activate
cd /code/.circleci/integration/tap-github
tap-github --config config.json --catalog catalog.json > /code/artifacts/data/tap
deactivate
- run:
name: Data -> Target
command: |
source venv/target-postgres/bin/activate
pip install -U pip
/opt/poetry/bin/poetry install
cd /code/.circleci/integration
cat /code/artifacts/data/tap | target-postgres --config target-config.json
deactivate
- run:
name: Target -> Data
command: |
source venv/tap-postgres/bin/activate
cd /code/.circleci/integration/tap-postgres
tap-postgres --config config.json --discover > tmp-properties.json
## Select _every_ table found in properties.
## row-count seems to only show up inside of the necessary metadata object...easier than multi-line-sed
sed 's/"row-count": 0,/"row-count": 0,"selected":true,/g' tmp-properties.json > /code/artifacts/data/properties.json
tap-postgres --config config.json --properties /code/artifacts/data/properties.json > /code/artifacts/data/target
deactivate
- run:
name: Repeatability of Data -> Target
command: |
source venv/target-postgres/bin/activate
pip install -U pip
pip install .
cd /code/.circleci/integration
cat /code/artifacts/data/tap | target-postgres --config target-config.json
deactivate
cd /code/
source venv/tap-postgres/bin/activate
cd /code/.circleci/integration/tap-postgres
tap-postgres --config config.json --discover > tmp-properties.json
## Select _every_ table found in properties.
## row-count seems to only show up inside of the necessary metadata object...easier than multi-line-sed
sed 's/"row-count": 0,/"row-count": 0,"selected":true,/g' tmp-properties.json > /code/artifacts/data/properties.json
tap-postgres --config config.json --properties /code/artifacts/data/properties.json > /code/artifacts/data/target.repeated
deactivate
## TODO: compare repeated data to insure that we only changed _sdc values
# diff /code/artifacts/data/target /code/artifacts/data/target.repeated
- store_artifacts:
path: /code/artifacts
test--migrations:
working_directory: /code/
docker:
- image: *py
- image: postgres:12.12
environment:
POSTGRES_DB: target_postgres_test
POSTGRES_PASSWORD: postgres
steps:
- *checkout_command
- *restore__cache
- *install_poetry
- attach_workspace:
at: "./"
- run:
name: Run Tests
command: |
source venv/target-postgres/bin/activate
pytest --verbose tests/migrations
environment:
POSTGRES_HOST: localhost
POSTGRES_DATABASE: target_postgres_test
POSTGRES_USERNAME: postgres
POSTGRES_PASSWORD: postgres
- store_artifacts:
path: /code/tests/migrations/artifacts
destination: raw-test-output
build:
working_directory: /code/
docker:
- image: *py
steps:
- *checkout_command
- *restore__cache
- attach_workspace:
at: "./"
- run:
name: Build distribution
command: |
source venv/target-postgres/bin/activate
pip install -U pip
pip install --upgrade setuptools wheel twine
/opt/poetry/bin/poetry build
deactivate
- persist_to_workspace:
root: "./"
paths:
- "./dist"
test-release:
working_directory: /code/
docker:
- image: *py
steps:
- *checkout_command
- *restore__cache
- attach_workspace:
at: "./"
- run:
name: Validate tag
command: |
export TAG=`echo $CIRCLE_TAG | sed 's/v//'`
VERSION=`grep version pyproject.toml | sed 's/^.*version = "\(.*\)",.*$/\1/'`
echo tag: $TAG equals version: $VERSION '?'
[[ $TAG == $VERSION ]]
- run:
name: Install upload tools
command: pip install --upgrade twine
- run:
name: Test Publish
environment:
TWINE_USERNAME: datamill
TWINE_REPOSITORY_URL: https://test.pypi.org/legacy/
command: |
export TWINE_PASSWORD=$PYPI__PASSWORD__TEST
twine upload ./dist/*
release:
working_directory: /code/
docker:
- image: *py
steps:
- *checkout_command
- *restore__cache
- attach_workspace:
at: "./"
- run:
name: Install upload tools
command: pip install --upgrade twine
- run:
name: Publish
environment:
TWINE_USERNAME: datamill
command: |
export TWINE_PASSWORD=$PYPI__PASSWORD
twine upload ./dist/*