-
Notifications
You must be signed in to change notification settings - Fork 437
562 lines (461 loc) · 17.4 KB
/
nodejs.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
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
name: Node CI
on:
push:
branches: [ "master", "alpha", "beta", "*.x" ]
pull_request:
branches: [ "master", "alpha", "beta", "*.x" ]
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
jobs:
lint:
name: Linting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Use Node.js 16
uses: actions/setup-node@v3
with:
node-version: 16
- name: Determine npm cache directory
id: npm-cache
run: |
echo "::set-output name=dir::$(npm config get cache)"
- uses: actions/cache@v3
with:
path: ${{ steps.npm-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- run: npm ci
- run: npm run lint
test:
name: SQL Server Linux / Node.js ${{ matrix.node-version }}
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
matrix:
node-version: [16.x, 18.x, 19.x]
fail-fast: false
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Generate TLS Certificate
run: |
openssl req -x509 -newkey rsa:4096 -nodes -addext "extendedKeyUsage = serverAuth" -subj '/CN=localhost' -keyout ./test/fixtures/mssql.key -out ./test/fixtures/mssql.crt
- name: Start containers
run: |
docker-compose -f "test/docker-compose.linux.yml" up --detach
- name: Set up CI configuration
run: |
mkdir ~/.tedious
echo '{
"config": {
"server": "localhost",
"authentication": {
"type": "default",
"options": {
"userName": "sa",
"password": "yourStrong(!)Password"
}
},
"options": {
"port": 1433,
"database": "master",
"encrypt": true
}
}
}' | jq --arg certificate "$(cat ./test/fixtures/mssql.crt)" '.config.options.cryptoCredentialsDetails.ca |= $certificate' > ~/.tedious/test-connection.json
- name: Upgrade npm
run: npm install -g npm
if: ${{ matrix.node-version == '6.x' }}
- name: Determine npm cache directory
id: npm-cache
run: |
echo "::set-output name=dir::$(npm config get cache)"
- uses: actions/cache@v3
with:
path: ${{ steps.npm-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- run: npm ci
- name: run unit tests
run: npx nyc --reporter=lcov npm run test
- uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: run integration tests (TDS 7.4)
env:
TEDIOUS_TDS_VERSION: 7_4
run: npx nyc --reporter=lcov npm run test-integration
- uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: run integration tests (TDS 7.3B)
env:
TEDIOUS_TDS_VERSION: 7_3_B
run: npx nyc --reporter=lcov npm run test-integration
- uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: run integration tests (TDS 7.3A)
env:
TEDIOUS_TDS_VERSION: 7_3_A
run: npx nyc --reporter=lcov npm run test-integration
- uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: run integration tests (TDS 7.2)
env:
TEDIOUS_TDS_VERSION: 7_2
run: npx nyc --reporter=lcov npm run test-integration
- uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: run integration tests (TDS 7.1)
env:
TEDIOUS_TDS_VERSION: 7_1
run: npx nyc --reporter=lcov npm run test-integration
- uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
test-windows:
name: SQL Server ${{ matrix.mssql-version }} Windows / Node.js ${{ matrix.node-version }}
runs-on: windows-2022
timeout-minutes: 20
strategy:
matrix:
mssql-version: [2016, 2017, 2019, 2022]
node-version: [16.x, 18.x, 19.x]
fail-fast: false
steps:
- name: Install SQL Server ${{ matrix.mssql-version }}
shell: pwsh
run: |
Push-Location C:\temp
$exe_link, $box_link, $update_link, $update_download_link = '', '', '', ''
switch (${{ matrix.mssql-version }}) {
'2022' {
$exe_link = 'https://download.microsoft.com/download/3/8/d/38de7036-2433-4207-8eae-06e247e17b25/SQLServer2022-DEV-x64-ENU.exe'
$box_link = 'https://download.microsoft.com/download/3/8/d/38de7036-2433-4207-8eae-06e247e17b25/SQLServer2022-DEV-x64-ENU.box'
$update_link = 'https://www.microsoft.com/en-us/download/confirmation.aspx?id=105013'
}
'2019' {
$exe_link = 'https://download.microsoft.com/download/8/4/c/84c6c430-e0f5-476d-bf43-eaaa222a72e0/SQLServer2019-DEV-x64-ENU.exe'
$box_link = 'https://download.microsoft.com/download/8/4/c/84c6c430-e0f5-476d-bf43-eaaa222a72e0/SQLServer2019-DEV-x64-ENU.box'
$update_link = 'https://www.microsoft.com/en-us/download/confirmation.aspx?id=100809'
}
'2017' {
$exe_link = 'https://download.microsoft.com/download/E/F/2/EF23C21D-7860-4F05-88CE-39AA114B014B/SQLServer2017-DEV-x64-ENU.exe'
$box_link = 'https://download.microsoft.com/download/E/F/2/EF23C21D-7860-4F05-88CE-39AA114B014B/SQLServer2017-DEV-x64-ENU.box'
$update_link = 'https://www.microsoft.com/en-us/download/confirmation.aspx?id=56128'
}
'2016' {
$exe_link = 'https://download.microsoft.com/download/4/1/A/41AD6EDE-9794-44E3-B3D5-A1AF62CD7A6F/sql16_sp2_dlc/en-us/SQLServer2016SP2-FullSlipstream-DEV-x64-ENU.exe'
$box_link = 'https://download.microsoft.com/download/4/1/A/41AD6EDE-9794-44E3-B3D5-A1AF62CD7A6F/sql16_sp2_dlc/en-us/SQLServer2016SP2-FullSlipstream-DEV-x64-ENU.box'
$update_download_link = 'https://download.microsoft.com/download/a/7/7/a77b5753-8fe7-4804-bfc5-591d9a626c98/SQLServer2016SP3-KB5003279-x64-ENU.exe'
}
default {
Write-Error "Invalid SQL Server version specified: ${{ matrix.mssql-version }}"
Exit 1
}
}
if (${{ matrix.mssql-version }} -ne '2016') {
$dl_links = ((Invoke-WebRequest -Uri $update_link).Links | Where-Object {$_.href -like 'https://download.microsoft.com/*'})
if ($dl_links.count -gt 0) {
$update_download_link = [System.Uri]::new($dl_links[0].href)
} else {
Write-Error "Download link not found"
Exit 1
}
echo $update_download_link
}
Invoke-WebRequest -Uri $update_download_link -Outfile sqlupdate.exe
Invoke-WebRequest -Uri $exe_link -OutFile sqlsetup.exe
Invoke-WebRequest -Uri $box_link -OutFile sqlsetup.box
Start-Process -Wait -FilePath ./sqlsetup.exe -ArgumentList /qs, /x:setup
.\setup\setup.exe /q /ACTION=Install /INSTANCENAME=MSSQLSERVER /FEATURES=SQLEngine /UPDATEENABLED=1 /UpdateSource=C:\temp /SQLSVCACCOUNT='NT SERVICE\MSSQLSERVER' /SQLSYSADMINACCOUNTS='BUILTIN\ADMINISTRATORS' /TCPENABLED=1 /NPENABLED=0 /IACCEPTSQLSERVERLICENSETERMS /SQLCOLLATION=SQL_Latin1_General_CP1_CI_AS /SECURITYMODE=SQL /SAPWD="yourStrong(!)Password"
Pop-Location
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Install dbatools
shell: powershell
run: Install-Module dbatools -Force
- name: Set up TLS Key and Certificate
shell: powershell
run: |
Import-Module dbatools
$certificate = New-SelfSignedCertificate `
-Type SSLServerAuthentication `
-Subject "CN=$env:COMPUTERNAME" -FriendlyName 'SQL Server RSA2048 G1' `
-DnsName "$env:COMPUTERNAME",'localhost.' `
-KeyAlgorithm 'RSA' -KeyLength 2048 -Hash 'SHA256' `
-TextExtension '2.5.29.37={text}1.3.6.1.5.5.7.3.1' `
-NotAfter (Get-Date).AddMonths(36) `
-KeyExportPolicy NonExportable -KeySpec KeyExchange `
-Provider 'Microsoft RSA SChannel Cryptographic Provider' `
-CertStoreLocation Cert:\LocalMachine\My `
$sqlinstance = Find-DbaInstance -ComputerName localhost
$sqlinstance | Set-DbaNetworkCertificate -Thumbprint ($certificate.Thumbprint).ToUpper()
Restart-Service MSSQLSERVER
# Convert UA certificate raw data to Base64
$output = @(
'-----BEGIN CERTIFICATE-----'
[System.Convert]::ToBase64String($certificate.RawData, 1)
'-----END CERTIFICATE-----'
)
# Output PEM file to the path
$output -join "`n" | Out-File -FilePath test\fixtures\mssql.crt -Encoding ascii -NoNewLine
- name: Set up CI configuration
shell: bash
run: |
mkdir ~/.tedious
echo '{
"config": {
"server": "localhost",
"authentication": {
"type": "default",
"options": {
"userName": "sa",
"password": "yourStrong(!)Password"
}
},
"options": {
"port": 1433,
"database": "master",
"trustServerCertificate": true
}
}
}' | jq --arg certificate "$(cat ./test/fixtures/mssql.crt)" '.config.options.cryptoCredentialsDetails.ca |= $certificate' > ~/.tedious/test-connection.json
- name: Upgrade npm
run: npm install -g npm
if: ${{ matrix.node-version == '6.x' }}
- name: Determine npm cache directory
id: npm-cache
run: |
echo "::set-output name=dir::$(npm config get cache)"
- uses: actions/cache@v3
with:
path: ${{ steps.npm-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- run: npm ci
- name: run unit tests
run: npx nyc --reporter=lcov npm run test
- uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: run integration tests (TDS 7.4)
env:
TEDIOUS_TDS_VERSION: 7_4
run: npx nyc --reporter=lcov npm run test-integration
- uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: run integration tests (TDS 7.3B)
env:
TEDIOUS_TDS_VERSION: 7_3_B
run: npx nyc --reporter=lcov npm run test-integration
- uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: run integration tests (TDS 7.3A)
env:
TEDIOUS_TDS_VERSION: 7_3_A
run: npx nyc --reporter=lcov npm run test-integration
- uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: run integration tests (TDS 7.2)
env:
TEDIOUS_TDS_VERSION: 7_2
run: npx nyc --reporter=lcov npm run test-integration
- uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: run integration tests (TDS 7.1)
env:
TEDIOUS_TDS_VERSION: 7_1
run: npx nyc --reporter=lcov npm run test-integration
- uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
azure-sql-auth:
name: Azure SQL Server / Node.js 16.x
runs-on: ubuntu-latest
timeout-minutes: 20
# Only run these tests if we have access to the secrets
if: ${{ github.event_name == 'push' || github.repository == github.event.pull_request.head.repo.full_name }}
steps:
- uses: actions/checkout@v3
- name: Use Node.js 16
uses: actions/setup-node@v3
with:
node-version: 16
- name: Determine npm cache directory
id: npm-cache
run: |
echo "::set-output name=dir::$(npm config get cache)"
- uses: actions/cache@v3
with:
path: ${{ steps.npm-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- run: npm ci
- run: mkdir ~/.tedious
- name: Set up CI configuration (SQL Authentication)
run: |
echo '{
"config": {
"server": "${{ secrets.AZURE_SERVER }}",
"authentication": {
"type": "default",
"options": {
"userName": "${{ secrets.AZURE_USERNAME }}",
"password": "${{ secrets.AZURE_PASSWORD }}"
}
},
"options": {
"port": 1433,
"database": "tedious"
}
}
}' > ~/.tedious/test-connection.json
- name: run integration tests
run: npx nyc --reporter=lcov npm run test-integration
- uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
azure-ad-auth:
name: Azure SQL Server / Node.js 16.x
runs-on: ubuntu-latest
timeout-minutes: 20
# Only run these tests if we have access to the secrets
if: ${{ github.event_name == 'push' || github.repository == github.event.pull_request.head.repo.full_name }}
steps:
- uses: actions/checkout@v3
- name: Use Node.js 16
uses: actions/setup-node@v3
with:
node-version: 16
- name: Determine npm cache directory
id: npm-cache
run: |
echo "::set-output name=dir::$(npm config get cache)"
- uses: actions/cache@v3
with:
path: ${{ steps.npm-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- run: npm ci
- run: mkdir ~/.tedious
- name: Set up CI configuration (AD Authentication)
run: |
echo '{
"config": {
"server": "${{ secrets.AZURE_SERVER }}",
"authentication": {
"type": "azure-active-directory-password",
"options": {
"clientId": "${{ secrets.AZURE_AD_SP_CLIENT_ID }}",
"tenantId": "${{ secrets.AZURE_AD_TENANT_ID }}",
"userName": "${{ secrets.AZURE_AD_USERNAME }}",
"password": "${{ secrets.AZURE_AD_PASSWORD }}"
}
},
"options": {
"port": 1433,
"database": "tedious"
}
}
}' > ~/.tedious/test-connection.json
- name: run integration tests
run: npx nyc --reporter=lcov npm run test-integration
- uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
azure-ad-service-principal-auth:
name: Azure SQL Server / Node.js 16.x
runs-on: ubuntu-latest
timeout-minutes: 20
# Only run these tests if we have access to the secrets
if: ${{ github.event_name == 'push' || github.repository == github.event.pull_request.head.repo.full_name }}
steps:
- uses: actions/checkout@v3
- name: Use Node.js 16
uses: actions/setup-node@v3
with:
node-version: 16
- name: Determine npm cache directory
id: npm-cache
run: |
echo "::set-output name=dir::$(npm config get cache)"
- uses: actions/cache@v3
with:
path: ${{ steps.npm-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- run: npm ci
- run: mkdir ~/.tedious
- name: Set up CI configuration (AD Service Principal Authentication)
run: |
echo '{
"config": {
"server": "${{ secrets.AZURE_SERVER }}",
"authentication": {
"type": "azure-active-directory-service-principal-secret",
"options": {
"clientId": "${{ secrets.AZURE_AD_SP_CLIENT_ID }}",
"tenantId": "${{ secrets.AZURE_AD_SP_TENANT_ID }}",
"clientSecret": "${{ secrets.AZURE_AD_SP_CLIENT_SECRET }}"
}
},
"options": {
"port": 1433,
"database": "tedious"
}
}
}' > ~/.tedious/test-connection.json
- name: run integration tests
run: npx nyc --reporter=lcov npm run test-integration
- uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
pre-release:
name: Pre-Release
needs: [test, test-windows]
if: ${{ github.event_name == 'push' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js 16
uses: actions/setup-node@v3
with:
node-version: 16
- name: Determine npm cache directory
id: npm-cache
run: |
echo "::set-output name=dir::$(npm config get cache)"
- uses: actions/cache@v3
with:
path: ${{ steps.npm-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- run: npm ci
- env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm run semantic-release