-
Notifications
You must be signed in to change notification settings - Fork 1
199 lines (191 loc) · 8.13 KB
/
push.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
name: 'GitHub Actions'
'on':
- push
concurrency: 'ci-${{ github.ref }}'
env:
APP_IMAGE: keboola/dbt-transformation
KBC_DEVELOPERPORTAL_VENDOR: keboola
KBC_DEVELOPERPORTAL_APP: keboola.dbt-transformation
KBC_DEVELOPERPORTAL_USERNAME: keboola+dbt_transformation_gha
KBC_DEVELOPERPORTAL_PASSWORD: '${{ secrets.KBC_DEVELOPERPORTAL_PASSWORD }}'
# Snowflake Credentials
SNOWFLAKE_HOST: "keboola.snowflakecomputing.com"
SNOWFLAKE_PORT: 443
SNOWFLAKE_WAREHOUSE: "KEBOOLA_PROD_SMALL"
SNOWFLAKE_DATABASE: "SAPI_9317"
SNOWFLAKE_SCHEMA: "WORKSPACE_964066099"
SNOWFLAKE_USER: "SAPI_WORKSPACE_964066099"
SNOWFLAKE_PASSWORD: ${{ secrets.SNOWFLAKE_PASSWORD }}
# BigQuery
BIGQUERY_PROJECT_ID: devel-249608
BIGQUERY_DATASET: dbt
BIGQUERY_THREADS: 1
BIGQUERY_KEY_CONTENT: ${{ secrets.BIGQUERY_KEY_CONTENT }}
# Redshift
REDSHIFT_DB_HOST: testing.cx4py8yq28xb.us-east-1.redshift.amazonaws.com
REDSHIFT_DB_PORT: 5439
REDSHIFT_DB_USER: dbt_redshift_ci
REDSHIFT_DB_PASSWORD: ${{ secrets.REDSHIFT_PASSWORD }}
REDSHIFT_DB_DATABASE: dbt_redshift_ci
REDSHIFT_DB_SCHEMA: public
REDSHIFT_DB_THREADS: 4
GITHUB_USERNAME: "dbt-test-project-user"
GITHUB_PASSWORD: ${{ secrets.GH_PAT }}
GITLAB_USERNAME: "dbt-test-project-user"
GITLAB_PASSWORD: ${{ secrets.GITLAB_PAT }}
BITBUCKET_USERNAME: "dbt-test-project-user"
BITBUCKET_PASSWORD: ${{ secrets.BITBUCKET_PAT }}
KBC_URL: "https://connection.keboola.com"
KBC_TOKEN: ${{ secrets.KBC_API_TOKEN }}
KBC_TOKEN_NO_RO_MAPPING: ${{ secrets.KBC_API_TOKEN_NO_RO_MAPPING }}
DOCKERHUB_USER: '${{ secrets.DOCKERHUB_USER }}'
DOCKERHUB_TOKEN: '${{ secrets.DOCKERHUB_TOKEN }}'
KBC_STORAGE_TOKEN: '${{ secrets.KBC_STORAGE_TOKEN }}'
KBC_TEST_PROJECT_URL: ''
KBC_TEST_PROJECT_CONFIGS: ''
jobs:
build:
runs-on: ubuntu-latest
outputs:
app_image_tag: '${{ steps.tag.outputs.app_image_tag }}'
is_semantic_tag: '${{ steps.tag.outputs.is_semantic_tag }}'
strategy:
matrix:
APP_ID:
- keboola.dbt-transformation
- keboola.dbt-transformation-remote-snowflake
- keboola.dbt-transformation-remote-postgresql
- keboola.dbt-transformation-remote-mssql
- keboola.dbt-transformation-remote-bigquery
- keboola.dbt-transformation-remote-redshift
dbt_version: [ 1.7.1, 1.6.8, 1.5.9, 1.4.9, 1.3.7, 1.2.6 ]
steps:
-
name: 'Check out the repo'
uses: actions/checkout@v2
-
name: 'Print Docker version'
run: 'docker -v'
-
name: 'Docker login'
if: env.DOCKERHUB_TOKEN
run: 'docker login --username "$DOCKERHUB_USER" --password "$DOCKERHUB_TOKEN"'
-
name: 'Build image'
run: 'docker build --build-arg DBT_VERSION=${{ matrix.dbt_version }} -t $APP_IMAGE .'
-
name: 'Set image tag'
id: tag
run: |
TAG="${GITHUB_REF##*/}"
IS_SEMANTIC_TAG=$(echo "$TAG" | grep -q '^v\?[0-9]\+\.[0-9]\+\.[0-9]\+$' && echo true || echo false)
echo "Tag = '$TAG', is semantic tag = '$IS_SEMANTIC_TAG'"
echo "::set-output name=app_image_tag::$TAG"
echo "::set-output name=is_semantic_tag::$IS_SEMANTIC_TAG"
-
name: 'Push image to ECR'
uses: keboola/action-push-to-ecr@master
with:
vendor: '${{ env.KBC_DEVELOPERPORTAL_VENDOR }}'
app_id: '${{ matrix.APP_ID }}'
username: '${{ env.KBC_DEVELOPERPORTAL_USERNAME }}'
password: '${{ env.KBC_DEVELOPERPORTAL_PASSWORD }}'
tag: '${{ steps.tag.outputs.app_image_tag }}-${{ matrix.dbt_version }}'
push_latest: '${{ steps.tag.outputs.is_semantic_tag }}'
source_image: '${{ env.APP_IMAGE }}'
tests:
needs: build
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 1
matrix:
dbt_version: [ 1.7.1, 1.6.8, 1.5.9, 1.4.9, 1.3.7, 1.2.6 ]
steps:
-
name: 'Check out the repo'
uses: actions/checkout@v2
-
name: 'Pull image from ECR'
uses: keboola/action-pull-from-ecr@master
with:
vendor: '${{ env.KBC_DEVELOPERPORTAL_VENDOR }}'
app_id: '${{ env.KBC_DEVELOPERPORTAL_APP }}'
username: '${{ env.KBC_DEVELOPERPORTAL_USERNAME }}'
password: '${{ env.KBC_DEVELOPERPORTAL_PASSWORD }}'
tag: '${{ needs.build.outputs.app_image_tag }}-${{ matrix.dbt_version }}'
target_image: '${{ env.APP_IMAGE}}'
tag_as_latest: true
-
name: 'Run tests'
run: |
docker-compose run dev composer install
docker-compose run wait
docker-compose run \
-e SNOWFLAKE_HOST \
-e SNOWFLAKE_PORT \
-e SNOWFLAKE_WAREHOUSE \
-e SNOWFLAKE_DATABASE \
-e SNOWFLAKE_SCHEMA \
-e SNOWFLAKE_USER \
-e SNOWFLAKE_PASSWORD \
-e BIGQUERY_PROJECT_ID \
-e BIGQUERY_DATASET \
-e BIGQUERY_THREADS \
-e BIGQUERY_KEY_CONTENT \
-e REDSHIFT_DB_HOST \
-e REDSHIFT_DB_PORT \
-e REDSHIFT_DB_USER \
-e REDSHIFT_DB_PASSWORD \
-e REDSHIFT_DB_DATABASE \
-e REDSHIFT_DB_SCHEMA \
-e REDSHIFT_DB_THREADS \
-e GITHUB_USERNAME \
-e GITHUB_PASSWORD \
-e GITLAB_USERNAME \
-e GITLAB_PASSWORD \
-e BITBUCKET_USERNAME \
-e BITBUCKET_PASSWORD \
-e KBC_URL \
-e KBC_TOKEN \
-e KBC_TOKEN_NO_RO_MAPPING \
dev composer ci
tests-in-kbc:
needs: build
runs-on: ubuntu-latest
steps:
-
name: 'Run KBC test jobs'
if: 'env.KBC_STORAGE_TOKEN && env.KBC_TEST_PROJECT_CONFIGS'
uses: keboola/action-run-configs-parallel@master
with:
token: '${{ env.KBC_STORAGE_TOKEN }}'
componentId: '${{ env.KBC_DEVELOPERPORTAL_APP }}'
tag: '${{ needs.build.outputs.app_image_tag }}-1.5.0'
configs: '${{ env.KBC_TEST_PROJECT_CONFIGS }}'
deploy:
needs:
- build
- tests
- tests-in-kbc
runs-on: ubuntu-latest
if: 'startsWith(github.ref, ''refs/tags/'') && needs.build.outputs.is_semantic_tag == ''true'''
strategy:
matrix:
APP_ID:
- keboola.dbt-transformation
- keboola.dbt-transformation-remote-snowflake
- keboola.dbt-transformation-remote-postgresql
- keboola.dbt-transformation-remote-mssql
- keboola.dbt-transformation-remote-bigquery
- keboola.dbt-transformation-remote-redshift
steps:
-
name: 'Set tag in the Developer Portal'
uses: keboola/action-set-tag-developer-portal@master
with:
vendor: '${{ env.KBC_DEVELOPERPORTAL_VENDOR }}'
app_id: '${{ matrix.APP_ID }}'
username: '${{ env.KBC_DEVELOPERPORTAL_USERNAME }}'
password: '${{ env.KBC_DEVELOPERPORTAL_PASSWORD }}'
tag: '${{ needs.build.outputs.app_image_tag }}-1.5.0'