-
Notifications
You must be signed in to change notification settings - Fork 0
80 lines (71 loc) · 2.65 KB
/
demoTestsSqlCmd.yaml
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
# Creates and executes the sample tests by running the scripts under sql/UnitTests folder with sqlcmd. Then, deletes the created tests.
name: demoTestsSqlCmd
on:
push:
branches:
- main
- fix/print_table_limit
paths:
- "demo/UnitTests/**"
- ".github/workflows/demoTestsSqlCmd.yaml"
env:
WORKING_DIRECTORY: demo/UnitTests
jobs:
build:
name: Run Demo Sqlcmd Scripts
runs-on: [ubuntu-latest]
continue-on-error: false
steps:
# Checkout repository
- name: Check Out Repository
id: checkout_repository
uses: actions/checkout@v3
# Login to Azure
- name: Azure Login
id: azure_login
uses: azure/login@v1
with:
creds: '{"clientId":"${{ secrets.CLIENT_ID }}","clientSecret":"${{ secrets.CLIENT_SECRET }}","subscriptionId":"${{ secrets.SUBSCRIPTION_ID }}","tenantId":"${{ secrets.TENANT_ID }}"}'
# Generate Azure Active Directory Token
- name: Generate Azure Active Directory Token
id: azure_access_token
run: |
echo "Create Azure Access Token"
ACCESS_TOKEN=$(az account get-access-token --scope "https://database.windows.net/.default" --query "accessToken" -o tsv)
echo "Set secret value"
echo "azureAccessToken=$ACCESS_TOKEN" >> "$GITHUB_OUTPUT"
# Install Sqlserver Module
- name: Install Sqlserver Module
id: install_sqlserver_module
run: |
Install-Module sqlserver -scope CurrentUser -force
working-directory: ${{ env.WORKING_DIRECTORY }}
shell: pwsh
# Create and Execute Sample Tests
- name: Create and Execute Sample Tests
id: create_and_execute_sample_tests
run: |
Invoke-Sqlcmd `
-ServerInstance "${{ secrets.TARGET_SERVER_URI }}" `
-Database "${{ secrets.TARGET_DATABASE_NAME }}" `
-AccessToken "${{ steps.azure_access_token.outputs.azureAccessToken }}" `
-InputFile "SampleTests.sql" `
-Verbose
working-directory: ${{ env.WORKING_DIRECTORY }}
shell: pwsh
# Delete Sample Tests
- name: Delete Sample Tests
id: delete_sample_tests
run: |
Invoke-Sqlcmd `
-ServerInstance "${{ secrets.TARGET_SERVER_URI }}" `
-Database "${{ secrets.TARGET_DATABASE_NAME }}" `
-AccessToken "${{ steps.azure_access_token.outputs.azureAccessToken }}" `
-InputFile "DeleteSampleTests.sql"
working-directory: ${{ env.WORKING_DIRECTORY }}
shell: pwsh
# Log out from Azure
- name: Log out from Azure
id: azure_logout
run: |
az logout