-
Notifications
You must be signed in to change notification settings - Fork 0
507 lines (494 loc) · 25.1 KB
/
policy-integration-tests.yml
File metadata and controls
507 lines (494 loc) · 25.1 KB
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
name: policy-integration-tests
on:
pull_request:
branches: [main]
workflow_dispatch:
inputs:
removeTestResource:
description: "Remove Test Resources"
type: boolean
default: true
testToRun:
description: "Tests To Run (separate with commas ',')"
type: string
default: " "
debug:
description: "Enable debug logging"
type: boolean
default: false
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: false
permissions:
contents: read
env:
ACTIONS_STEP_DEBUG: ${{ inputs.debug }}
# Test directories and config
testDirectory: "tests/policy-integration-tests"
testIgnoreFileName: ".testignore"
testGlobalConfigFilePath: "tests/policy-integration-tests/.shared/policy_integration_test_config.jsonc"
deploymentMaxRetry: "3"
preferredBicepCliVersion: "0.41.2"
preferredTerraformVersion: "latest"
azureLocation: "australiaeast"
# Script paths
testInitiationScriptPath: "scripts/pipelines/policy-integration-tests/pipeline-initiate-policy-integration-tests.ps1"
getTestConfigsScript: "scripts/pipelines/policy-integration-tests/pipeline-get-test-config.ps1"
testBicepDeploymentScriptPath: "scripts/pipelines/policy-integration-tests/pipeline-deploy-policy-test-bicep-template.ps1"
testTFDeploymentDestroyScriptPath: "scripts/pipelines/policy-integration-tests/pipeline-deploy-destroy-policy-test-terraform-template.ps1"
waitPolicyInitialEvalScriptPath: "scripts/pipelines/policy-integration-tests/pipeline-get-policy-assignment-compliance-state.ps1"
complianceScanScriptPath: "scripts/pipelines/policy-integration-tests/pipeline-policy-int-test-compliance-scan.ps1"
testDeploymentParseResultScriptPath: "scripts/pipelines/policy-integration-tests/pipeline-create-pipeline-variables-from-json-file.ps1"
testResourceDeleteScriptPath: "scripts/pipelines/policy-integration-tests/pipeline-delete-policy-test-deployed-resources.ps1"
installPSModuleScriptPath: "scripts/pipelines/pipeline-install-moduleFromRepo.ps1"
installBicepScriptPath: "scripts/pipelines/pipeline-install-bicep.ps1"
jobs:
# ──────────────────────────────────────────
# Initiation – parse global test config file
# ──────────────────────────────────────────
initiation:
name: Tests Initiation
runs-on: ubuntu-latest
outputs:
testBicepTemplateName: ${{ steps.parseConfigFile.outputs.testBicepTemplateName }}
testTerraformDirectoryName: ${{ steps.parseConfigFile.outputs.testTerraformDirectoryName }}
testLocalConfigFileName: ${{ steps.parseConfigFile.outputs.testLocalConfigFileName }}
initialEvalMaximumWaitTime: ${{ steps.parseConfigFile.outputs.initialEvalMaximumWaitTime }}
testBicepDeploymentOutputArtifactPrefix: ${{ steps.parseConfigFile.outputs.testBicepDeploymentOutputArtifactPrefix }}
testTerraformDeploymentOutputArtifactPrefix: ${{ steps.parseConfigFile.outputs.testTerraformDeploymentOutputArtifactPrefix }}
testDeploymentOutputFileName: ${{ steps.parseConfigFile.outputs.testDeploymentOutputFileName }}
testTerraformStateFileName: ${{ steps.parseConfigFile.outputs.testTerraformStateFileName }}
testTerraformEncryptedStateFileName: ${{ steps.parseConfigFile.outputs.testTerraformEncryptedStateFileName }}
testOutputFilePrefix: ${{ steps.parseConfigFile.outputs.testOutputFilePrefix }}
testOutputFormat: ${{ steps.parseConfigFile.outputs.testOutputFormat }}
testScriptName: ${{ steps.parseConfigFile.outputs.testScriptName }}
waitTimeForAppendModifyPoliciesAfterDeployment: ${{ steps.parseConfigFile.outputs.waitTimeForAppendModifyPoliciesAfterDeployment }}
waitTimeForPolicyComplianceStateAfterDeployment: ${{ steps.parseConfigFile.outputs.waitTimeForPolicyComplianceStateAfterDeployment }}
waitTimeForDeployIfNotExistsPoliciesAfterDeployment: ${{ steps.parseConfigFile.outputs.waitTimeForDeployIfNotExistsPoliciesAfterDeployment }}
bicepDeploymentRequired: ${{ steps.parseConfigFile.outputs.bicepDeploymentRequired }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
persist-credentials: false
- name: List Environment Variables
shell: pwsh
run: "Get-ChildItem env:"
- name: Parse Global Test Config File
id: parseConfigFile
shell: pwsh
run: |
./${{ env.testInitiationScriptPath }} `
-testDirectory '${{ env.testDirectory }}' `
-testConfigFilePath '${{ env.testGlobalConfigFilePath }}'
# ──────────────────────────────────────────
# Detect test cases from git diff (PR only)
# ──────────────────────────────────────────
mapTestCases:
name: Detect Test Cases from Git Diff
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
needs: initiation
outputs:
shouldSkipTest: ${{ steps.detectTestCases.outputs.shouldSkipTest }}
requiredTestCases: ${{ steps.detectTestCases.outputs.requiredTestCases }}
runComplianceScan: ${{ steps.detectTestCases.outputs.runComplianceScan }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
persist-credentials: false
- name: Detect Test Cases
id: detectTestCases
uses: ./.github/actions/templates/pol-int-test-detect-test-cases
with:
test-config-file-path: "${{ env.testGlobalConfigFilePath }}"
target-git-branch: "${{ github.base_ref }}"
test-case-dir: "${{ env.testDirectory }}"
# ──────────────────────────────────────────
# Get test configurations
# ──────────────────────────────────────────
getTestConfigs:
name: Get Test Configurations
runs-on: ubuntu-latest
if: >-
always() &&
(needs.mapTestCases.result == 'success' || needs.mapTestCases.result == 'skipped')
needs:
- initiation
- mapTestCases
outputs:
testDelayStartMinutes: ${{ steps.getTestConfigsTask.outputs.testDelayStartMinutes }}
runComplianceScan: ${{ steps.getTestConfigsTask.outputs.runComplianceScan }}
complianceScanSubNames: ${{ steps.getTestConfigsTask.outputs.complianceScanSubNames }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
persist-credentials: false
- name: Get Test Config
id: getTestConfigsTask
shell: pwsh
run: |
./${{ env.getTestConfigsScript }} `
-directory '${{ env.testDirectory }}' `
-ignoreFileName '${{ env.testIgnoreFileName }}' `
-includedDirectory "${{ github.event_name == 'pull_request' && needs.mapTestCases.outputs.requiredTestCases || inputs.testToRun || ' ' }}" `
-policyComplianceStateDelay ${{ needs.initiation.outputs.waitTimeForPolicyComplianceStateAfterDeployment }} `
-appendModifyDelay ${{ needs.initiation.outputs.waitTimeForAppendModifyPoliciesAfterDeployment }} `
-DINEDelay ${{ needs.initiation.outputs.waitTimeForDeployIfNotExistsPoliciesAfterDeployment }} `
-testLocalConfigFileName '${{ needs.initiation.outputs.testLocalConfigFileName }}' `
-testScriptName '${{ needs.initiation.outputs.testScriptName }}' `
-skip ${{ github.event_name == 'pull_request' && needs.mapTestCases.outputs.shouldSkipTest || 'false' }}
# ──────────────────────────────────────────
# Get test case sub directories
# ──────────────────────────────────────────
getTests:
name: Get Test Cases
runs-on: ubuntu-latest
if: >-
always() &&
(needs.mapTestCases.result == 'success' || needs.mapTestCases.result == 'skipped') &&
needs.getTestConfigs.result == 'success'
needs:
- mapTestCases
- getTestConfigs
outputs:
SubDirCount: ${{ steps.getSubDirs.outputs.SubDirCount }}
SubDirectories: ${{ steps.getSubDirs.outputs.SubDirectories }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
persist-credentials: false
- name: Get Sub Directories
id: getSubDirs
uses: ./.github/actions/templates/pol-int-test-get-sub-dir
with:
directory: "${{ env.testDirectory }}"
ignore-file-name: "${{ env.testIgnoreFileName }}"
included-directory: "${{ github.event_name == 'pull_request' && needs.mapTestCases.outputs.requiredTestCases || inputs.testToRun || ' ' }}"
skip: "${{ github.event_name == 'pull_request' && needs.mapTestCases.outputs.shouldSkipTest || 'false' }}"
# ──────────────────────────────────────────
# Deploy test resources (matrix)
# ──────────────────────────────────────────
deployTestResources:
name: "Deploy Resources [${{ matrix.matrixSubDirName }}]"
runs-on: ubuntu-latest
timeout-minutes: 180
if: >-
always() &&
needs.getTests.result == 'success' &&
needs.initiation.result == 'success' &&
needs.getTests.outputs.SubDirCount != '0'
needs:
- getTests
- initiation
env:
AZURE_CREDENTIALS: ${{ secrets.POLICY_DEV_MG_OWNER }}
strategy:
fail-fast: false
matrix:
include: ${{ fromJSON(needs.getTests.outputs.SubDirectories) }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
persist-credentials: false
- name: Azure Login
uses: azure/login@v3
with:
creds: ${{ env.AZURE_CREDENTIALS }}
enable-AzPSSession: true
- name: Install Bicep CLI
shell: pwsh
run: |
./${{ env.installBicepScriptPath }} `
-desiredVersion '${{ env.preferredBicepCliVersion }}'
- name: Install Terraform
uses: hashicorp/setup-terraform@v4
with:
terraform_version: ${{ env.preferredTerraformVersion }}
- name: Wait Initial Policy Evaluation
shell: pwsh
run: |
./${{ env.waitPolicyInitialEvalScriptPath }} `
-configFilePath '${{ matrix.matrixSubDirRelativePath }}/${{ needs.initiation.outputs.testLocalConfigFileName }}' `
-wait 'true' `
-maximumWaitMinutes ${{ needs.initiation.outputs.initialEvalMaximumWaitTime }}
- name: Deploy Test Bicep Template
shell: pwsh
run: |
./${{ env.testBicepDeploymentScriptPath }} `
-BicepFilePath '${{ matrix.matrixSubDirRelativePath }}/${{ needs.initiation.outputs.testBicepTemplateName }}' `
-TestConfigFilePath '${{ matrix.matrixSubDirRelativePath }}/${{ needs.initiation.outputs.testLocalConfigFileName }}' `
-BuildNumber ${{ github.run_number }} `
-maxRetry ${{ env.deploymentMaxRetry }} `
-bicepModuleSubscriptionId '' `
-deploymentResultFilePath '${{ matrix.matrixSubDirFullPath }}/${{ needs.initiation.outputs.testBicepDeploymentOutputArtifactPrefix }}-${{ matrix.matrixSubDirName }}/${{ needs.initiation.outputs.testDeploymentOutputFileName }}'
- name: Publish Bicep Deployment Result Artifact
if: always()
uses: actions/upload-artifact@v7
with:
name: "${{ needs.initiation.outputs.testBicepDeploymentOutputArtifactPrefix }}-${{ matrix.matrixSubDirName }}"
path: "${{ matrix.matrixSubDirFullPath }}/${{ needs.initiation.outputs.testBicepDeploymentOutputArtifactPrefix }}-${{ matrix.matrixSubDirName }}"
- name: Deploy Test Terraform Template
shell: pwsh
run: |
./${{ env.testTFDeploymentDestroyScriptPath }} `
-TestConfigFilePath '${{ matrix.matrixSubDirRelativePath }}/${{ needs.initiation.outputs.testLocalConfigFileName }}' `
-terraformPath '${{ matrix.matrixSubDirRelativePath }}/${{ needs.initiation.outputs.testTerraformDirectoryName }}' `
-tfBackendConfigFileName 'backend-${{ github.run_id }}.tf' `
-tfAction 'apply' `
-tfBackendStateFileDirectory '${{ runner.temp }}/${{ matrix.matrixSubDirName }}-tfstate-${{ github.run_id }}' `
-tfStateFileName '${{ needs.initiation.outputs.testTerraformStateFileName }}' `
-tfEncryptedStateFileName '${{ needs.initiation.outputs.testTerraformEncryptedStateFileName }}' `
-deploymentResultFileName '${{ needs.initiation.outputs.testDeploymentOutputFileName }}' `
-uninitializeTerraform 'true' `
-aesEncryptionKey '${{ secrets.AES_ENCRYPTION_KEY }}' `
-aesIV '${{ secrets.AES_IV }}'
- name: Publish Terraform Deployment Result Artifact
if: always()
uses: actions/upload-artifact@v7
with:
name: "${{ needs.initiation.outputs.testTerraformDeploymentOutputArtifactPrefix }}-${{ matrix.matrixSubDirName }}"
path: "${{ runner.temp }}/${{ matrix.matrixSubDirName }}-tfstate-${{ github.run_id }}"
# ──────────────────────────────────────────
# Run Policy Compliance Scan
# ──────────────────────────────────────────
runPolicyComplianceScan:
name: Run Policy Compliance Scan
runs-on: ubuntu-latest
if: >-
always() &&
needs.deployTestResources.result == 'success' &&
needs.getTests.outputs.SubDirCount != '0'
needs:
- initiation
- getTests
- getTestConfigs
- deployTestResources
env:
AZURE_CREDENTIALS: ${{ secrets.POLICY_DEV_MG_OWNER }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
persist-credentials: false
- name: Azure Login
uses: azure/login@v3
with:
creds: ${{ env.AZURE_CREDENTIALS }}
- name: Initiate Policy Compliance Scan
if: needs.getTestConfigs.outputs.runComplianceScan == 'true'
shell: pwsh
run: |
./${{ env.complianceScanScriptPath }} `
-testGlobalConfigFilePath '${{ env.testGlobalConfigFilePath }}' `
-complianceScanSubNames '${{ needs.getTestConfigs.outputs.complianceScanSubNames }}'
# ──────────────────────────────────────────
# Wait after template deployment for policy
# evaluation to complete
# ──────────────────────────────────────────
delayAfterTemplateDeployment:
name: Wait After Template Deployment
runs-on: ubuntu-latest
if: >-
always() &&
needs.runPolicyComplianceScan.result == 'success' &&
needs.initiation.outputs.bicepDeploymentRequired == 'true' &&
needs.getTests.outputs.SubDirCount != '0'
needs:
- initiation
- getTests
- deployTestResources
- getTestConfigs
- runPolicyComplianceScan
steps:
- name: "Wait ${{ needs.getTestConfigs.outputs.testDelayStartMinutes }} min for initial evaluation"
shell: pwsh
run: |
Write-Output "::group::Waiting ${{ needs.getTestConfigs.outputs.testDelayStartMinutes }} minutes for Initial Policy Evaluation"
$delayMinutes = '${{ needs.getTestConfigs.outputs.testDelayStartMinutes }}'
$now = "$([DateTime]::UtcNow.ToString('u')) UTC"
if ($delayMinutes -match '^\d+$' -and [int]$delayMinutes -gt 0) {
Write-Output "[$now]: Waiting $delayMinutes minutes for policy evaluation..."
Start-Sleep -Seconds ([int]$delayMinutes * 60)
} else {
Write-Output "[$now]: No delay required (value: '$delayMinutes')"
}
Write-Output '::endgroup::'
# ──────────────────────────────────────────
# Execute test cases (matrix)
# ──────────────────────────────────────────
runTests:
name: "Run Tests [${{ matrix.matrixSubDirName }}]"
runs-on: ubuntu-latest
timeout-minutes: 180
if: >-
always() &&
!failure() && !cancelled() &&
needs.getTests.outputs.SubDirCount != '0'
needs:
- getTests
- initiation
- deployTestResources
- delayAfterTemplateDeployment
env:
AZURE_CREDENTIALS: ${{ secrets.POLICY_DEV_MG_OWNER }}
strategy:
fail-fast: false
matrix:
include: ${{ fromJSON(needs.getTests.outputs.SubDirectories) }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
persist-credentials: false
- name: Azure Login
uses: azure/login@v3
with:
creds: ${{ env.AZURE_CREDENTIALS }}
- name: Install AzResourceTest Module
shell: pwsh
run: |
./${{ env.installPSModuleScriptPath }} `
-modules 'AzResourceTest@2.0.3' `
-repoName 'PSGallery' `
-maxRetry 3 `
-allowPrerelease 'false'
- name: Install Bicep CLI
shell: pwsh
run: |
./${{ env.installBicepScriptPath }} `
-desiredVersion '${{ env.preferredBicepCliVersion }}'
- name: Install Terraform
uses: hashicorp/setup-terraform@v4
with:
terraform_version: ${{ env.preferredTerraformVersion }}
- name: Download Bicep Deployment Result Artifact
uses: actions/download-artifact@v8
with:
name: "${{ needs.initiation.outputs.testBicepDeploymentOutputArtifactPrefix }}-${{ matrix.matrixSubDirName }}"
path: "${{ matrix.matrixSubDirFullPath }}/${{ needs.initiation.outputs.testBicepDeploymentOutputArtifactPrefix }}-${{ matrix.matrixSubDirName }}"
- name: Download Terraform Deployment Result Artifact
uses: actions/download-artifact@v8
with:
name: "${{ needs.initiation.outputs.testTerraformDeploymentOutputArtifactPrefix }}-${{ matrix.matrixSubDirName }}"
path: "${{ matrix.matrixSubDirFullPath }}/${{ needs.initiation.outputs.testTerraformDeploymentOutputArtifactPrefix }}-${{ matrix.matrixSubDirName }}"
- name: "Parse Bicep Deployment Result - ${{ matrix.matrixSubDirName }}"
id: parseBicepDeploymentResult
shell: pwsh
run: |
./${{ env.testDeploymentParseResultScriptPath }} `
-jsonFilePath '${{ matrix.matrixSubDirFullPath }}/${{ needs.initiation.outputs.testBicepDeploymentOutputArtifactPrefix }}-${{ matrix.matrixSubDirName }}/${{ needs.initiation.outputs.testDeploymentOutputFileName }}' `
-overallJsonVariableName 'bicepDeploymentResult'
- name: "Parse Terraform Deployment Result - ${{ matrix.matrixSubDirName }}"
id: parseTerraformDeploymentResult
shell: pwsh
run: |
./${{ env.testDeploymentParseResultScriptPath }} `
-jsonFilePath '${{ matrix.matrixSubDirFullPath }}/${{ needs.initiation.outputs.testTerraformDeploymentOutputArtifactPrefix }}-${{ matrix.matrixSubDirName }}/${{ needs.initiation.outputs.testDeploymentOutputFileName }}' `
-overallJsonVariableName 'terraformDeploymentResult'
- name: "Resource Test - ${{ matrix.matrixSubDirName }}"
shell: pwsh
env:
bicepDeploymentResult: ${{ steps.parseBicepDeploymentResult.outputs.bicepDeploymentResult }}
terraformDeploymentResult: ${{ steps.parseTerraformDeploymentResult.outputs.terraformDeploymentResult }}
outputFilePath: "${{ matrix.matrixSubDirRelativePath }}/${{ needs.initiation.outputs.testOutputFilePrefix }}-${{ matrix.matrixSubDirName }}.XML"
outputFormat: ${{ needs.initiation.outputs.testOutputFormat }}
run: |
./${{ matrix.matrixSubDirRelativePath }}/${{ needs.initiation.outputs.testScriptName }}
- name: "Process Test Results - ${{ matrix.matrixSubDirName }}"
if: always()
uses: ./.github/actions/templates/parse-pester-results
with:
test-result-files: "${{ matrix.matrixSubDirRelativePath }}/${{ needs.initiation.outputs.testOutputFilePrefix }}-${{ matrix.matrixSubDirName }}.XML"
test-title: "Policy Integration Test - ${{ matrix.matrixSubDirName }}"
check-name: "Test - ${{ matrix.matrixSubDirName }}"
skip-passed-tests-report: "false"
# ──────────────────────────────────────────
# Remove deployed test resources (matrix)
# ──────────────────────────────────────────
resourceRemoval:
name: "Remove Resources [${{ matrix.matrixSubDirName }}]"
runs-on: ubuntu-latest
timeout-minutes: 60
if: >-
always() && !cancelled() &&
(github.event_name != 'workflow_dispatch' || inputs.removeTestResource) &&
needs.getTests.outputs.SubDirCount != '0'
needs:
- getTests
- initiation
- deployTestResources
- runTests
env:
AZURE_CREDENTIALS: ${{ secrets.POLICY_DEV_MG_OWNER }}
strategy:
fail-fast: false
matrix:
include: ${{ fromJSON(needs.getTests.outputs.SubDirectories) }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
persist-credentials: false
- name: Azure Login
uses: azure/login@v3
with:
creds: ${{ env.AZURE_CREDENTIALS }}
enable-AzPSSession: true
- name: Install Terraform
uses: hashicorp/setup-terraform@v4
with:
terraform_version: ${{ env.preferredTerraformVersion }}
- name: Download Terraform Deployment Result Artifact
uses: actions/download-artifact@v8
with:
name: "${{ needs.initiation.outputs.testTerraformDeploymentOutputArtifactPrefix }}-${{ matrix.matrixSubDirName }}"
path: "${{ runner.temp }}/${{ matrix.matrixSubDirName }}-tfstate-${{ github.run_id }}/${{ needs.initiation.outputs.testTerraformDeploymentOutputArtifactPrefix }}-${{ matrix.matrixSubDirName }}"
- name: Download Bicep Deployment Result Artifact
uses: actions/download-artifact@v8
with:
name: "${{ needs.initiation.outputs.testBicepDeploymentOutputArtifactPrefix }}-${{ matrix.matrixSubDirName }}"
path: "${{ matrix.matrixSubDirFullPath }}/${{ needs.initiation.outputs.testBicepDeploymentOutputArtifactPrefix }}-${{ matrix.matrixSubDirName }}"
- name: "Parse Bicep Deployment Result - ${{ matrix.matrixSubDirName }}"
id: parseBicepDeploymentResult
shell: pwsh
run: |
./${{ env.testDeploymentParseResultScriptPath }} `
-jsonFilePath '${{ matrix.matrixSubDirFullPath }}/${{ needs.initiation.outputs.testBicepDeploymentOutputArtifactPrefix }}-${{ matrix.matrixSubDirName }}/${{ needs.initiation.outputs.testDeploymentOutputFileName }}' `
-overallJsonVariableName 'bicepDeploymentResult'
- name: "Remove Bicep Test Resources - ${{ matrix.matrixSubDirName }}"
if: >-
steps.parseBicepDeploymentResult.outputs.bicepDeploymentId != '' ||
steps.parseBicepDeploymentResult.outputs.bicepRemoveTestResourceGroup == 'True'
shell: pwsh
env:
bicepDeploymentResult: ${{ steps.parseBicepDeploymentResult.outputs.bicepDeploymentResult }}
run: |
$ErrorActionPreference = 'Stop'
./${{ env.testResourceDeleteScriptPath }}
- name: "Remove Test Terraform Resources - ${{ matrix.matrixSubDirName }}"
shell: pwsh
run: |
./${{ env.testTFDeploymentDestroyScriptPath }} `
-TestConfigFilePath '${{ matrix.matrixSubDirRelativePath }}/${{ needs.initiation.outputs.testLocalConfigFileName }}' `
-terraformPath '${{ matrix.matrixSubDirRelativePath }}/${{ needs.initiation.outputs.testTerraformDirectoryName }}' `
-tfBackendConfigFileName 'backend-${{ github.run_id }}.tf' `
-tfAction 'destroy' `
-tfBackendStateFileDirectory '${{ runner.temp }}/${{ matrix.matrixSubDirName }}-tfstate-${{ github.run_id }}/${{ needs.initiation.outputs.testTerraformDeploymentOutputArtifactPrefix }}-${{ matrix.matrixSubDirName }}' `
-tfStateFileName '${{ needs.initiation.outputs.testTerraformStateFileName }}' `
-tfEncryptedStateFileName '${{ needs.initiation.outputs.testTerraformEncryptedStateFileName }}' `
-uninitializeTerraform 'true' `
-aesEncryptionKey '${{ secrets.AES_ENCRYPTION_KEY }}' `
-aesIV '${{ secrets.AES_IV }}'