Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI Environment] Enabled CI environment to handle DeploymentTest (bicep) files for new self-contained dependency approach #1624

Merged
merged 308 commits into from
Aug 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
308 commits
Select commit Hold shift + click to select a range
70a6f1e
added missing address space
AlexanderSehr Jun 29, 2022
bceadac
Fix param ref
AlexanderSehr Jun 29, 2022
261ee47
Further refactoring
AlexanderSehr Jun 29, 2022
c3ba3ed
Update to latest
AlexanderSehr Jun 29, 2022
76b1b96
Update to latest
AlexanderSehr Jun 29, 2022
124bfdd
Fixed deployment ref
AlexanderSehr Jun 29, 2022
510442c
Update to latest
AlexanderSehr Jun 29, 2022
23f13e0
Updated GH piplines + minor improvements
AlexanderSehr Jun 29, 2022
ca75794
Fixed ref
AlexanderSehr Jun 29, 2022
c3c3c8c
another try
AlexanderSehr Jun 29, 2022
b4d5d3c
Another try
AlexanderSehr Jun 29, 2022
467bd16
Fixed GH pipeline
AlexanderSehr Jun 29, 2022
2d536fe
Updated names
AlexanderSehr Jun 29, 2022
b81d4d5
Rename
AlexanderSehr Jun 29, 2022
28224b6
Stardted refactoring the readme function
AlexanderSehr Jun 29, 2022
ee95d1c
Renamed var
AlexanderSehr Jun 29, 2022
6f8504d
Update modules/.global/global.module.tests.ps1
AlexanderSehr Jun 29, 2022
ba05015
Update to latest
AlexanderSehr Jun 29, 2022
4eb3b0b
Merge branch 'users/alsehr/1577_RenameFolder2' of https://github.com/…
AlexanderSehr Jun 29, 2022
0b28416
Merge branch 'main' into users/alsehr/1577_RenameFolder2
AlexanderSehr Jun 29, 2022
1ad3623
Renamed variable
AlexanderSehr Jun 29, 2022
c131584
Further updates
AlexanderSehr Jun 29, 2022
b3c1cf3
Mreged latest base branch
AlexanderSehr Jun 29, 2022
dd75daf
Merged latest main
AlexanderSehr Jun 30, 2022
f3d9f07
Merge branch 'main' into users/alsehr/1583_dependencyVar5
AlexanderSehr Jun 30, 2022
0dca935
[Utilities] Updated ReadMe Utility to handle bicep test files when ge…
AlexanderSehr Jun 30, 2022
161c785
Merge branch 'users/alsehr/1583_dependencyVar5' of https://github.com…
AlexanderSehr Jun 30, 2022
b9434f2
Commenting
AlexanderSehr Jun 30, 2022
445129a
Formatting update
AlexanderSehr Jun 30, 2022
f02cb14
Added order
AlexanderSehr Jun 30, 2022
a0b23c9
Added support for ARM deployment test file
AlexanderSehr Jul 1, 2022
09cf924
Updated handling of ARM-JSON deployment files + updated tests
AlexanderSehr Jul 1, 2022
d07f74f
Update to latest
AlexanderSehr Jul 1, 2022
defae14
Small updates
AlexanderSehr Jul 1, 2022
303f224
Small updates
AlexanderSehr Jul 1, 2022
0b12667
Added documentation
AlexanderSehr Jul 1, 2022
7078e9c
Added docs
AlexanderSehr Jul 2, 2022
f65d18e
Update to latest
AlexanderSehr Jul 3, 2022
77467ff
Merge branch 'main' into users/alsehr/1583_dependencyVar5
AlexanderSehr Jul 4, 2022
7d149f2
Regenerated docs
AlexanderSehr Jul 4, 2022
c6e4cd8
Added config exception
AlexanderSehr Jul 4, 2022
8944fb7
Added config exception
AlexanderSehr Jul 4, 2022
50175bc
Mergef first couple changes from PR 1632
AlexanderSehr Jul 8, 2022
62c94e5
Merged first batch of set-moduleReadMe script updates (not yet compat…
AlexanderSehr Jul 10, 2022
de6068c
Latest draft including bicep to json intermediate format
AlexanderSehr Jul 10, 2022
80e5edb
Further improvements when dealing with classic parameter files
AlexanderSehr Jul 10, 2022
1a56e58
Updated function & tested arm converted test file
AlexanderSehr Jul 10, 2022
cd4dde8
Updated comments
AlexanderSehr Jul 10, 2022
1438e13
Added SQL server example & updated readme robustness
AlexanderSehr Jul 12, 2022
a74a2d6
Added SQL server example & updated readme robustness
AlexanderSehr Jul 12, 2022
f8a23dd
Updated pipeline
AlexanderSehr Jul 13, 2022
56400c5
Merged latest main
AlexanderSehr Jul 13, 2022
567f856
Added additional error handling
AlexanderSehr Jul 13, 2022
710d9f2
Fixed dpeloyment test
AlexanderSehr Jul 13, 2022
36f804e
Updated docs
AlexanderSehr Jul 13, 2022
d47137e
Adjusted publishing
AlexanderSehr Jul 13, 2022
ae7a619
Adjusted var syntax
AlexanderSehr Jul 13, 2022
2b86826
Added initial draft for virtualHub
AlexanderSehr Jul 13, 2022
26377f0
Updated readme
AlexanderSehr Jul 13, 2022
6afb26b
Minor updates
AlexanderSehr Jul 13, 2022
39b987e
Updated readmes
AlexanderSehr Jul 13, 2022
8824790
Merge branch 'main' into users/alsehr/1583_dependencyVar5
AlexanderSehr Jul 14, 2022
2a162f9
Improved robustness
AlexanderSehr Jul 14, 2022
9b0eab2
Merged latest main
AlexanderSehr Jul 14, 2022
f84bede
Renamed folder
AlexanderSehr Jul 14, 2022
f2fee8c
Adjusted output
AlexanderSehr Jul 14, 2022
47c40ce
Removed redundant dependency
AlexanderSehr Jul 14, 2022
26599bd
Merged latest main
AlexanderSehr Jul 15, 2022
274d682
Regenerated docs
AlexanderSehr Jul 15, 2022
e569895
Updated Set-ModuleReadMe with Bicep support & regenerated docs
AlexanderSehr Jul 15, 2022
57e9fb1
Updated Set-ModuleReadMe with Bicep support & regenerated docs
AlexanderSehr Jul 15, 2022
6b06637
Updated comments
AlexanderSehr Jul 15, 2022
30963fa
Updated robustness
AlexanderSehr Jul 15, 2022
c79f4db
Updated robustness
AlexanderSehr Jul 15, 2022
3c1a59f
Updated docs
AlexanderSehr Jul 15, 2022
994ad66
Another update
AlexanderSehr Jul 15, 2022
ece3e5f
Changed casing
AlexanderSehr Jul 15, 2022
593b3ff
Merged latest main
AlexanderSehr Jul 15, 2022
42572e7
Added error handling
AlexanderSehr Jul 15, 2022
629061b
Added error handling
AlexanderSehr Jul 15, 2022
e9b66e1
Merged upstream branch
AlexanderSehr Jul 15, 2022
1acfbc5
Adjusted naming
AlexanderSehr Jul 15, 2022
952bd09
Refactored ADO dependency pipeline
AlexanderSehr Jul 15, 2022
57f0bc6
Refactored ADO dependency pipeline
AlexanderSehr Jul 15, 2022
e4787be
Renamed parameter
AlexanderSehr Jul 15, 2022
210f018
Added var
AlexanderSehr Jul 15, 2022
7e91cfe
Test replace
AlexanderSehr Jul 15, 2022
a952777
Test replace
AlexanderSehr Jul 15, 2022
8887b4b
Test replace
AlexanderSehr Jul 15, 2022
e6f52f4
Test replace
AlexanderSehr Jul 15, 2022
4fc70c2
Test replace
AlexanderSehr Jul 15, 2022
7f36e03
Attempt to parameterize parameter fetch for ADO
AlexanderSehr Jul 15, 2022
ebc3be4
Adjusted references
AlexanderSehr Jul 15, 2022
277f381
Small fix
AlexanderSehr Jul 15, 2022
14a747c
Adjusted references
AlexanderSehr Jul 15, 2022
c4ebef4
Added var
AlexanderSehr Jul 15, 2022
a762d4f
Added parameter file case handling
AlexanderSehr Jul 15, 2022
2d9fa43
Fixed condition
AlexanderSehr Jul 15, 2022
d9c88b2
Fixed ref
AlexanderSehr Jul 15, 2022
5e3fba3
Rename
AlexanderSehr Jul 15, 2022
6dd6b6b
Added copied dependency pipeline template
AlexanderSehr Jul 15, 2022
1d386cb
Simplified pipelines
AlexanderSehr Jul 15, 2022
5adba5c
Minor refactoring
AlexanderSehr Jul 16, 2022
6cd94d1
Removed modulePath param from dependency pipeline
AlexanderSehr Jul 16, 2022
e71a51e
Cleanup
AlexanderSehr Jul 16, 2022
8429eb1
Cleanup
AlexanderSehr Jul 16, 2022
6834615
Updated naming
AlexanderSehr Jul 16, 2022
caa62ea
Merged latest main
AlexanderSehr Jul 18, 2022
1ef763c
Update jobs.validateModuleDeployment.yml
AlexanderSehr Jul 18, 2022
d8a36a1
Cleanup
AlexanderSehr Jul 18, 2022
18b5564
Merge branch 'main' into users/alsehr/1583_dependencyVar5
AlexanderSehr Jul 18, 2022
bf77e4a
Update to latest
AlexanderSehr Jul 21, 2022
e35a707
Restructured folders
AlexanderSehr Jul 21, 2022
86e615e
Updated test to new dependency folder structure
AlexanderSehr Jul 21, 2022
d1cef82
Removed nameprefix from parameter
AlexanderSehr Jul 21, 2022
53c97ce
Merged latest main
AlexanderSehr Jul 21, 2022
c4be1f2
Merged latest main
AlexanderSehr Jul 21, 2022
1e9e50e
Update readmes
AlexanderSehr Jul 21, 2022
bd8f0ad
Merged latest main\
AlexanderSehr Jul 23, 2022
4ee39ef
Resolved conflicts
AlexanderSehr Jul 31, 2022
8526126
Merged latest main
AlexanderSehr Aug 2, 2022
316fa08
Merge branch 'main' into users/alsehr/1583_dependencyVar5
AlexanderSehr Aug 2, 2022
7cf084b
Update to latest
AlexanderSehr Aug 2, 2022
0921714
Merge branch 'main' into users/alsehr/1583_dependencyVar5
AlexanderSehr Aug 5, 2022
10e788a
Update to latest
AlexanderSehr Aug 5, 2022
6ee637a
Changed namePrefix param to token
AlexanderSehr Aug 5, 2022
b203be8
Removed namePrefix param leftovers
AlexanderSehr Aug 5, 2022
907c54e
Changed comments
AlexanderSehr Aug 5, 2022
9a3c580
Adjust case hanlding
AlexanderSehr Aug 5, 2022
6129ff4
Adjusted name prefix handling
AlexanderSehr Aug 5, 2022
69484fc
Merge branch 'main' into users/alsehr/1583_dependencyVar5
AlexanderSehr Aug 6, 2022
da8c3c2
Added output
AlexanderSehr Aug 6, 2022
c65acc8
Update to latest
AlexanderSehr Aug 6, 2022
a8baa8c
Disabled pester
AlexanderSehr Aug 6, 2022
ada3354
Update to latest
AlexanderSehr Aug 6, 2022
0e80d00
Refactored file handling
AlexanderSehr Aug 6, 2022
ee189aa
Fallback
AlexanderSehr Aug 6, 2022
36c2aa9
Update to latest
AlexanderSehr Aug 6, 2022
d880428
Update to latest
AlexanderSehr Aug 6, 2022
4d56ecf
Update to latest
AlexanderSehr Aug 6, 2022
90856b3
Update to latest
AlexanderSehr Aug 6, 2022
15e90fc
Update to latest
AlexanderSehr Aug 6, 2022
45eb854
Update to latest
AlexanderSehr Aug 6, 2022
72bc402
Merged latest main
AlexanderSehr Aug 10, 2022
b5e7bf9
Update to latest
AlexanderSehr Aug 10, 2022
95a872a
Removed namePrefix param
AlexanderSehr Aug 10, 2022
14b2e32
Merged latest main
AlexanderSehr Aug 13, 2022
e579b48
Minor fix
AlexanderSehr Aug 13, 2022
29d5943
Added VM draft
AlexanderSehr Aug 13, 2022
e738423
Improved case handling
AlexanderSehr Aug 14, 2022
a1722bb
Updated readme
AlexanderSehr Aug 14, 2022
8d4867c
Merged latest main
AlexanderSehr Aug 14, 2022
17c9842
Cleanup
AlexanderSehr Aug 14, 2022
71cfd54
Update to latest
AlexanderSehr Aug 14, 2022
612678e
Fixed Pester test
AlexanderSehr Aug 14, 2022
80ac8af
Update to latest
AlexanderSehr Aug 14, 2022
09c4f69
Update to latest
AlexanderSehr Aug 14, 2022
01bccec
Small fix
AlexanderSehr Aug 14, 2022
9f3e575
Another small fix for linux
AlexanderSehr Aug 14, 2022
76e638d
Fixed ref
AlexanderSehr Aug 14, 2022
5a2db3e
Merged latest main
AlexanderSehr Aug 14, 2022
0d490af
Another small fix
AlexanderSehr Aug 14, 2022
d5cf656
Update to latest
AlexanderSehr Aug 14, 2022
8e93d17
Update to latest
AlexanderSehr Aug 14, 2022
6c4bedd
Merge branch 'main' into users/alsehr/1583_dependencyVar5
AlexanderSehr Aug 14, 2022
7e4548b
Update to latest
AlexanderSehr Aug 14, 2022
3556fe7
Merged latest
AlexanderSehr Aug 14, 2022
b3b65cf
Added small upgrade to mgmtgroup removal + cleanup of pipeline
AlexanderSehr Aug 14, 2022
ec55a5f
Update to latest
AlexanderSehr Aug 14, 2022
29f5599
Fixed sa name
AlexanderSehr Aug 14, 2022
3b85c46
Renamed res
AlexanderSehr Aug 14, 2022
b159efc
Updated removal
AlexanderSehr Aug 14, 2022
c15182b
added commment
AlexanderSehr Aug 14, 2022
caec61c
Update to latest
AlexanderSehr Aug 14, 2022
29568c9
Update to latest
AlexanderSehr Aug 14, 2022
53faea2
Adjusted conditions
AlexanderSehr Aug 15, 2022
440abdb
Update to latest
AlexanderSehr Aug 15, 2022
26e3d20
Update to latest
AlexanderSehr Aug 15, 2022
21209fd
Update to latest
AlexanderSehr Aug 15, 2022
89acfe0
Updated ReadMe
AlexanderSehr Aug 15, 2022
395a743
Simplified names & updated readmes
AlexanderSehr Aug 15, 2022
f264661
Renamed RG
AlexanderSehr Aug 15, 2022
9f4e7f1
Fixed VM dependencies
AlexanderSehr Aug 15, 2022
63aa398
Naming update
AlexanderSehr Aug 15, 2022
b1cb94a
Updated VM dependencies
AlexanderSehr Aug 15, 2022
59902ce
Updated docs
AlexanderSehr Aug 15, 2022
9d885e4
Added missing role assignment
AlexanderSehr Aug 15, 2022
583d3eb
Small bracket fix
AlexanderSehr Aug 15, 2022
3f22b33
RoleAssignment fix
AlexanderSehr Aug 15, 2022
64a2906
Further fixes
AlexanderSehr Aug 15, 2022
7650310
Further fixes
AlexanderSehr Aug 15, 2022
05822d8
Further fixes
AlexanderSehr Aug 15, 2022
5387e24
Further fixes
AlexanderSehr Aug 15, 2022
f0c58ed
Sync
AlexanderSehr Aug 15, 2022
93b08b5
Fixed folder ref
AlexanderSehr Aug 15, 2022
7b56ff1
Adjuted lb
AlexanderSehr Aug 15, 2022
99cbe9a
Merged latest main
AlexanderSehr Aug 15, 2022
90299fa
Update to latest
AlexanderSehr Aug 15, 2022
ad7eefc
Update to latest
AlexanderSehr Aug 15, 2022
90a95e6
Update to latest
AlexanderSehr Aug 15, 2022
8572d5f
Added missing pipeline flag
AlexanderSehr Aug 15, 2022
387cc81
Adjusted output
AlexanderSehr Aug 15, 2022
ab804c3
Added docs for new dependencies approach
AlexanderSehr Aug 15, 2022
ca05e1a
Small update
AlexanderSehr Aug 15, 2022
69d781d
Fixed name
AlexanderSehr Aug 15, 2022
e32c236
Update to latest
AlexanderSehr Aug 15, 2022
ade838b
Reenabled param json compatibility
AlexanderSehr Aug 15, 2022
b0fee24
Updated SQL server api
AlexanderSehr Aug 15, 2022
3b65086
Update to latest
AlexanderSehr Aug 15, 2022
3d8aa73
Several fixes
AlexanderSehr Aug 15, 2022
7ee5df6
Update to latest
AlexanderSehr Aug 15, 2022
a5e820b
Update to latest
AlexanderSehr Aug 15, 2022
1f69584
Adjusted cond
AlexanderSehr Aug 15, 2022
de97a2f
Fixed removal
AlexanderSehr Aug 15, 2022
cecc96e
Added key rbac + small renames
AlexanderSehr Aug 16, 2022
263f6fa
small renames
AlexanderSehr Aug 16, 2022
c9f9145
Template fix
AlexanderSehr Aug 16, 2022
32a21e2
Updated cse
AlexanderSehr Aug 16, 2022
ccfac9b
Update naming
AlexanderSehr Aug 16, 2022
a0a74eb
Removed reworked modules from PR
AlexanderSehr Aug 16, 2022
d6b1a66
Update to latest
AlexanderSehr Aug 16, 2022
7305775
Update to latest
AlexanderSehr Aug 16, 2022
690ab39
Update to latest
AlexanderSehr Aug 16, 2022
8b24f84
Small readmeGen fix + improved readability
AlexanderSehr Aug 18, 2022
2ffcd56
Updated AutomationAccount
AlexanderSehr Aug 19, 2022
dddf98b
Small update
AlexanderSehr Aug 19, 2022
0f25876
Update to latest
AlexanderSehr Aug 19, 2022
67ade81
Update to latest
AlexanderSehr Aug 20, 2022
a700c88
Small regex update
AlexanderSehr Aug 20, 2022
159d210
typoe
AlexanderSehr Aug 23, 2022
bef0039
Added missing quote
AlexanderSehr Aug 23, 2022
eee9a27
Update Initialize-DeploymentRemoval.ps1
AlexanderSehr Aug 28, 2022
906cf05
Update Invoke-ResourcePostRemoval.ps1
AlexanderSehr Aug 28, 2022
d8dac1e
Update .azuredevops/pipelineTemplates/jobs.validateModuleDeployment.yml
AlexanderSehr Aug 28, 2022
0e0fd3e
Update .azuredevops/pipelineTemplates/jobs.validateModuleDeployment.yml
AlexanderSehr Aug 28, 2022
eb4e1f6
Update .azuredevops/pipelineTemplates/jobs.validateModuleDeployment.yml
AlexanderSehr Aug 28, 2022
33432be
Update .github/actions/templates/validateModuleDeployment/action.yml
AlexanderSehr Aug 28, 2022
8f9ba64
Update .github/actions/templates/validateModuleDeployment/action.yml
AlexanderSehr Aug 28, 2022
cd421d4
Update modules/.shared/dependencyConstructs/diagnostic.dependencies.b…
AlexanderSehr Aug 28, 2022
7b8c441
Update modules/.shared/dependencyConstructs/diagnostic.dependencies.b…
AlexanderSehr Aug 28, 2022
0a06581
Update modules/.shared/dependencyConstructs/diagnostic.dependencies.b…
AlexanderSehr Aug 28, 2022
8e8e6f6
Update modules/.shared/dependencyConstructs/diagnostic.dependencies.b…
AlexanderSehr Aug 28, 2022
fea76a8
Update modules/.shared/dependencyConstructs/diagnostic.dependencies.b…
AlexanderSehr Aug 28, 2022
2b6732e
Update docs/wiki/The CI environment - Static validation.md
AlexanderSehr Aug 28, 2022
d37aa95
Update docs/wiki/The library - Module design.md
AlexanderSehr Aug 28, 2022
b09c5e7
Update docs/wiki/The library - Module design.md
AlexanderSehr Aug 28, 2022
f220f28
Update to latest
AlexanderSehr Aug 29, 2022
e54f976
Update to latest
AlexanderSehr Aug 29, 2022
d9eb0a9
Update to latest
AlexanderSehr Aug 29, 2022
696bd96
Update to latest
AlexanderSehr Aug 29, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions .azuredevops/pipelineTemplates/jobs.getModuleTestFiles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,20 @@ jobs:
$deploymentTestPaths = Get-ModuleTestFileList @functionInput -Verbose

$testTable = @{}
foreach($deploymentTestPath in $deploymentTestPaths) {
$deploymentTestFileName = Split-Path $deploymentTestPath -Leaf
$testTable[$deploymentTestFileName] = @{
moduleTestFilePath = $deploymentTestPath
}
foreach ($deploymentTestPath in $deploymentTestPaths) {
if((Split-Path (Split-Path $deploymentTestPath) -Leaf) -ne '.test') {
# Using test files in subfolders (e.g. '.test/deploy.test.json')
$deploymentTestFileName = Split-Path (Split-Path $deploymentTestPath -Parent) -Leaf
} else {
# Using parameter files (e.g. '.test/parameters.json')
$deploymentTestFileName = Split-Path $deploymentTestPath -Leaf
}
$testTable[$deploymentTestFileName] += @{
moduleTestFilePath = $deploymentTestPath
}
}

$deploymentTestPathsOutput = $testTable | ConvertTo-Json -Compress

Write-Host ('##vso[task.setVariable variable=moduleTests;isOutput=true]{0}' -f ($testTable | ConvertTo-Json -Compress))
Write-Verbose "Module test files: $deploymentTestPathsOutput" -Verbose
49 changes: 32 additions & 17 deletions .azuredevops/pipelineTemplates/jobs.validateModuleDeployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ jobs:
$moduleTemplateFilePath = Join-Path '$(System.DefaultWorkingDirectory)' '${{ parameters.templateFilePath }}'
$moduleTestFilePath = Join-Path '$(System.DefaultWorkingDirectory)' '$(modulePath)' '$(moduleTestFilePath)'

# Determine possible parameters depending on file type
if ((Split-Path $moduleTemplateFilePath -Extension) -eq '.bicep') {
$moduleTemplateContent = az bicep build --file $moduleTemplateFilePath --stdout | ConvertFrom-Json -AsHashtable
$moduleTemplatePossibleParameters = $moduleTemplateContent.parameters.Keys
Expand All @@ -230,13 +231,18 @@ jobs:

# Building input object
$functionInput = @{
templateFilePath = $moduleTemplateFilePath
parameterFilePath = $moduleTestFilePath
location = $location
resourceGroupName = $resourceGroupName
subscriptionId = $subscriptionId
managementGroupId = $managementGroupId
additionalParameters = @{}
TemplateFilePath = ($moduleTestFilePath -like '*parameters.json') ? $moduleTemplateFilePath : $moduleTestFilePath
Location = $location
ResourceGroupName = $resourceGroupName
SubscriptionId = $subscriptionId
ManagementGroupId = $managementGroupId
AdditionalParameters = @{}
}

# Handle template file
if ($moduleTestFilePath -like '*parameters.json') {
# Original parameter file
$functionInput['parameterFilePath'] = $moduleTestFilePath
}

# Handle additional parameters
Expand Down Expand Up @@ -267,15 +273,16 @@ jobs:
# Load used functions
. (Join-Path '$(System.DefaultWorkingDirectory)' '$(pipelineFunctionsPath)' 'resourceDeployment' 'New-TemplateDeployment.ps1')

# Fetching parameters
$location = '${{ parameters.location }}'
$resourceGroupName = '${{ parameters.resourceGroupName }}'
$subscriptionId = '${{ parameters.subscriptionId }}'
$managementGroupId = '${{ parameters.managementGroupId }}'

$moduleTemplateFilePath = Join-Path '$(System.DefaultWorkingDirectory)' '${{ parameters.templateFilePath }}'

$moduleTestFilePath = Join-Path '$(System.DefaultWorkingDirectory)' '$(modulePath)' '$(moduleTestFilePath)'

# Determine possible parameters depending on file type
if ((Split-Path $moduleTemplateFilePath -Extension) -eq '.bicep') {
$moduleTemplateContent = az bicep build --file $moduleTemplateFilePath --stdout | ConvertFrom-Json -AsHashtable
$moduleTemplatePossibleParameters = $moduleTemplateContent.parameters.Keys
Expand All @@ -289,13 +296,19 @@ jobs:

# Building input object
$functionInput = @{
templateFilePath = $moduleTemplateFilePath
parameterFilePath = $moduleTestFilePath
location = $location
resourceGroupName = $resourceGroupName
subscriptionId = $subscriptionId
managementGroupId = $managementGroupId
additionalParameters = @{}
TemplateFilePath = ($moduleTestFilePath -like '*parameters.json') ? $moduleTemplateFilePath : $moduleTestFilePath
Location = $location
ResourceGroupName = $resourceGroupName
SubscriptionId = $subscriptionId
ManagementGroupId = $managementGroupId
doNotThrow = $true
AdditionalParameters = @{}
}

# Handle template file
if ($moduleTestFilePath -like '*parameters.json') {
# Original paramter file
$functionInput['parameterFilePath'] = $moduleTestFilePath
}

# Handle additional parameters
Expand Down Expand Up @@ -352,9 +365,11 @@ jobs:
. (Join-Path '$(System.DefaultWorkingDirectory)' '$(pipelineFunctionsPath)' 'resourceRemoval' 'Initialize-DeploymentRemoval.ps1')

$functionInput = @{
TemplateFilePath = Join-Path '$(System.DefaultWorkingDirectory)' '${{ parameters.templateFilePath }}'
TemplateFilePath = ('$(moduleTestFilePath)' -like '*parameters.json') ?
(Join-Path '$(System.DefaultWorkingDirectory)' '${{ parameters.templateFilePath }}') :
(Join-Path '$(System.DefaultWorkingDirectory)' '$(modulePath)' '$(moduleTestFilePath)')
ResourceGroupName = '${{ parameters.resourceGroupName }}'
subscriptionId = '${{ parameters.subscriptionId }}'
SubscriptionId = '${{ parameters.subscriptionId }}'
ManagementGroupId = '${{ parameters.managementGroupId }}'
deploymentName = '$(deploymentName)'
Verbose = $true
Expand Down
4 changes: 4 additions & 0 deletions .github/actions/templates/getModuleTestFiles/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,17 @@ runs:
Write-Output '::group::Get parameter files'
# Load used functions
. (Join-Path $env:GITHUB_WORKSPACE 'utilities' 'pipelines' 'sharedScripts' 'Get-ModuleTestFileList.ps1')

$functionInput = @{
ModulePath = Join-Path $env:GITHUB_WORKSPACE '${{ inputs.modulePath }}'
}

Write-Verbose "Invoke task with" -Verbose
Write-Verbose ($functionInput | ConvertTo-Json | Out-String) -Verbose

# Get the list of parameter file paths
$testFilePaths = Get-ModuleTestFileList @functionInput -Verbose

# Output values to be accessed by next jobs
$compressedOutput = $testFilePaths | ConvertTo-Json -Compress
if($compressedOutput -notmatch "\[.*\]") {
Expand Down
121 changes: 86 additions & 35 deletions .github/actions/templates/validateModuleDeployment/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -211,29 +211,57 @@ runs:
# Load used functions
. (Join-Path $env:GITHUB_WORKSPACE 'utilities' 'pipelines' 'resourceDeployment' 'Test-TemplateDeployment.ps1')

# Prepare general parameters
# --------------------------
# Fetching parameters
$location = '${{ inputs.location }}'
$resourceGroupName = '${{ inputs.resourceGroupName }}'
$subscriptionId = '${{ inputs.subscriptionId }}'
$managementGroupId = '${{ inputs.managementGroupId }}'

# Determine template & test file path
if ('${{ inputs.templateFilePath }}' -like '*.test*') {
Write-Verbose 'Using template test file [${{ inputs.templateFilePath }}]' -Verbose
$moduleTestFilePath = Join-Path $env:GITHUB_WORKSPACE '${{ inputs.templateFilePath }}'
$moduleTemplateFilePath = Resolve-Path ('{0}/deploy.*' -f ($moduleTestFilePath | Split-Path | Split-Path | Split-Path))
} else {
Write-Verbose 'Using parameter test file [${{ inputs.parameterFilePath }}]' -Verbose
$moduleTestFilePath = Join-Path $env:GITHUB_WORKSPACE '${{ inputs.parameterFilePath }}'
$moduleTemplateFilePath = Join-Path $env:GITHUB_WORKSPACE '${{ inputs.templateFilePath }}'
}

# Determine possible parameters depending on file type
if ((Split-Path $moduleTemplateFilePath -Extension) -eq '.bicep') {
$moduleTemplateContent = az bicep build --file $moduleTemplateFilePath --stdout | ConvertFrom-Json -AsHashtable
$moduleTemplatePossibleParameters = $moduleTemplateContent.parameters.Keys
} else {
$moduleTemplatePossibleParameters = ((Get-Content $moduleTemplateFilePath -Raw) | ConvertFrom-Json -AsHashtable).parameters.keys
}

# ----------------- #
# Invoke validation #
# ----------------- #
$functionInput = @{
templateFilePath = '${{ inputs.templateFilePath }}'
location = '${{ inputs.location }}'
resourceGroupName = '${{ inputs.resourceGroupName }}'
subscriptionId = '${{ inputs.subscriptionId }}'
managementGroupId = '${{ inputs.managementGroupId }}'
additionalParameters = @{}
TemplateFilePath = ($moduleTestFilePath -like '*parameters.json') ? $moduleTemplateFilePath : $moduleTestFilePath
Location = $location
ResourceGroupName = $resourceGroupName
SubscriptionId = $subscriptionId
ManagementGroupId = $managementGroupId
AdditionalParameters = @{}
}

if(-not [String]::IsNullOrEmpty('${{ inputs.parameterFilePath }}')) {
$functionInput['parameterFilePath'] = Join-Path $env:GITHUB_WORKSPACE '${{ inputs.parameterFilePath }}'
# Handle template file
if ($moduleTestFilePath -like '*parameters.json') {
$functionInput['parameterFilePath'] = $moduleTestFilePath
}

if (-not [System.Convert]::ToBoolean('${{ env.enableDefaultTelemetry }}') -and (Get-Content -Path $functionInput.templateFilePath -Raw) -like '*param enableDefaultTelemetry*') {
if (-not [System.Convert]::ToBoolean('${{ env.enableDefaultTelemetry }}') -and ($moduleTemplatePossibleParameters.Keys -contains 'enableDefaultTelemetry')) {
$functionInput['additionalParameters'] += @{
enableDefaultTelemetry = [System.Convert]::ToBoolean('${{ env.enableDefaultTelemetry }}')
}
}

Write-Verbose "Invoke task with" -Verbose
Write-Verbose 'Invoke task with' -Verbose
Write-Verbose ($functionInput | ConvertTo-Json | Out-String) -Verbose

Test-TemplateDeployment @functionInput -Verbose
Expand All @@ -254,30 +282,55 @@ runs:
# Load used functions
. (Join-Path $env:GITHUB_WORKSPACE 'utilities' 'pipelines' 'resourceDeployment' 'New-TemplateDeployment.ps1')

# Prepare general parameters
# --------------------------
$location = '${{ inputs.location }}'
$resourceGroupName = '${{ inputs.resourceGroupName }}'
$subscriptionId = '${{ inputs.subscriptionId }}'
$managementGroupId = '${{ inputs.managementGroupId }}'

# Determine template & test file path
if ('${{ inputs.templateFilePath }}' -like '*.test*') {
$moduleTestFilePath = Join-Path $env:GITHUB_WORKSPACE '${{ inputs.templateFilePath }}'
$moduleTemplateFilePath = Resolve-Path ('{0}/deploy.*' -f ($moduleTestFilePath | Split-Path | Split-Path | Split-Path))
} else {
$moduleTestFilePath = Join-Path $env:GITHUB_WORKSPACE '${{ inputs.parameterFilePath }}'
$moduleTemplateFilePath = Join-Path $env:GITHUB_WORKSPACE '${{ inputs.templateFilePath }}'
}

# Determine possible parameters depending on file type
if ((Split-Path $moduleTemplateFilePath -Extension) -eq '.bicep') {
$moduleTemplateContent = az bicep build --file $moduleTemplateFilePath --stdout | ConvertFrom-Json -AsHashtable
$moduleTemplatePossibleParameters = $moduleTemplateContent.parameters.Keys
} else {
$moduleTemplatePossibleParameters = ((Get-Content $moduleTemplateFilePath -Raw) | ConvertFrom-Json -AsHashtable).parameters.keys
}

# ----------------- #
# Invoke deployment #
# ----------------- #
$functionInput = @{
templateFilePath = Join-Path $env:GITHUB_WORKSPACE '${{ inputs.templateFilePath }}'
location = '${{ inputs.location }}'
resourceGroupName = '${{ inputs.resourceGroupName }}'
subscriptionId = '${{ inputs.subscriptionId }}'
managementGroupId = '${{ inputs.managementGroupId }}'
doNotThrow = $true
additionalParameters = @{}
TemplateFilePath = ($moduleTestFilePath -like '*parameters.json') ? $moduleTemplateFilePath : $moduleTestFilePath
Location = $location
ResourceGroupName = $resourceGroupName
SubscriptionId = $subscriptionId
ManagementGroupId = $managementGroupId
DoNotThrow = $true
AdditionalParameters = @{}
}

if(-not [String]::IsNullOrEmpty('${{ inputs.parameterFilePath }}')) {
$functionInput['parameterFilePath'] = Join-Path $env:GITHUB_WORKSPACE '${{ inputs.parameterFilePath }}'
# Handle template file
if ($moduleTestFilePath -like '*parameters.json') {
$functionInput['parameterFilePath'] = $moduleTestFilePath
}

if (-not [System.Convert]::ToBoolean('${{ env.enableDefaultTelemetry }}') -and (Get-Content -Path $functionInput.templateFilePath -Raw) -like '*param enableDefaultTelemetry*') {
if (-not [System.Convert]::ToBoolean('${{ env.enableDefaultTelemetry }}') -and ($moduleTemplatePossibleParameters.Keys -contains 'enableDefaultTelemetry')) {
$functionInput['additionalParameters'] += @{
enableDefaultTelemetry = [System.Convert]::ToBoolean('${{ env.enableDefaultTelemetry }}')
}
}

Write-Verbose "Invoke task with" -Verbose
Write-Verbose 'Invoke task with' -Verbose
Write-Verbose ($functionInput | ConvertTo-Json | Out-String) -Verbose

# Invoke deployment
Expand All @@ -287,11 +340,11 @@ runs:
Write-Output ('::set-output name={0}::{1}' -f 'deploymentName', $res.deploymentName)

# Populate further outputs
$deploymentOutputHash=@{}
$deploymentOutputHash = @{}

foreach ($outputKey in $res.deploymentOutput.Keys) {
Write-Output ('::set-output name={0}::{1}' -f $outputKey, $res.deploymentOutput[$outputKey].Value)
$deploymentOutputHash.add($outputKey,$res.deploymentOutput[$outputKey].Value)
$deploymentOutputHash.add($outputKey, $res.deploymentOutput[$outputKey].Value)
}

$deploymentOutput = $deploymentOutputHash | ConvertTo-Json -Compress -Depth 100
Expand Down Expand Up @@ -319,19 +372,17 @@ runs:
# Load used function
. (Join-Path $env:GITHUB_WORKSPACE 'utilities' 'pipelines' 'resourceRemoval' 'Initialize-DeploymentRemoval.ps1')

if (-not [String]::IsNullOrEmpty('${{ steps.deploy_step.outputs.deploymentName }}')) {
$functionInput = @{
DeploymentName = '${{ steps.deploy_step.outputs.deploymentName }}'
TemplateFilePath = Join-Path $env:GITHUB_WORKSPACE '${{ inputs.templateFilePath }}'
ResourceGroupName = '${{ inputs.resourceGroupName }}'
ManagementGroupId = '${{ inputs.managementGroupId }}'
Verbose = $true
}
$functionInput = @{
TemplateFilePath = Join-Path $env:GITHUB_WORKSPACE '${{ inputs.templateFilePath }}'
DeploymentName = '${{ steps.deploy_step.outputs.deploymentName }}'
ResourceGroupName = '${{ inputs.resourceGroupName }}'
ManagementGroupId = '${{ inputs.managementGroupId }}'
Verbose = $true
}

Write-Verbose 'Invoke task with' -Verbose
Write-Verbose ($functionInput | ConvertTo-Json | Out-String) -Verbose
Write-Verbose 'Invoke task with' -Verbose
Write-Verbose ($functionInput | ConvertTo-Json | Out-String) -Verbose

Initialize-DeploymentRemoval @functionInput
}
Initialize-DeploymentRemoval @functionInput

Write-Output '::endgroup::'
8 changes: 4 additions & 4 deletions docs/wiki/Contribution guide - Validate module locally.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Use this script to test a module from your PC locally, without a CI environment. You can use it to run only the static validation (Pester tests), a deployment validation (dryRun) or an actual deployment to Azure. In the latter cases the script also takes care to replace placeholder tokens in the used parameter file for you.
Use this script to test a module from your PC locally, without a CI environment. You can use it to run only the static validation (Pester tests), a deployment validation (dryRun) or an actual deployment to Azure. In the latter cases the script also takes care to replace placeholder tokens in the used module test & template files for you.

---

Expand All @@ -19,14 +19,14 @@ If the switch for Pester tests (`-PesterTest`) is provided the script will
1. Invoke the module test for the provided template file path and run all tests for it.

If the switch for either the validation test (`-ValidationTest`) or deployment test (`-DeploymentTest`) is provided alongside a HashTable for the token replacement (`-ValidateOrDeployParameters`), the script will
1. Either fetch all parameter files of the module's parameter folder (default) or you can specify a single parameter file by leveraging the `parameterFilePath` parameter instead.
1. Create a dictionary to replace all tokens in these parameter files with actual values. This dictionary will consist
1. Either fetch all module test files of the module's `.test` folder (default) or you can specify a single module test file by leveraging the `ModuleTestFilePath` parameter instead.
1. Create a dictionary to replace all tokens in these module test files with actual values. This dictionary will consist
- of the subscriptionID & managementGroupID of the provided `ValidateOrDeployParameters` object,
- add all key-value pairs of the `-AdditionalTokens` object to it,
- and optionally also add all key-value pairs specified in the `settings.yml`, under the 'local tokens settings'.
1. If the `-ValidationTest` parameter was set, it runs a deployment validation using the `Test-TemplateDeployment` script.
1. If the `-DeploymentTest` parameter was set, it runs a deployment using the `New-TemplateDeployment` script (with no retries).
1. As a final step, it rolls the parameter files back to their original state if either the `-ValidationTest` or `-DeploymentTest` parameters were provided.
1. As a final step, it rolls the module test files back to their original state if either the `-ValidationTest` or `-DeploymentTest` parameters were provided.

# How to use it

Expand Down
Loading