-
Notifications
You must be signed in to change notification settings - Fork 0
470 lines (405 loc) · 15.4 KB
/
main.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
name: CI
on:
push:
branches:
- 'main'
tags:
- '**'
pull_request:
pull_request_target:
workflow_dispatch:
jobs:
test-and-package:
strategy:
matrix:
include:
- os: ubuntu-latest
target: darwin-x64
zetasql-lib: remote_server
- os: ubuntu-latest
target: darwin-arm64
zetasql-lib: remote_server_arm
- os: ubuntu-latest
target: linux-x64
zetasql-lib: remote_server.so
- os: ubuntu-latest
target: linux-arm64
zetasql-lib: remote_server_arm.so
- os: windows-latest
target: win32-x64
zetasql-lib: remote_server.so
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
steps:
- name: checkout
uses: actions/checkout@v4
- name: set up node
uses: actions/setup-node@v4
with:
node-version: '19.x'
- name: build and test
run: |
npm install
npm run build
npm run lint
npm run ts-unused-exports
npm run test
- name: set environment variable with file name
run: echo "FILE_NAME=${{ github.sha }}-${{ matrix.target }}.vsix" >> $GITHUB_ENV
- name: delete libraries for other platforms
run: |
find server/node_modules/@fivetrandevelopers/zetasql/lib/zetasql -maxdepth 1 -type f ! -name '${{ matrix.zetasql-lib }}' -exec rm -f {} \;
find server/node_modules/@fivetrandevelopers/zetasql-snowflake/lib/snowflake -maxdepth 1 -type f ! -name '${{ matrix.zetasql-lib }}' -exec rm -f {} \;
- name: package to vsix file
run: |
npm config set script-shell bash
npx @vscode/vsce package -o ${FILE_NAME} --target ${{ matrix.target }} --githubBranch main
- name: create cache
uses: actions/cache@v4
with:
path: ./${{ env.FILE_NAME }}
key: ${{ env.FILE_NAME }}
enableCrossOsArchive: true
run-e2e-tests:
if: github.actor != 'dependabot[bot]'
needs: test-and-package
strategy:
fail-fast: false
matrix:
include: # Run tests on latest version and version used in https://github.com/fivetran/analytics/blob/main/dbt_ft_prod/dbt_project.yml#L9 (require-dbt-version)
# https://github.com/fivetran/analytics/blob/a83516d1f662ef4db5750e4bff6735b56b823123/.buildkite/scripts/step_2_run_models_dry.sh#L11
- install-dbt: '${PYTHON_INSTALL_LOC} -m pip install dbt-bigquery==1.5.3 dbt-snowflake==1.5.2 dbt-postgres==1.5.4'
os: macos-latest
target: darwin-x64
activate-venv: source ~/dbt_1_2_2_env/bin/activate
python-version: '3.9.12'
- install-dbt: '${PYTHON_INSTALL_LOC} -m pip install dbt-bigquery dbt-snowflake dbt-postgres'
os: macos-latest
target: darwin-x64
activate-venv: source ~/dbt_1_2_2_env/bin/activate
python-version: '3.9.12'
- install-dbt: '${PYTHON_INSTALL_LOC} -m pip install dbt-bigquery dbt-snowflake dbt-postgres'
os: ubuntu-latest
target: linux-x64
prepare-for-tests: |
Xvfb -ac :99 -screen 0 1280x1024x16 &
export DISPLAY=:99
activate-venv: source ~/dbt_1_2_2_env/bin/activate
python-version: '3.10.7'
SKIP_TESTS: 'vscode_commands.spec.js'
- install-dbt: '${PYTHON_INSTALL_LOC} -m pip install dbt-bigquery dbt-snowflake dbt-postgres'
os: windows-latest
target: win32-x64
add-colon-to-key-file-path: |
homedir=c:/${homedir#*c/}
python=${homedir}/dbt_1_2_2_env/Scripts/python
cat <<EOT > ${GITHUB_WORKSPACE}/e2e/projects/special-python-settings/.vscode/settings.json
{
"python.defaultInterpreterPath": "${python}"
}
EOT
activate-venv: |
cd ~/dbt_1_2_2_env/Scripts
. activate
python-version: '3.10.7'
name: e2e-${{ matrix.target }} ${{ matrix.install-dbt }} ${{ matrix.os }} ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
steps:
- name: set environment variable with file name
run: echo "FILE_NAME=${{ github.sha }}-${{ matrix.target }}.vsix" >> $GITHUB_ENV
- name: checkout
uses: actions/checkout@v4
- name: load e2e tests and vsix from cache
uses: actions/cache@v4
id: cache
with:
path: ./${{ env.FILE_NAME }}
key: ${{ env.FILE_NAME }}
enableCrossOsArchive: true
fail-on-cache-miss: true
- name: setup WSL
if: matrix.os == 'windows-latest'
uses: Vampire/setup-wsl@v3
with:
distribution: Ubuntu-20.04
- uses: actions/setup-node@v4
with:
node-version: '19.x'
- name: build tests
run: | # ignore postinstall script and install dependencies for e2e
npm install --ignore-scripts
cd common
npx tsc --sourceMap false --project tsconfig.json
cd ../e2e
npm install
npx tsc --sourceMap false --project tsconfig.json
- uses: actions/setup-python@v5
id: setup-python
with:
python-version: ${{ matrix.python-version }}
- name: add custom python venv
run: | # https://github.com/dbt-labs/dbt-core/issues/4745
${PYTHON_INSTALL_LOC} -m venv ~/dbt_1_2_2_env
ls ~/dbt_1_2_2_env
${{ matrix.activate-venv }}
python -m pip install pytz dbt-core==1.2.2 dbt-bigquery==1.2.0
python -m pip list | grep dbt
dbt --version
env:
PYTHON_INSTALL_LOC: '${{ steps.setup-python.outputs.python-path }}'
- name: prepare profile config
run: |
mkdir -p ~/.dbt/
echo "$BQ_SERVICE_ACCOUNT" > ~/.dbt/bq-test-project.json
echo "$PG_CONNECTION_PARAMS" > ~/.dbt/postgres.json
echo "$SNOWFLAKE_CONNECTION_PARAMS" > ~/.dbt/snowflake.json
user=$(whoami)
homedir=$(eval echo "~${user}")
${{ matrix.add-colon-to-key-file-path }}
KEY_FILE_PATH=${homedir}/.dbt/bq-test-project.json
echo "KEY_FILE_PATH=${KEY_FILE_PATH}" >> $GITHUB_ENV
read project_id < <(echo $(echo ${BQ_SERVICE_ACCOUNT} | jq -r '.project_id'))
dataset="transforms_dbt_default"
read pg_host pg_user pg_password pg_port pg_dbname pg_schema < <(echo $(echo ${PG_CONNECTION_PARAMS} | jq -r '.host, .user, .password, .port, .dbname, .schema'))
echo "POSTGRESQL_PORT=${pg_port}" >> $GITHUB_ENV
read sf_account sf_database sf_password sf_role sf_schema sf_user sf_warehouse < <(echo $(echo ${SNOWFLAKE_CONNECTION_PARAMS} | jq -r '.account, .database, .password, .role, .schema, .username, .warehouse'))
sf_password="${sf_password//[$'\t\r\n']}" # Fix new line issue on Windows
cat <<EOT > ~/.dbt/profiles.yml
e2e-test-project:
target: prod
outputs:
prod:
type: bigquery
method: service-account
project: ${project_id}
keyfile: "{{ env_var('KEY_FILE_PATH') }}"
dataset: ${dataset}
threads: 4
e2e-test-workspace-project1:
target: prod
outputs:
prod:
type: bigquery
method: "{{ env_var('PROJECT1_METHOD') }}" # See .env file in the project root
project: ${project_id}
dataset: ${dataset}
threads: 4
keyfile_json: "{{ env_var('BQ_SERVICE_ACCOUNT') | as_native }}"
e2e-test-workspace-project2:
target: prod
outputs:
prod:
type: bigquery
method: service-account
project: ${project_id}
keyfile: ${KEY_FILE_PATH}
dataset: ${dataset}
threads: 4
e2e-test-project-postgres:
target: prod
outputs:
prod:
type: postgres
host: ${pg_host}
user: ${pg_user}
password: ${pg_password}
port: "{{ env_var('POSTGRESQL_PORT') | as_number }}" # For testing | as_number filter
dbname: ${pg_dbname}
schema: ${pg_schema}
threads: 4
keepalives_idle: 0
connect_timeout: 10
search_path: ${pg_schema}
snowflake:
target: prod
outputs:
prod:
type: snowflake
account: ${sf_account}
database: ${sf_database}
password: '${sf_password}'
role: ${sf_role}
schema: ${sf_schema}
threads: 4
user: ${sf_user}
warehouse: ${sf_warehouse}
EOT
env:
BQ_SERVICE_ACCOUNT: ${{ secrets.BQ_SERVICE_ACCOUNT }}
PG_CONNECTION_PARAMS: ${{ secrets.PG_CONNECTION_PARAMS }}
SNOWFLAKE_CONNECTION_PARAMS: ${{ secrets.SNOWFLAKE_CONNECTION_PARAMS }}
GITHUB_WORKSPACE: ${{ env.GITHUB_WORKSPACE }}
- name: show prepared files
run: |
cd ~/.dbt/
pwd
ls -la
- name: install dbt
run: ${{ matrix.install-dbt }}
env:
PYTHON_INSTALL_LOC: '${{ steps.setup-python.outputs.python-path }}'
- name: show info
run: |
which dbt
dbt --version
node -v
echo ${PYTHON_INSTALL_LOC}
${PYTHON_INSTALL_LOC} --version
${PYTHON_INSTALL_LOC} -m pip --version
${PYTHON_INSTALL_LOC} -m pip list | grep dbt
env:
PYTHON_INSTALL_LOC: '${{ steps.setup-python.outputs.python-path }}'
# Uncomment lines below if you want to connect to the job via SSH
# - name: Setup SSH via tmate for debugging
# uses: rdp-studio/ssh2actions@main
# env:
# TELEGRAM_BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
# TELEGRAM_CHAT_ID: ${{ secrets.CHAT_ID }}
- run: unzip ${{ env.FILE_NAME }} -d e2e-tests
- name: check WSL
shell: powershell
if: matrix.os == 'windows-latest'
run: |
wsl -d Ubuntu ls "/mnt/d/a/dbt-language-server/dbt-language-server/e2e-tests/extension/server/"
- name: run e2e tests
run: |
${{ matrix.prepare-for-tests }}
node e2e/out/runners/runTest $(pwd)/e2e-tests/extension
env:
BQ_SERVICE_ACCOUNT: ${{ secrets.BQ_SERVICE_ACCOUNT }}
SKIP_TESTS: ${{ matrix.SKIP_TESTS }}
PYTHON_INSTALL_LOC: '${{ steps.setup-python.outputs.python-path }}'
WIZARD_FOR_DBT_WSL_UBUNTU_NAME: 'Ubuntu'
- name: show log files
if: always()
run: find .vscode-test/user-data -type f -name *.log
- name: upload logs
if: always()
uses: actions/upload-artifact@v4
with:
name: e2e-${{ matrix.target }} ${{ matrix.install-dbt }} ${{ matrix.os }} ${{ matrix.python-version }}
path: |
.vscode-test/user-data/logs/**/*Wizard for dbt Core (TM).*
.vscode-test/user-data/logs/**/*Wizard for dbt Core (TM) Trace.*
.vscode-test/user-data/logs/**/*Install Latest dbt.*
e2e/projects/completion-jinja/logs/*
e2e/projects/test-fixture/logs/*
e2e/projects/two-projects/logs/*
e2e/projects/without-projects/logs/*
e2e/projects/special-python-settings/logs/*
e2e/projects/postgres/logs/*
e2e/projects/project-with-packages/logs/*
e2e/projects/snowflake/logs/*
publish-vsix:
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') }} # main branch or have any tag started with 'v'
needs: [test-and-package, run-e2e-tests]
runs-on: ubuntu-latest
steps:
- name: load darwin-x64 vsix from cache
id: darwin-x64-cache
uses: actions/cache@v4
with:
path: ./${{ env.VSIX_NAME }}
key: ${{ env.VSIX_NAME }}
enableCrossOsArchive: true
fail-on-cache-miss: true
env:
VSIX_NAME: ${{ github.sha }}-darwin-x64.vsix
- name: load darwin-arm64 vsix from cache
id: darwin-arm64-cache
uses: actions/cache@v4
with:
path: ./${{ env.VSIX_NAME }}
key: ${{ env.VSIX_NAME }}
enableCrossOsArchive: true
fail-on-cache-miss: true
env:
VSIX_NAME: ${{ github.sha }}-darwin-arm64.vsix
- name: load linux-x64 vsix from cache
id: linux-x64-cache
uses: actions/cache@v4
with:
path: ./${{ env.VSIX_NAME }}
key: ${{ env.VSIX_NAME }}
enableCrossOsArchive: true
fail-on-cache-miss: true
env:
VSIX_NAME: ${{ github.sha }}-linux-x64.vsix
- name: load linux-arm64 vsix from cache
id: linux-arm64-cache
uses: actions/cache@v4
with:
path: ./${{ env.VSIX_NAME }}
key: ${{ env.VSIX_NAME }}
enableCrossOsArchive: true
fail-on-cache-miss: true
env:
VSIX_NAME: ${{ github.sha }}-linux-arm64.vsix
- name: load win32-x64 vsix from cache
id: windows-cache
uses: actions/cache@v4
with:
path: ./${{ env.VSIX_NAME }}
key: ${{ env.VSIX_NAME }}
enableCrossOsArchive: true
fail-on-cache-miss: true
env:
VSIX_NAME: ${{ github.sha }}-win32-x64.vsix
- name: 'google auth using service account json'
uses: 'google-github-actions/auth@v2'
with:
credentials_json: '${{ secrets.GCS_SERVICE_ACCOUNT }}'
- name: push vsix files to GCS
if: ${{ github.ref == 'refs/heads/main' }}
uses: google-github-actions/upload-cloud-storage@v2
with:
path: .
glob: '*.vsix'
destination: dbt-language-server
process_gcloudignore: false
- name: set up node
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
uses: actions/setup-node@v4
with:
node-version: '19.x'
- name: publish tagged (latest) extension
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
env:
VSCE_PAT: ${{ secrets.VSCE_TOKEN }}
run: npx @vscode/vsce publish --githubBranch main --packagePath $(find . -iname "*.vsix")
publish-npm:
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
needs: [test-and-package, run-e2e-tests]
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: build and test
run: |
npm install
npm run build
npm run lint
npm run ts-unused-exports
npm run test
- name: set up node
uses: actions/setup-node@v4
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
- name: publish dbt-language-server-common npm package
run: |
cd common
npm publish --verbose
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
- name: publish dbt-language-server npm package
run: |
cd server
npm publish --verbose
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}