-
Notifications
You must be signed in to change notification settings - Fork 3.8k
499 lines (496 loc) · 22.2 KB
/
publish-command.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
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
name: Publish Connector Image
on:
workflow_dispatch:
inputs:
repo:
description: "Repo to check out code from. Defaults to the main airbyte repo. Set this when building connectors from forked repos."
required: false
default: "airbytehq/airbyte"
gitref:
description: "The git ref to check out from the specified repository."
required: false
default: master
connector:
description: "Airbyte Connector"
required: true
comment-id:
description: "The comment-id of the slash command. Used to update the comment with the status."
required: false
auto-bump-version:
description: "after publishing, the workflow will automatically bump the connector version in definitions and generate seed spec"
required: true
default: "true"
parallel:
description: "Switching this to true will spin up 5 build agents instead of 1 and allow multi connector publishes to run in parallel"
required: true
default: "false"
run-tests:
description: "Should run tests when publishing"
required: true
default: "true"
pre-release:
description: "Should publish a pre-release version"
required: true
default: false
jobs:
## Gradle Build
# In case of self-hosted EC2 errors, remove this block.
start-publish-image-runner-0:
name: Start Build EC2 Runner 0
runs-on: ubuntu-latest
outputs:
label: ${{ steps.start-ec2-runner.outputs.label }}
ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }}
steps:
- name: Checkout Airbyte
uses: actions/checkout@v3
with:
repository: ${{ github.event.inputs.repo }}
ref: ${{ github.event.inputs.gitref }}
- name: Check PAT rate limits
run: |
./tools/bin/find_non_rate_limited_PAT \
${{ secrets.GH_PAT_BUILD_RUNNER_OSS }} \
${{ secrets.GH_PAT_BUILD_RUNNER_BACKUP }}
- name: Start AWS Runner
id: start-ec2-runner
uses: ./.github/actions/start-aws-runner
with:
aws-access-key-id: ${{ secrets.SELF_RUNNER_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.SELF_RUNNER_AWS_SECRET_ACCESS_KEY }}
github-token: ${{ env.PAT }}
label: ${{ github.run_id }}-publisher
start-publish-image-runner-1:
if: github.event.inputs.parallel == 'true' && success()
name: Start Build EC2 Runner 1
runs-on: ubuntu-latest
outputs:
label: ${{ steps.start-ec2-runner.outputs.label }}
ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }}
steps:
- name: Checkout Airbyte
uses: actions/checkout@v3
with:
repository: ${{ github.event.inputs.repo }}
ref: ${{ github.event.inputs.gitref }}
- name: Check PAT rate limits
run: |
./tools/bin/find_non_rate_limited_PAT \
${{ secrets.GH_PAT_BUILD_RUNNER_OSS }} \
${{ secrets.GH_PAT_BUILD_RUNNER_BACKUP }}
- name: Start AWS Runner
id: start-ec2-runner
uses: ./.github/actions/start-aws-runner
with:
aws-access-key-id: ${{ secrets.SELF_RUNNER_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.SELF_RUNNER_AWS_SECRET_ACCESS_KEY }}
github-token: ${{ env.PAT }}
label: ${{ github.run_id }}-publisher
start-publish-image-runner-2:
if: github.event.inputs.parallel == 'true' && success()
name: Start Build EC2 Runner 2
runs-on: ubuntu-latest
outputs:
label: ${{ steps.start-ec2-runner.outputs.label }}
ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }}
steps:
- name: Checkout Airbyte
uses: actions/checkout@v3
with:
repository: ${{ github.event.inputs.repo }}
ref: ${{ github.event.inputs.gitref }}
- name: Check PAT rate limits
run: |
./tools/bin/find_non_rate_limited_PAT \
${{ secrets.GH_PAT_BUILD_RUNNER_OSS }} \
${{ secrets.GH_PAT_BUILD_RUNNER_BACKUP }}
- name: Start AWS Runner
id: start-ec2-runner
uses: ./.github/actions/start-aws-runner
with:
aws-access-key-id: ${{ secrets.SELF_RUNNER_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.SELF_RUNNER_AWS_SECRET_ACCESS_KEY }}
github-token: ${{ env.PAT }}
label: ${{ github.run_id }}-publisher
start-publish-image-runner-3:
if: github.event.inputs.parallel == 'true' && success()
name: Start Build EC2 Runner 3
runs-on: ubuntu-latest
outputs:
label: ${{ steps.start-ec2-runner.outputs.label }}
ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }}
steps:
- name: Checkout Airbyte
uses: actions/checkout@v3
with:
repository: ${{ github.event.inputs.repo }}
ref: ${{ github.event.inputs.gitref }}
- name: Check PAT rate limits
run: |
./tools/bin/find_non_rate_limited_PAT \
${{ secrets.GH_PAT_BUILD_RUNNER_OSS }} \
${{ secrets.GH_PAT_BUILD_RUNNER_BACKUP }}
- name: Start AWS Runner
id: start-ec2-runner
uses: ./.github/actions/start-aws-runner
with:
aws-access-key-id: ${{ secrets.SELF_RUNNER_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.SELF_RUNNER_AWS_SECRET_ACCESS_KEY }}
github-token: ${{ env.PAT }}
label: ${{ github.run_id }}-publisher
start-publish-image-runner-4:
if: github.event.inputs.parallel == 'true' && success()
name: Start Build EC2 Runner 4
runs-on: ubuntu-latest
outputs:
label: ${{ steps.start-ec2-runner.outputs.label }}
ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }}
steps:
- name: Checkout Airbyte
uses: actions/checkout@v3
with:
repository: ${{ github.event.inputs.repo }}
ref: ${{ github.event.inputs.gitref }}
- name: Check PAT rate limits
run: |
./tools/bin/find_non_rate_limited_PAT \
${{ secrets.GH_PAT_BUILD_RUNNER_OSS }} \
${{ secrets.GH_PAT_BUILD_RUNNER_BACKUP }}
- name: Start AWS Runner
id: start-ec2-runner
uses: ./.github/actions/start-aws-runner
with:
aws-access-key-id: ${{ secrets.SELF_RUNNER_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.SELF_RUNNER_AWS_SECRET_ACCESS_KEY }}
github-token: ${{ env.PAT }}
label: ${{ github.run_id }}-publisher
preprocess-matrix:
needs: start-publish-image-runner-0
runs-on: ${{ needs.start-publish-image-runner-0.outputs.label }}
outputs:
connectorjson: ${{ steps.preprocess.outputs.connectorjson }}
steps:
# given a string input of a single connector or comma separated list of connectors e.g. connector1, connector2
# this step builds an array, by removing whitespace, add in quotation marks around connectors and braces [ ] at the start and end
# finally, it sets it as output from this job so we can use this array of connectors as our matrix strategy for publishing
- id: preprocess
run: |
start="[\""
replace="\",\""
end="\"]"
stripped_connector="$(echo "${{ github.event.inputs.connector }}" | tr -d ' ')"
middle=${stripped_connector//,/$replace}
full="$start$middle$end"
echo "connectorjson=$full" >> $GITHUB_OUTPUT
write-initial-output-to-comment:
name: Set up git comment
if: github.event.inputs.comment-id
needs: start-publish-image-runner-0
runs-on: ${{ needs.start-publish-image-runner-0.outputs.label }}
steps:
- name: Print start message
if: github.event.inputs.comment-id && success()
uses: peter-evans/create-or-update-comment@v1
with:
comment-id: ${{ github.event.inputs.comment-id }}
body: |
> :clock2: Publishing the following connectors:<br>${{ github.event.inputs.connector }}<br>https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}
- name: Create table header
uses: peter-evans/create-or-update-comment@v1
with:
comment-id: ${{ github.event.inputs.comment-id }}
body: |
<br>
| Connector | Version | Did it publish? | Were definitions generated? |
- name: Create table separator
uses: peter-evans/create-or-update-comment@v1
with:
comment-id: ${{ github.event.inputs.comment-id }}
body: |
| --- | --- | --- | --- |
publish-image:
timeout-minutes: 240
needs:
- start-publish-image-runner-0
- preprocess-matrix
- write-initial-output-to-comment
strategy:
max-parallel: 5
fail-fast: false
matrix:
connector: ${{ fromJSON(needs.preprocess-matrix.outputs.connectorjson) }}
runs-on: runner-pool-${{ github.run_id }}
steps:
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v0
with:
service_account_key: ${{ secrets.SPEC_CACHE_SERVICE_ACCOUNT_KEY }}
export_default_credentials: true
- name: Search for valid connector name format
id: regex
uses: AsasInnab/regex-action@v1
with:
regex_pattern: "^(connectors|bases)/[a-zA-Z0-9-_]+$"
regex_flags: "i" # required to be set for this plugin
search_string: ${{ matrix.connector }}
- name: Validate input workflow format
if: steps.regex.outputs.first_match != matrix.connector
run: echo "The connector provided has an invalid format!" && exit 1
- name: Checkout Airbyte
uses: actions/checkout@v3
with:
repository: ${{ github.event.inputs.repo }}
ref: ${{ github.event.inputs.gitref }}
token: ${{ secrets.GH_PAT_MAINTENANCE_OSS }}
- name: Install Java
uses: actions/setup-java@v3
with:
distribution: "zulu"
java-version: "17"
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: "3.9"
- name: Install Pyenv
run: |
python3 -m pip install --quiet virtualenv==16.7.9 --user
rm -r venv || echo "no pre-existing venv"
python3 -m virtualenv venv
source venv/bin/activate
- name: Install yq
if: github.event.inputs.auto-bump-version == 'true' && github.event.inputs.pre-release != 'true' && success()
run: |
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys CC86BB64
sudo add-apt-repository ppa:rmescandon/yq
sudo apt update
sudo apt install yq -y
- name: Install CI scripts
# all CI python packages have the prefix "ci_"
run: |
source venv/bin/activate
pip install --quiet -e ./tools/ci_*
- name: Write Integration Test Credentials for ${{ matrix.connector }}
run: |
source venv/bin/activate
ci_credentials ${{ matrix.connector }} write-to-storage
# normalization also runs destination-specific tests, so fetch their creds also
if [ 'bases/base-normalization' = "${{ matrix.connector }}" ] || [ 'base-normalization' = "${{ matrix.connector }}" ]; then
ci_credentials destination-bigquery write-to-storage
ci_credentials destination-postgres write-to-storage
ci_credentials destination-snowflake write-to-storage
fi
env:
GCP_GSM_CREDENTIALS: ${{ secrets.GCP_GSM_CREDENTIALS }}
- name: Set Name and Version Environment Vars
if: startsWith(matrix.connector, 'connectors')
run: |
source tools/lib/lib.sh
DOCKERFILE=airbyte-integrations/${{ matrix.connector }}/Dockerfile
echo "IMAGE_NAME=$(echo ${{ matrix.connector }} | cut -d"/" -f2)" >> $GITHUB_ENV
echo "IMAGE_VERSION=$(_get_docker_image_version ${DOCKERFILE} ${{ github.event.inputs.pre-release }})" >> $GITHUB_ENV
- name: Prepare Sentry
if: startsWith(matrix.connector, 'connectors')
uses: Wandalen/wretry.action@master
with:
attempt_limit: 3
attempt_delay: 5000 # in ms
command: curl -sL https://sentry.io/get-cli/ | bash || echo "sentry cli already installed"
- name: Publish ${{ matrix.connector }}
id: publish
env:
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }}
DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }}
# Oracle expects this variable to be set. Although usually present, this is not set by default on Github virtual runners.
TZ: UTC
uses: Wandalen/wretry.action@master
with:
command: |
echo "$SPEC_CACHE_SERVICE_ACCOUNT_KEY" > spec_cache_key_file.json && docker login -u ${DOCKER_HUB_USERNAME} -p ${DOCKER_HUB_PASSWORD}
./tools/integrations/manage.sh publish airbyte-integrations/${{ matrix.connector }} ${{ github.event.inputs.run-tests }} --publish_spec_to_cache ${{ github.event.inputs.pre-release == 'true' && '--pre_release' || '' }}
attempt_limit: 3
attempt_delay: 5000 in # ms
- name: Update Integration Test Credentials after test run for ${{ github.event.inputs.connector }}
if: always()
run: |
source venv/bin/activate
ci_credentials ${{ matrix.connector }} update-secrets
# normalization also runs destination-specific tests, so fetch their creds also
if [ 'bases/base-normalization' = "${{ matrix.connector }}" ] || [ 'base-normalization' = "${{ matrix.connector }}" ]; then
ci_credentials destination-bigquery update-secrets
ci_credentials destination-postgres update-secrets
ci_credentials destination-snowflake update-secrets
fi
env:
GCP_GSM_CREDENTIALS: ${{ secrets.GCP_GSM_CREDENTIALS }}
- name: Create Sentry Release
if: startsWith(matrix.connector, 'connectors') && success()
run: |
SENTRY_RELEASE_NAME="airbyte-${{ env.IMAGE_NAME }}@${{ env.IMAGE_VERSION }}"
sentry-cli releases set-commits "$SENTRY_RELEASE_NAME" --auto --ignore-missing &&
sentry-cli releases finalize "$SENTRY_RELEASE_NAME"
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_CONNECTOR_RELEASE_AUTH_TOKEN }}
SENTRY_ORG: airbytehq
SENTRY_PROJECT: connector-incident-management
- name: Check if connector in definitions yaml
if: github.event.inputs.auto-bump-version == 'true' && github.event.inputs.pre-release != 'true' && success()
run: |
connector="airbyte/${{ env.IMAGE_NAME }}"
definitionpath=./airbyte-config-oss/init-oss/src/main/resources/seed/
sourcecheck=$(yq e ".. | select(has(\"dockerRepository\")) | select(.dockerRepository == \"$connector\")" "$definitionpath"source_definitions.yaml)
destcheck=$(yq e ".. | select(has(\"dockerRepository\")) | select(.dockerRepository == \"$connector\")" "$definitionpath"destination_definitions.yaml)
if [[ (-z "$sourcecheck" && -z "$destcheck") ]]
then exit 1
fi
- name: Bump version in definitions yaml
if: github.event.inputs.auto-bump-version == 'true' && github.event.inputs.pre-release != 'true' && success()
run: |
connector="airbyte/${{ env.IMAGE_NAME }}"
definitionpath=./airbyte-config-oss/init-oss/src/main/resources/seed/
sourcename=$(yq e ".[] | select(has(\"dockerRepository\")) | select(.dockerRepository == \"$connector\") | .name" "$definitionpath"source_definitions.yaml)
destname=$(yq e ".[] | select(has(\"dockerRepository\")) | select(.dockerRepository == \"$connector\") | .name" "$definitionpath"destination_definitions.yaml)
if [ -z "$sourcename" ]
then yq e "(.[] | select(.name == \"$destname\").dockerImageTag)|=\"${{ env.IMAGE_VERSION }}\"" -i "$definitionpath"destination_definitions.yaml
else yq e "(.[] | select(.name == \"$sourcename\").dockerImageTag)|=\"${{ env.IMAGE_VERSION }}\"" -i "$definitionpath"source_definitions.yaml
fi
- name: Run gradle process changes
if: github.event.inputs.auto-bump-version == 'true' && github.event.inputs.pre-release != 'true' && success()
uses: Wandalen/wretry.action@master
with:
command: ./gradlew :airbyte-config-oss:init-oss:processResources
attempt_limit: 3
attempt_delay: 5000 # in ms
- name: git config
if: github.event.inputs.auto-bump-version == 'true' && success()
run: |
git config user.name 'Octavia Squidington III'
git config user.email 'octavia-squidington-iii@users.noreply.github.com'
- name: git commit and push
if: github.event.inputs.auto-bump-version == 'true' && github.event.inputs.pre-release != 'true' && success()
run: |
git add -u
git commit -m "auto-bump connector version"
git pull origin ${{ github.event.inputs.gitref }}
git push origin ${{ github.event.inputs.gitref }}
id: auto-bump
- name: Process outcomes into emojis
if: ${{ always() && github.event.inputs.comment-id }}
run: |
if [[ ${{ steps.publish.outcome }} = "success" ]]; then
echo "PUBLISH_OUTCOME=:white_check_mark:" >> $GITHUB_ENV
else
echo "PUBLISH_OUTCOME=:x:" >> $GITHUB_ENV
fi
if [[ ${{ steps.auto-bump.outcome }} = "success" ]]; then
echo "AUTO_BUMP_OUTCOME=:white_check_mark:" >> $GITHUB_ENV
else
echo "AUTO_BUMP_OUTCOME=:x:" >> $GITHUB_ENV
fi
- name: Add connector outcome line to table
if: ${{ always() && github.event.inputs.comment-id }}
uses: peter-evans/create-or-update-comment@v1
with:
comment-id: ${{ github.event.inputs.comment-id }}
body: |
| ${{ matrix.connector }} | ${{ env.IMAGE_VERSION }} | ${{ env.PUBLISH_OUTCOME }} | ${{ env.AUTO_BUMP_OUTCOME }} |
add-helpful-info-to-git-comment:
if: ${{ always() && github.event.inputs.comment-id }}
name: Add extra info to git comment
needs:
- start-publish-image-runner-0 # required to get output from the start-runner job
- publish-image # required to wait when the main job is done
runs-on: ubuntu-latest
steps:
- name: Add hint for manual seed definition update
uses: peter-evans/create-or-update-comment@v1
with:
comment-id: ${{ github.event.inputs.comment-id }}
body: |
<br>
if you have connectors that successfully published but failed definition generation, follow [step 4 here ▶️](https://docs.airbyte.com/connector-development/#publishing-a-connector)
# In case of self-hosted EC2 errors, remove this block.
stop-publish-image-runner-0:
if: ${{ always() }} # required to stop the runner even if the error happened in the previous jobs
name: Stop Build EC2 Runner
needs:
- start-publish-image-runner-0 # required to get output from the start-runner job
- preprocess-matrix
- publish-image # required to wait when the main job is done
- add-helpful-info-to-git-comment
runs-on: ubuntu-latest
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.SELF_RUNNER_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.SELF_RUNNER_AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-2
- name: Checkout Airbyte
uses: actions/checkout@v3
- name: Check PAT rate limits
run: |
./tools/bin/find_non_rate_limited_PAT \
${{ secrets.GH_PAT_BUILD_RUNNER_OSS }} \
${{ secrets.GH_PAT_BUILD_RUNNER_BACKUP }}
- name: Stop EC2 runner
uses: airbytehq/ec2-github-runner@base64v1.1.0
with:
mode: stop
github-token: ${{ env.PAT }}
label: ${{ needs.start-publish-image-runner-0.outputs.label }}
ec2-instance-id: ${{ needs.start-publish-image-runner-0.outputs.ec2-instance-id }}
stop-publish-image-runner-multi:
if: ${{ always() && github.event.inputs.parallel == 'true' }}
name: Stop Build EC2 Runner
needs:
- start-publish-image-runner-0
- start-publish-image-runner-1
- start-publish-image-runner-2
- start-publish-image-runner-3
- start-publish-image-runner-4
- preprocess-matrix
- publish-image # required to wait when the main job is done
strategy:
fail-fast: false
matrix:
ec2-instance:
[
{
"label": "${{ needs.start-publish-image-runner-1.outputs.label }}",
"id": "${{ needs.start-publish-image-runner-1.outputs.ec2-instance-id }}",
},
{
"label": "${{ needs.start-publish-image-runner-2.outputs.label }}",
"id": "${{ needs.start-publish-image-runner-2.outputs.ec2-instance-id }}",
},
{
"label": "${{ needs.start-publish-image-runner-3.outputs.label }}",
"id": "${{ needs.start-publish-image-runner-3.outputs.ec2-instance-id }}",
},
{
"label": "${{ needs.start-publish-image-runner-4.outputs.label }}",
"id": "${{ needs.start-publish-image-runner-4.outputs.ec2-instance-id }}",
},
]
runs-on: ubuntu-latest
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.SELF_RUNNER_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.SELF_RUNNER_AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-2
- name: Checkout Airbyte
uses: actions/checkout@v3
- name: Check PAT rate limits
run: |
./tools/bin/find_non_rate_limited_PAT \
${{ secrets.GH_PAT_BUILD_RUNNER_OSS }} \
${{ secrets.GH_PAT_BUILD_RUNNER_BACKUP }}
- name: Stop EC2 runner
uses: airbytehq/ec2-github-runner@base64v1.1.0
with:
mode: stop
github-token: ${{ env.PAT }}
label: ${{ matrix.ec2-instance.label }}
ec2-instance-id: ${{ matrix.ec2-instance.id }}