-
Notifications
You must be signed in to change notification settings - Fork 1
298 lines (277 loc) · 11.7 KB
/
full-validation.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
name: Full validation
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
permissions:
id-token: write
jobs:
build:
runs-on: ubuntu-latest
environment: staging
env:
PACKAGE_VERSION: 1.0.0-beta.1
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
6.0.x
7.0.x
- name: Pack MySqlConnector Extension
working-directory: ./Batec.Azure.Data.Extensions.MySqlConnector/src
run: dotnet pack -c Release -o ./../../artifacts/
- name: Pack Npgsql Extension
working-directory: ./Batec.Azure.Data.Extensions.Npgsql/src
run: dotnet pack -c Release -o ./../../artifacts/
- name: Restore Solution
run: dotnet restore -s ./artifacts/ -s https://api.nuget.org/v3/index.json Batec.Azure.Data.Extensions.sln
- name: Build
run: dotnet build --no-restore Batec.Azure.Data.Extensions.sln
- name: Azure CLI Login
uses: azure/login@v1
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Test Common
working-directory: ./Batec.Azure.Data.Extensions.Common/tests/
run: dotnet test
tests-mysql:
needs: build
environment: staging
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
6.0.x
7.0.x
- name: Azure CLI Login
uses: azure/login@v1
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
# Install the latest version of the Terraform CLI
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_wrapper: false
# Initialize a new or existing Terraform working directory by creating initial files, loading any remote state, downloading modules, etc.
- name: 'Terraform Init MySql'
working-directory: "./iac/mysql"
env:
ARM_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
ARM_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
ARM_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
run: terraform init
# Terraform Apply
- name: 'Terraform Apply MySql'
id: terraform-apply-mysql
working-directory: "./iac/mysql"
env:
ARM_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
ARM_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
ARM_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
run: terraform apply -auto-approve
- name: Get Terraform output
id: get-terraform-output-mysql
working-directory: "./iac/mysql"
env:
ARM_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
ARM_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
ARM_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
run: |
MYSQL_FQDN=$(terraform output -raw fqdn)
MYSQL_DATABASE=$(terraform output -raw database)
MYSQL_SERVER_ADMIN=$(terraform output -raw aad_admin)
echo "MYSQL_FQDN=${MYSQL_FQDN}" >> $GITHUB_ENV
echo "MYSQL_DATABASE=${MYSQL_DATABASE}" >> $GITHUB_ENV
echo "MYSQL_SERVER_ADMIN=${MYSQL_SERVER_ADMIN}" >> $GITHUB_ENV
continue-on-error: true
- name: Pack MySqlConnector Extension
working-directory: ./Batec.Azure.Data.Extensions.MySqlConnector/src
run: dotnet pack -c Release -o ./../../artifacts/
- name: Pack Npgsql Extension
working-directory: ./Batec.Azure.Data.Extensions.Npgsql/src
run: dotnet pack -c Release -o ./../../artifacts/
- name: Restore Solution
run: dotnet restore -s ./artifacts/ -s https://api.nuget.org/v3/index.json Batec.Azure.Data.Extensions.sln
- name: Build
run: dotnet build --no-restore Batec.Azure.Data.Extensions.sln
- name: Test MySqlConnector
id: test-mysqlconnector
if: steps.get-terraform-output-mysql.outcome == 'success'
working-directory: ./Batec.Azure.Data.Extensions.MySqlConnector/tests/
run: dotnet test
continue-on-error: true
env:
MYSQL_FQDN: ${{ env.MYSQL_FQDN }}
MYSQL_DATABASE: ${{ env.MYSQL_DATABASE }}
MYSQL_SERVER_ADMIN: ${{ env.MYSQL_SERVER_ADMIN }}
- name: Setup EF tools
run: dotnet tool install --global dotnet-ef
continue-on-error: true
- name: Setup MySQL EF connection string
id: setup-mysql-ef-connection-string
working-directory: ./Batec.Azure.Data.Extensions.Pomelo.EntityFrameworkCore/tests/
env:
POSTGRESQL_FQDN: ${{ env.POSTGRESQL_FQDN }}
POSTGRESQL_DATABASE: ${{ env.POSTGRESQL_DATABASE }}
POSTGRESQL_SERVER_ADMIN: ${{ env.POSTGRESQL_SERVER_ADMIN }}
run: |
MYSQL_CONNECTION_STRING="Server=${{ env.MYSQL_FQDN }};Port=3306;User ID=${{ env.MYSQL_SERVER_ADMIN }};Database=${{ env.MYSQL_DATABASE }};SSL Mode=Required;Allow Public Key Retrieval=True;Connection Timeout=30"
echo "{\"ConnectionStrings\":{\"DefaultConnection\":\"${MYSQL_CONNECTION_STRING}\"}}" >appsettings.json
continue-on-error: true
- name: Setup MySQL EF database
id: setup-mysql-ef-database
if: steps.setup-mysql-ef-connection-string.outcome == 'success'
working-directory: ./Batec.Azure.Data.Extensions.Pomelo.EntityFrameworkCore/tests/
run: dotnet ef database update
continue-on-error: true
- name: Test MySqlConnector Entity Framework
id: test-mysqlconnector-ef
if: steps.setup-mysql-ef-database.outcome == 'success'
working-directory: ./Batec.Azure.Data.Extensions.Pomelo.EntityFrameworkCore/tests/
run: dotnet test
continue-on-error: true
env:
MYSQL_FQDN: ${{ env.MYSQL_FQDN }}
MYSQL_DATABASE: ${{ env.MYSQL_DATABASE }}
MYSQL_SERVER_ADMIN: ${{ env.MYSQL_SERVER_ADMIN }}
# Terraform Destroy
- name: Terraform Destroy
if: steps.terraform-apply-mysql.outcome == 'success'
working-directory: "./iac/mysql"
env:
ARM_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
ARM_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
ARM_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
run: terraform destroy -auto-approve
- name: Tests failed
if: steps.test-mysqlconnector.outcome != 'success' || steps.test-mysqlconnector-ef.outcome != 'success'
run: |
echo "Tests failed"
exit 1
tests-postgresql:
needs: build
environment: staging
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Azure CLI Login
uses: azure/login@v1
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
6.0.x
7.0.x
# Install the latest version of the Terraform CLI
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_wrapper: false
# Initialize a new or existing Terraform working directory by creating initial files, loading any remote state, downloading modules, etc.
- name: 'Terraform Init Postgresql'
working-directory: "./iac/postgresql"
env:
ARM_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
ARM_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
ARM_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
run: terraform init
# Terraform Apply
- name: 'Terraform Apply Postgresql'
id: terraform-apply-postgresql
working-directory: "./iac/postgresql"
env:
ARM_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
ARM_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
ARM_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
run: terraform apply -auto-approve
- name: Get Terraform output
working-directory: "./iac/postgresql"
env:
ARM_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
ARM_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
ARM_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
run: |
POSTGRESQL_FQDN=$(terraform output -raw fqdn)
POSTGRESQL_DATABASE=$(terraform output -raw database)
POSTGRESQL_SERVER_ADMIN=$(terraform output -raw aad_admin)
echo "POSTGRESQL_FQDN=${POSTGRESQL_FQDN}" >> $GITHUB_ENV
echo "POSTGRESQL_DATABASE=${POSTGRESQL_DATABASE}" >> $GITHUB_ENV
echo "POSTGRESQL_SERVER_ADMIN=${POSTGRESQL_SERVER_ADMIN}" >> $GITHUB_ENV
continue-on-error: true
- name: Pack MySqlConnector Extension
working-directory: ./Batec.Azure.Data.Extensions.MySqlConnector/src
run: dotnet pack -c Release -o ./../../artifacts/
- name: Pack Npgsql Extension
working-directory: ./Batec.Azure.Data.Extensions.Npgsql/src
run: dotnet pack -c Release -o ./../../artifacts/
- name: Restore Solution
run: dotnet restore -s ./artifacts/ -s https://api.nuget.org/v3/index.json Batec.Azure.Data.Extensions.sln
- name: Build
run: dotnet build --no-restore Batec.Azure.Data.Extensions.sln
- name: Test Npgsql
id: tests-postgresql
working-directory: ./Batec.Azure.Data.Extensions.Npgsql/tests/
run: dotnet test
continue-on-error: true
env:
POSTGRESQL_FQDN: ${{ env.POSTGRESQL_FQDN }}
POSTGRESQL_DATABASE: ${{ env.POSTGRESQL_DATABASE }}
POSTGRESQL_SERVER_ADMIN: ${{ env.POSTGRESQL_SERVER_ADMIN }}
- name: Setup EF tools
run: dotnet tool install --global dotnet-ef
continue-on-error: true
- name: Setup POSTGRESQL EF connection string
id: setup-postgresql-ef-connetion-string
working-directory: ./Batec.Azure.Data.Extensions.Npgsql.EntityFrameworkCore/tests/
env:
POSTGRESQL_FQDN: ${{ env.POSTGRESQL_FQDN }}
POSTGRESQL_DATABASE: ${{ env.POSTGRESQL_DATABASE }}
POSTGRESQL_SERVER_ADMIN: ${{ env.POSTGRESQL_SERVER_ADMIN }}
run: |
POSTGRESQL_CONNECTION_STRING="Server=$POSTGRESQL_FQDN;Port=5432;User ID=$POSTGRESQL_SERVER_ADMIN;Database=$POSTGRESQL_DATABASE;SSL Mode=Require;Trust Server Certificate=true"
echo "{\"ConnectionStrings\":{\"DefaultConnection\":\"${POSTGRESQL_CONNECTION_STRING}\"}}" >appsettings.json
continue-on-error: true
- name: Setup PostgreSQL EF database
id: setup-postgresql-ef-db
if: steps.setup-postgresql-ef-connetion-string.outcome == 'success'
working-directory: ./Batec.Azure.Data.Extensions.Npgsql.EntityFrameworkCore/tests/
run: dotnet ef database update
continue-on-error: true
- name: Test Postgresql Entity Framework
id: tests-postgresql-ef
if: steps.setup-postgresql-ef-db.outcome == 'success'
working-directory: ./Batec.Azure.Data.Extensions.Npgsql.EntityFrameworkCore/tests/
run: dotnet test
continue-on-error: true
env:
POSTGRESQL_FQDN: ${{ env.POSTGRESQL_FQDN }}
POSTGRESQL_DATABASE: ${{ env.POSTGRESQL_DATABASE }}
POSTGRESQL_SERVER_ADMIN: ${{ env.POSTGRESQL_SERVER_ADMIN }}
# Terraform Destroy
- name: Terraform Destroy
if: steps.terraform-apply-postgresql.outcome == 'success'
working-directory: "./iac/postgresql"
env:
ARM_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
ARM_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
ARM_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
run: terraform destroy -auto-approve
- name: Tests failed
if: steps.tests-postgresql.outcome != 'success' || steps.tests-postgresql-ef.outcome != 'success'
run: |
echo "Tests failed"
exit 1