Skip to content

Commit

Permalink
Updated diagnostic settings & tests (#200)
Browse files Browse the repository at this point in the history
* Updated all bicep

* Minor fixes + Implemented new-readme script + updated output + outdated 2 example readme

* Added documentation

* Updated empty module handling + minor fixes

* Minor cleanup

* Refreshed all readme's

* Fixed several tests

* Minor fixes

* Cleanup

* Updated tests to work directly with bicep (and not write an ARM file); added more testing capabilities; update endpoint api versions; cleanup

* Updated docs

* Updated repo readme generation to work without identifiers

* Small adjustment

* Updated readme titles & added primary resource

* Enforce UTF8 encoding

* Updated to latest PR + removed 2 redundant arm files + updated ReadMes

* Updated locks

* Updated non converted modules

* Minor update

* Updated logic

* Refreshed templates again

* Minor change

* Renamed parameters

* Renamed parameters

* Updated further script analyzer issues

* Updated output

* Cleanup

* Cleanup dependencies

* Cleanup

* Re-added considerations

* Re-added considerations

* Dummy change

* Minor change

* Update to latest

* cleanup

* Update to latest

* Renamed platform workflows

* Updated API versions

* Fixed remaining tests

Co-authored-by: MrMCake <[email protected]>
  • Loading branch information
AlexanderSehr and MrMCake authored Oct 22, 2021
1 parent df325fb commit 83d32ac
Show file tree
Hide file tree
Showing 237 changed files with 5,402 additions and 9,544 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/ms.eventgrid.topics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:
- name: "Test module"
uses: ./.github/actions/templates/validateModuleDeploy
with:
templateFilePath: '${{ env.modulePath }}/deploy.json'
templateFilePath: '${{ env.modulePath }}/deploy.bicep'
parameterFilePath: '${{ env.modulePath }}/parameters/${{ matrix.parameterFilePaths }}'
location: '${{ env.defaultLocation }}'
resourceGroupName: '${{ env.resourceGroupName }}'
Expand Down Expand Up @@ -116,7 +116,7 @@ jobs:
uses: ./.github/actions/templates/deployModule
with:
moduleName: '${{ env.moduleName }}'
templateFilePath: '${{ env.modulePath }}/deploy.json'
templateFilePath: '${{ env.modulePath }}/deploy.bicep'
parameterFilePath: '${{ env.modulePath }}/parameters/${{ matrix.parameterFilePaths }}'
location: '${{ env.defaultLocation }}'
resourceGroupName: '${{ env.resourceGroupName }}'
Expand Down Expand Up @@ -146,7 +146,7 @@ jobs:
- name: "Publish module"
uses: ./.github/actions/templates/publishModule
with:
templateFilePath: '${{ env.modulePath }}/deploy.json'
templateFilePath: '${{ env.modulePath }}/deploy.bicep'
componentTemplateSpecRGName: '${{ env.componentTemplateSpecRGName }}'
componentTemplateSpecRGLocation: '${{ env.componentTemplateSpecRGLocation }}'
componentTemplateSpecName: '${{ env.moduleName }}'
Expand Down Expand Up @@ -178,5 +178,5 @@ jobs:
uses: ./.github/actions/templates/removeModule
with:
moduleName: '${{ env.moduleName }}'
templateFilePath: '${{ env.modulePath }}/deploy.json'
resourceGroupName: '${{ env.resourceGroupName }}'
templateFilePath: '${{ env.modulePath }}/deploy.bicep'
resourceGroupName: '${{ env.resourceGroupName }}'
10 changes: 5 additions & 5 deletions .github/workflows/ms.keyvault.vaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:
- name: "Test module"
uses: ./.github/actions/templates/validateModuleDeploy
with:
templateFilePath: '${{ env.modulePath }}/deploy.json'
templateFilePath: '${{ env.modulePath }}/deploy.bicep'
parameterFilePath: '${{ env.modulePath }}/parameters/${{ matrix.parameterFilePaths }}'
location: '${{ env.defaultLocation }}'
resourceGroupName: '${{ env.resourceGroupName }}'
Expand Down Expand Up @@ -116,7 +116,7 @@ jobs:
uses: ./.github/actions/templates/deployModule
with:
moduleName: '${{ env.moduleName }}'
templateFilePath: '${{ env.modulePath }}/deploy.json'
templateFilePath: '${{ env.modulePath }}/deploy.bicep'
parameterFilePath: '${{ env.modulePath }}/parameters/${{ matrix.parameterFilePaths }}'
location: '${{ env.defaultLocation }}'
resourceGroupName: '${{ env.resourceGroupName }}'
Expand Down Expand Up @@ -146,7 +146,7 @@ jobs:
- name: "Publish module"
uses: ./.github/actions/templates/publishModule
with:
templateFilePath: '${{ env.modulePath }}/deploy.json'
templateFilePath: '${{ env.modulePath }}/deploy.bicep'
componentTemplateSpecRGName: '${{ env.componentTemplateSpecRGName }}'
componentTemplateSpecRGLocation: '${{ env.componentTemplateSpecRGLocation }}'
componentTemplateSpecName: '${{ env.moduleName }}'
Expand Down Expand Up @@ -178,5 +178,5 @@ jobs:
uses: ./.github/actions/templates/removeModule
with:
moduleName: '${{ env.moduleName }}'
templateFilePath: '${{ env.modulePath }}/deploy.json'
resourceGroupName: '${{ env.resourceGroupName }}'
templateFilePath: '${{ env.modulePath }}/deploy.bicep'
resourceGroupName: '${{ env.resourceGroupName }}'
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,18 @@ jobs:
. "$env:GITHUB_WORKSPACE/.github/workflows/scripts/Set-GitHubReadMeModuleTable.ps1"
$functionInput = @{
modulesPath = Join-Path $env:GITHUB_WORKSPACE 'arm'
filePath = Join-Path $env:GITHUB_WORKSPACE 'README.md'
organization = ($env:GITHUB_REPOSITORY).split('/')[0]
repositoryName = ($env:GITHUB_REPOSITORY).split('/')[1]
columnsInOrder = @('Name', 'TemplateType', 'Status')
sortByColumn = 'Name'
ModulesPath = Join-Path $env:GITHUB_WORKSPACE 'arm'
FilePath = Join-Path $env:GITHUB_WORKSPACE 'README.md'
Organization = ($env:GITHUB_REPOSITORY).split('/')[0]
RepositoryName = ($env:GITHUB_REPOSITORY).split('/')[1]
ColumnsInOrder = @('Name', 'TemplateType', 'Status')
SortByColumn = 'Name'
}
Write-Verbose "Invoke task with" -Verbose
Write-Verbose ($functionInput | ConvertTo-Json | Out-String) -Verbose
Set-GitHubReadMeModuleTable @functionInput
Set-GitHubReadMeModuleTable @functionInput -Verbose
- name: "Update module folder ReadMe"
shell: pwsh
Expand All @@ -54,17 +54,17 @@ jobs:
. "$env:GITHUB_WORKSPACE/.github/workflows/scripts/Set-GitHubReadMeModuleTable.ps1"
$functionInput = @{
modulesPath = Join-Path $env:GITHUB_WORKSPACE 'arm'
filePath = Join-Path $env:GITHUB_WORKSPACE 'arm/README.md'
organization = ($env:GITHUB_REPOSITORY).split('/')[0]
repositoryName = ($env:GITHUB_REPOSITORY).split('/')[1]
columnsInOrder = @('Name', 'ProviderNamespace','ResourceType','TemplateType')
ModulesPath = Join-Path $env:GITHUB_WORKSPACE 'arm'
FilePath = Join-Path $env:GITHUB_WORKSPACE 'arm/README.md'
Organization = ($env:GITHUB_REPOSITORY).split('/')[0]
RepositoryName = ($env:GITHUB_REPOSITORY).split('/')[1]
ColumnsInOrder = @('Name', 'ProviderNamespace','ResourceType','TemplateType')
}
Write-Verbose "Invoke task with" -Verbose
Write-Verbose ($functionInput | ConvertTo-Json | Out-String) -Verbose
Set-GitHubReadMeModuleTable @functionInput
Set-GitHubReadMeModuleTable @functionInput -Verbose
- name: "Push changes"
shell: pwsh
Expand Down
File renamed without changes.
65 changes: 32 additions & 33 deletions .github/workflows/scripts/Set-GitHubReadMeModuleTable.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#region Helper functions

<#
.SYNOPSIS
Update the given ReadMe file with the latest module table
Expand All @@ -9,24 +11,24 @@ Note that the ReadMe file should have the following lines right before & after t
- '<!-- ModuleTableStartMarker -->'
- '<!-- ModuleTableEndMarker -->'
.PARAMETER filePath
.PARAMETER FilePath
Mandatory. The path to the ReadMe file to update
.PARAMETER modulesPath
.PARAMETER ModulesPath
Mandatory. The path to the modules folder to process
.PARAMETER repositoryName
.PARAMETER RepositoryName
Mandatory. The name of the repository the modules are in (required to generate the correct links)
.PARAMETER organization
Mandatory. The name of the organization the modules are in (required to generate the correct links)
.PARAMETER Organization
Mandatory. The name of the Organization the modules are in (required to generate the correct links)
.PARAMETER columnsInOrder
.PARAMETER ColumnsInOrder
Mandatory. The set of columns to add to the table in the order you expect them in the table.
Available are 'Name', 'ProviderNamespace', 'ResourceType', 'TemplateType', 'Deploy' & 'Status'
.EXAMPLE
Set-GitHubReadMeModuleTable -filePath 'C:\readme.md' -modulesPath 'C:\arm' -repositoryName 'ResourceModules' -organization 'Azure' -columnsInOrder @('Name','Status')
Set-GitHubReadMeModuleTable -FilePath 'C:\readme.md' -ModulesPath 'C:\arm' -RepositoryName 'ResourceModules' -Organization 'Azure' -ColumnsInOrder @('Name','Status')
Update the defined table section in the 'readme.md' file with a table that has the columns 'Name' & 'Status'
#>
Expand All @@ -35,52 +37,49 @@ function Set-GitHubReadMeModuleTable {
[CmdletBinding(SupportsShouldProcess)]
param (
[Parameter(Mandatory)]
[string] $filePath,
[string] $FilePath,

[Parameter(Mandatory)]
[string] $modulesPath,
[string] $ModulesPath,

[Parameter(Mandatory)]
[string] $repositoryName,
[string] $RepositoryName,

[Parameter(Mandatory)]
[string] $organization,
[string] $Organization,

[Parameter(Mandatory)]
[ValidateSet('Name', 'ProviderNamespace', 'ResourceType', 'TemplateType', 'Deploy', 'Status')]
[string[]] $columnsInOrder,
[string[]] $ColumnsInOrder,

[Parameter(Mandatory = $false)]
[string] $sortByColumn = 'ProviderNamespace'
[string] $SortByColumn = 'ProviderNamespace'
)

# Load functions
. (Join-Path $PSScriptRoot 'Get-ModulesAsMarkdownTable.ps1')
# Load external functions
. (Join-Path $PSScriptRoot 'helper/Get-ModulesAsMarkdownTable.ps1')
. (Join-Path $PSScriptRoot 'helper/Merge-FileWithNewContent.ps1')

# Logic
$contentArray = Get-Content -Path $filePath
$startIndex = [array]::IndexOf($contentArray, '<!-- ModuleTableStartMarker -->')
$endIndex = [array]::IndexOf($contentArray, '<!-- ModuleTableEndMarker -->')

$startContent = $contentArray[0..$startIndex]
$endContent = $contentArray[$endIndex..$contentArray.Count]
$contentArray = Get-Content -Path $FilePath

$tableStringInputObject = @{
Path = $modulesPath
RepositoryName = $repositoryName
Organization = $organization
ColumnsInOrder = $columnsInOrder
sortByColumn = $sortByColumn
Path = $ModulesPath
RepositoryName = $RepositoryName
Organization = $Organization
ColumnsInOrder = $ColumnsInOrder
SortByColumn = $SortByColumn
}
$tableString = Get-ModulesAsMarkdownTable @tableStringInputObject

$newContent = (($startContent + $tableString + $endContent) | Out-String).TrimEnd()
$newContent = Merge-FileWithNewContent -oldContent $contentArray -newContent $tableString -sectionStartIdentifier '# Available Resource Modules'

Write-Verbose 'New content:'
Write-Verbose '============'
Write-Verbose ($newContent | Out-String)

if ($PSCmdlet.ShouldProcess("File in path [$filePath]", 'Overwrite')) {
Set-Content -Path $filePath -Value $newContent -Force -NoNewline
Write-Verbose "File [$filePath] updated" -Verbose
Write-Verbose 'New content:' -Verbose
Write-Verbose '============' -Verbose
Write-Verbose ($newContent | Out-String) -Verbose
if ($PSCmdlet.ShouldProcess("File in path [$FilePath]", 'Overwrite')) {
Set-Content -Path $FilePath -Value $newContent -Force
Write-Verbose "File [$FilePath] updated" -Verbose
}
}
Loading

0 comments on commit 83d32ac

Please sign in to comment.