From bef835aaaf6b45df900ea3da8c35a1b274cb24f9 Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Fri, 20 Jan 2023 19:16:17 +0100 Subject: [PATCH 01/15] Updated tests --- .../staticValidation/module.tests.ps1 | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/utilities/pipelines/staticValidation/module.tests.ps1 b/utilities/pipelines/staticValidation/module.tests.ps1 index e512dabf78..8fcbee615d 100644 --- a/utilities/pipelines/staticValidation/module.tests.ps1 +++ b/utilities/pipelines/staticValidation/module.tests.ps1 @@ -37,7 +37,7 @@ $script:templateNotFoundException = 'No template file found in folder [{0}]' # - # Import any helper function used in this test script Import-Module (Join-Path $PSScriptRoot 'helper' 'helper.psm1') -Force -Describe 'File/folder tests' -Tag Modules { +Describe 'File/folder tests' -Tag 'Modules' { Context 'General module folder tests' { @@ -80,7 +80,7 @@ Describe 'File/folder tests' -Tag Modules { } } - It '[] Module should contain a [deploy.json/deploy.bicep] file' -TestCases $moduleFolderTestCases { + It '[] Module should contain a [`deploy.json`/`deploy.bicep`] file' -TestCases $moduleFolderTestCases { param( [string] $moduleFolderPath ) @@ -89,19 +89,19 @@ Describe 'File/folder tests' -Tag Modules { ($hasARM -or $hasBicep) | Should -Be $true } - It '[] Module should contain a [readme.md] file' -TestCases $moduleFolderTestCases { + It '[] Module should contain a [`readme.md`] file' -TestCases $moduleFolderTestCases { param( [string] $moduleFolderPath ) (Test-Path (Join-Path -Path $moduleFolderPath 'readme.md')) | Should -Be $true } - It '[] Module should contain a [.test] folder' -TestCases ($moduleFolderTestCases | Where-Object { $_.isTopLevelModule }) { + It '[] Module should contain a [`.test`] folder' -TestCases ($moduleFolderTestCases | Where-Object { $_.isTopLevelModule }) { param( [string] $moduleFolderPath ) Test-Path (Join-Path -Path $moduleFolderPath '.test') | Should -Be $true } - It '[] Module should contain a [version.json] file' -TestCases $moduleFolderTestCases { + It '[] Module should contain a [`version.json`] file' -TestCases $moduleFolderTestCases { param( [string] $moduleFolderPath ) (Test-Path (Join-Path -Path $moduleFolderPath 'version.json')) | Should -Be $true @@ -120,7 +120,7 @@ Describe 'File/folder tests' -Tag Modules { } } - It '[] folder should contain one or more test files' -TestCases $folderTestCases { + It '[] Folder should contain one or more test files' -TestCases $folderTestCases { param( [string] $moduleFolderName, @@ -144,7 +144,7 @@ Describe 'File/folder tests' -Tag Modules { } } - It '[] JSON test files in the .test folder should be valid json' -TestCases $testFolderFilesTestCases { + It '[] JSON test files in the `.test` folder should be valid json' -TestCases $testFolderFilesTestCases { param( [string] $moduleFolderName, @@ -158,7 +158,7 @@ Describe 'File/folder tests' -Tag Modules { } } } -Describe 'Readme tests' -Tag Readme { +Describe 'Readme tests' -Tag 'Readme' { Context 'Readme content tests' { @@ -209,7 +209,7 @@ Describe 'Readme tests' -Tag Readme { } } - It '[] Readme.md file should not be empty' -TestCases $readmeFolderTestCases { + It '[] `Readme.md` file should not be empty' -TestCases $readmeFolderTestCases { param( [string] $moduleFolderName, @@ -218,7 +218,7 @@ Describe 'Readme tests' -Tag Readme { $readMeContent | Should -Not -Be $null } - It '[] Readme.md file should contain these sections in order: Navigation, Resource Types, Parameters, Outputs, Cross-referenced modules, Deployment examples' -TestCases $readmeFolderTestCases { + It '[] `Readme.md` file should contain these sections in order: Navigation, Resource Types, Parameters, Outputs, Cross-referenced modules, Deployment examples' -TestCases $readmeFolderTestCases { param( [string] $moduleFolderName, @@ -316,7 +316,7 @@ Describe 'Readme tests' -Tag Readme { $actualParamCategories | Should -Be $expectedParamCategoriesInOrder } - It '[] parameter tables should provide columns in the following order: Parameter Name, Type, Default Value, Allowed Values, Description. Each column should be present unless empty for all the rows.' -TestCases $readmeFolderTestCases { + It '[] Parameter tables should provide columns in the following order: Parameter Name, Type, Default Value, Allowed Values, Description. Each column should be present unless empty for all the rows.' -TestCases $readmeFolderTestCases { param( [string] $moduleFolderName, @@ -505,7 +505,7 @@ Describe 'Readme tests' -Tag Readme { } } - It '[] Set-ModuleReadMe script should not apply any updates' -TestCases $readmeFolderTestCases { + It '[] `Set-ModuleReadMe` script should not apply any updates' -TestCases $readmeFolderTestCases { param( [string] $moduleFolderName, @@ -540,7 +540,7 @@ Describe 'Readme tests' -Tag Readme { } } -Describe 'Parameter file tests' -Tag 'Parameter' { +Describe 'Deployment test file tests' -Tag 'TestTemplate' { Context 'Deployment test file tests' { @@ -570,7 +570,7 @@ Describe 'Parameter file tests' -Tag 'Parameter' { } } - It "[] Bicep test deployment files should invoke test like [module testDeployment '../.*deploy.bicep' = {]" -TestCases ($deploymentTestFileTestCases | Where-Object { (Split-Path $_.testFilePath -Extension) -eq '.bicep' }) { + It "[] Bicep test deployment files should invoke test like [`module testDeployment '../.*deploy.bicep' = {`]" -TestCases ($deploymentTestFileTestCases | Where-Object { (Split-Path $_.testFilePath -Extension) -eq '.bicep' }) { param( [object[]] $testFileContent @@ -581,7 +581,7 @@ Describe 'Parameter file tests' -Tag 'Parameter' { $testIndex -ne -1 | Should -Be $true -Because 'the module test invocation should be in the expected format to allow identification.' } - It '[] Bicep test deployment name should contain [-test-]' -TestCases ($deploymentTestFileTestCases | Where-Object { (Split-Path $_.testFilePath -Extension) -eq '.bicep' }) { + It '[] Bicep test deployment name should contain [`-test-`]' -TestCases ($deploymentTestFileTestCases | Where-Object { (Split-Path $_.testFilePath -Extension) -eq '.bicep' }) { param( [object[]] $testFileContent @@ -592,7 +592,7 @@ Describe 'Parameter file tests' -Tag 'Parameter' { $expectedNameFormat | Should -Be $true -Because 'the handle ''-test-'' should be part of the module test invocation''s resource name to allow identification.' } - It '[] Bicep test deployment should have parameter [serviceShort]' -TestCases ($deploymentTestFileTestCases | Where-Object { (Split-Path $_.testFilePath -Extension) -eq '.bicep' }) { + It '[] Bicep test deployment should have parameter [`serviceShort`]' -TestCases ($deploymentTestFileTestCases | Where-Object { (Split-Path $_.testFilePath -Extension) -eq '.bicep' }) { param( [object[]] $testFileContent @@ -603,7 +603,7 @@ Describe 'Parameter file tests' -Tag 'Parameter' { $hasExpectedParam | Should -Be $true } - It '[] JSON test deployment name should contain [-test-]' -TestCases ($deploymentTestFileTestCases | Where-Object { (Split-Path $_.testFilePath -Extension) -eq '.json' }) { + It '[] JSON test deployment name should contain [`-test-`]' -TestCases ($deploymentTestFileTestCases | Where-Object { (Split-Path $_.testFilePath -Extension) -eq '.json' }) { param( [object[]] $testFileContent @@ -618,7 +618,7 @@ Describe 'Parameter file tests' -Tag 'Parameter' { $testResource | Should -Not -BeNullOrEmpty -Because 'the handle ''-test-'' should be part of the module test invocation''s resource name to allow identification.' } - It '[] JSON test deployment should have parameter [serviceShort]' -TestCases ($deploymentTestFileTestCases | Where-Object { (Split-Path $_.testFilePath -Extension) -eq '.json' }) { + It '[] JSON test deployment should have parameter [`serviceShort`]' -TestCases ($deploymentTestFileTestCases | Where-Object { (Split-Path $_.testFilePath -Extension) -eq '.json' }) { param( [object[]] $testFileContent @@ -672,7 +672,7 @@ Describe 'Parameter file tests' -Tag 'Parameter' { } } -Describe 'Deployment template tests' -Tag Template { +Describe 'Deployment template tests' -Tag 'Template' { Context 'Deployment template tests' { @@ -755,7 +755,7 @@ Describe 'Deployment template tests' -Tag Template { } } - It '[] the template file should not be empty' -TestCases $deploymentFolderTestCases { + It '[] The template file should not be empty' -TestCases $deploymentFolderTestCases { param( [string] $moduleFolderName, @@ -824,7 +824,7 @@ Describe 'Deployment template tests' -Tag Template { $ApiVersionArray | Should -Not -Contain $false } - It '[] the template file should contain required elements: schema, contentVersion, resources' -TestCases $deploymentFolderTestCases { + It '[] The template file should contain required elements: `schema`, `contentVersion`, `resources`' -TestCases $deploymentFolderTestCases { param( [string] $moduleFolderName, @@ -835,7 +835,7 @@ Describe 'Deployment template tests' -Tag Template { $templateContent.Keys | Should -Contain 'resources' } - It '[] If delete lock is implemented, the template should have a lock parameter with the default value of ['''']' -TestCases $deploymentFolderTestCases { + It '[] If delete lock is implemented, the template should have a lock parameter with an empty default value' -TestCases $deploymentFolderTestCases { param( [string] $moduleFolderName, @@ -933,7 +933,7 @@ Describe 'Deployment template tests' -Tag Template { $enableDefaultTelemetryFlag | Should -Not -Contain $false } - It "[] The Location should be defined as a parameter, with the default value of 'resourceGroup().Location' or global for ResourceGroup deployment scope" -TestCases $deploymentFolderTestCases { + It "[] The Location should be defined as a parameter, with the default value of '`resourceGroup().Location`' or global for ResourceGroup deployment scope" -TestCases $deploymentFolderTestCases { param( [string] $moduleFolderName, @@ -1034,7 +1034,7 @@ Describe 'Deployment template tests' -Tag Template { $outputs | Should -Contain 'resourceId' } - It "[] parameters' description should start with a one word category starting with a capital letter, followed by a dot, a space and the actual description text ending with a dot." -TestCases $deploymentFolderTestCases { + It "[] Each parameters' description should start with a one word category starting with a capital letter, followed by a dot, a space and the actual description text ending with a dot." -TestCases $deploymentFolderTestCases { param( [string] $moduleFolderName, @@ -1108,7 +1108,7 @@ Describe 'Deployment template tests' -Tag Template { } # PARAMETER Tests - It '[] All parameters in parameters files exist in template file (deploy.json)' -TestCases $deploymentFolderTestCases { + It '[] All parameters in parameters files exist in template file (`deploy.json`)' -TestCases $deploymentFolderTestCases { param ( [hashtable[]] $testFileTestCases ) @@ -1122,7 +1122,7 @@ Describe 'Deployment template tests' -Tag Template { } } - It '[] All required parameters in template file (deploy.json) should exist in parameters files' -TestCases $deploymentFolderTestCases { + It '[] All required parameters in template file (`deploy.json`) should exist in parameters files' -TestCases $deploymentFolderTestCases { param ( [hashtable[]] $testFileTestCases ) From 2d45c1289571ee24df8b247fd390ca8a49233afa Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Fri, 20 Jan 2023 19:34:02 +0100 Subject: [PATCH 02/15] Updated tests & removed redundancy --- .../staticValidation/module.tests.ps1 | 56 ++----------------- 1 file changed, 6 insertions(+), 50 deletions(-) diff --git a/utilities/pipelines/staticValidation/module.tests.ps1 b/utilities/pipelines/staticValidation/module.tests.ps1 index 8fcbee615d..28f9f8e005 100644 --- a/utilities/pipelines/staticValidation/module.tests.ps1 +++ b/utilities/pipelines/staticValidation/module.tests.ps1 @@ -540,9 +540,9 @@ Describe 'Readme tests' -Tag 'Readme' { } } -Describe 'Deployment test file tests' -Tag 'TestTemplate' { +Describe 'Test file tests' -Tag 'TestTemplate' { - Context 'Deployment test file tests' { + Context 'General test file' { $deploymentTestFileTestCases = @() @@ -629,7 +629,7 @@ Describe 'Deployment test file tests' -Tag 'TestTemplate' { } } - Context 'Parameter file token tests' { + Context 'Token usage' { # Parameter file test cases $parameterFileTokenTestCases = @() @@ -652,7 +652,7 @@ Describe 'Deployment test file tests' -Tag 'TestTemplate' { } } - It '[] [Tokens] Parameter file [] should not contain the plain value for token [] guid' -TestCases $parameterFileTokenTestCases { + It '[] [Tokens] Test file [] should not contain the plain value for token [] guid' -TestCases $parameterFileTokenTestCases { param ( [string] $testFilePath, [string] $parameterFileName, @@ -674,7 +674,7 @@ Describe 'Deployment test file tests' -Tag 'TestTemplate' { Describe 'Deployment template tests' -Tag 'Template' { - Context 'Deployment template tests' { + Context 'General template' { $deploymentFolderTestCases = [System.Collections.ArrayList] @() foreach ($moduleFolderPath in $moduleFolderPaths) { @@ -1152,53 +1152,9 @@ Describe 'Deployment template tests' -Tag 'Template' { } } } - - Context 'Parameter file token tests' { - - # Parameter file test cases - $parameterFileTokenTestCases = @() - - foreach ($moduleFolderPath in $moduleFolderPaths) { - if (Test-Path (Join-Path $moduleFolderPath '.test')) { - $TestFilePaths = (Get-ChildItem (Join-Path -Path $moduleFolderPath -ChildPath '.test') -Recurse -File -Force).FullName - foreach ($TestFilePath in $TestFilePaths) { - foreach ($token in $tokenConfiguration.Tokens.Keys) { - $parameterFileTokenTestCases += @{ - parameterFilePath = $TestFilePath - parameterFileName = Split-Path $TestFilePath -Leaf - tokenPrefix = $tokenConfiguration.TokenPrefix - tokenSuffix = $tokenConfiguration.TokenSuffix - tokenName = $token - tokenValue = $tokenConfiguration.Tokens[$token] - moduleFolderName = $moduleFolderPath.Replace('\', '/').Split('/modules/')[1] - } - } - } - } - } - - It '[] [Tokens] Parameter file [] should not contain the plain value for token []' -TestCases $parameterFileTokenTestCases { - param ( - [string] $parameterFilePath, - [string] $parameterFileName, - [string] $tokenPrefix, - [string] $tokenSuffix, - [string] $tokenName, - [string] $tokenValue, - [string] $moduleFolderName - ) - $ParameterFileTokenName = -join ($tokenPrefix, $tokenName, $tokenSuffix) - $ParameterFileContent = Get-Content -Path $parameterFilePath - - $incorrectReferencesFound = $ParameterFileContent | Select-String -Pattern $tokenValue -AllMatches - if ($incorrectReferencesFound.Matches) { - $incorrectReferencesFound.Matches.Count | Should -Be 0 -Because ('Parameter file should not contain the [{0}] value, instead should reference the token value [{1}]. Please check the {2} lines: [{3}]' -f $tokenName, $ParameterFileTokenName, $incorrectReferencesFound.Matches.Count, ($incorrectReferencesFound.Line.Trim() -join ",`n")) - } - } - } } -Describe "API version tests [All apiVersions in the template should be 'recent']" -Tag ApiCheck { +Describe 'API version tests' -Tag ApiCheck { $testCases = @() $apiSpecsFilePath = Join-Path $repoRootPath 'utilities' 'src' 'apiSpecsList.json' From 61b42d950cb5edc4c1b2343e34c7f7900395e682 Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Fri, 20 Jan 2023 20:21:57 +0100 Subject: [PATCH 03/15] Added platform pipelines to keep the static test documentation automatically up to date --- .../platform.updateStaticTestDocs.yml | 67 ++++++++++++ .../platform.updateStaticTestDocs.yml | 59 ++++++++++ .../platform/Set-StaticTestDocumentation.ps1 | 103 ++++++++++++++++++ 3 files changed, 229 insertions(+) create mode 100644 .azuredevops/platformPipelines/platform.updateStaticTestDocs.yml create mode 100644 .github/workflows/platform.updateStaticTestDocs.yml create mode 100644 utilities/tools/platform/Set-StaticTestDocumentation.ps1 diff --git a/.azuredevops/platformPipelines/platform.updateStaticTestDocs.yml b/.azuredevops/platformPipelines/platform.updateStaticTestDocs.yml new file mode 100644 index 0000000000..9c406b5f4c --- /dev/null +++ b/.azuredevops/platformPipelines/platform.updateStaticTestDocs.yml @@ -0,0 +1,67 @@ +name: ".Platform - Update Pester Test Documentation" + +pr: none + +trigger: + batch: true + branches: + include: + - main + paths: + include: + - 'utilities/pipelines/staticValidation/module.tests.ps1' + +variables: + - template: "../../settings.yml" + - name: pipelinePrincipalGitUserName + value: "CARMLPipelinePrincipal" + - name: pipelinePrincipalGitUserEmail + value: "CARML@noreply.github.com" + +jobs: + - job: Update_Static_Test_Docs + pool: + ${{ if ne(variables.vmImage, '') }}: + vmImage: ${{ variables.vmImage }} + ${{ if ne(variables.poolName, '') }}: + name: ${{ variables.poolName }} + steps: + - checkout: self + persistCredentials: true + + - task: AzurePowerShell@5 + displayName: "Update file" + inputs: + azureSubscription: "$(serviceConnection)" + azurePowerShellVersion: "latestVersion" + preferredAzurePowerShellVersion: "" + pwsh: true + ScriptType: InlineScript + inline: | + # Load used functions + . (Join-Path '$(System.DefaultWorkingDirectory)' 'utilities' 'tools' 'platform' 'Set-StaticTestDocumentation.ps1') + + $functionInput = @{ + TestFilePath = Join-Path '$(System.DefaultWorkingDirectory)' 'utilities' 'pipelines' 'staticValidation' 'module.tests.ps1' + WikiFilePath = Join-Path '$(System.DefaultWorkingDirectory)' 'docs' 'wiki' 'The CI environment - Static validation.md' + } + + Write-Verbose "Invoke task with" -Verbose + Write-Verbose ($functionInput | ConvertTo-Json | Out-String) -Verbose + + Set-StaticTestDocumentation @functionInput -Verbose + + - task: PowerShell@2 + displayName: "Push changes" + inputs: + targetType: inline + pwsh: true + script: | + git config --global user.email '$(pipelinePrincipalGitUserEmail)' + git config --global user.name '$(pipelinePrincipalGitUserName)' + + git add . + git status + git commit -m 'Push updated API Specs file' + git pull $(Build.Repository.Uri) HEAD:$(Build.SourceBranch) + git push $(Build.Repository.Uri) HEAD:$(Build.SourceBranch) diff --git a/.github/workflows/platform.updateStaticTestDocs.yml b/.github/workflows/platform.updateStaticTestDocs.yml new file mode 100644 index 0000000000..128e052ab3 --- /dev/null +++ b/.github/workflows/platform.updateStaticTestDocs.yml @@ -0,0 +1,59 @@ +name: ".Platform: Update Pester Test Documentation" + +on: + workflow_dispatch: + push: + # branches: + # - main + # paths: + # - 'utilities/pipelines/staticValidation/module.tests.ps1' + +env: + pipelinePrincipalGitUserName: "CARMLPipelinePrincipal" + pipelinePrincipalGitUserEmail: "CARML@noreply.github.com" + +jobs: + job_update_static_test_docs: + name: "Update file" + if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' + runs-on: ubuntu-20.04 + steps: + - name: "Checkout" + uses: actions/checkout@v3 + with: + fetch-depth: 0 + token: "${{ secrets.PLATFORM_REPO_UPDATE_PAT }}" # Sets general GIT credentials up + + - name: Azure Login + uses: Azure/login@v1 + with: + creds: ${{ secrets.AZURE_CREDENTIALS }} + enable-AzPSSession: true + + - name: "Update file" + shell: pwsh + run: | + # Load used functions + . (Join-Path $env:GITHUB_WORKSPACE 'utilities' 'tools' 'platform' 'Set-StaticTestDocumentation.ps1') + + $functionInput = @{ + TestFilePath = Join-Path $env:GITHUB_WORKSPACE 'utilities' 'pipelines' 'staticValidation' 'module.tests.ps1' + WikiFilePath = Join-Path $env:GITHUB_WORKSPACE 'docs' 'wiki' 'The CI environment - Static validation.md' + } + + Write-Verbose "Invoke task with" -Verbose + Write-Verbose ($functionInput | ConvertTo-Json | Out-String) -Verbose + + Set-StaticTestDocumentation @functionInput -Verbose + + - name: "Push changes" + shell: pwsh + run: | + git config --global user.email '${{ env.pipelinePrincipalGitUserEmail }}' + git config --global user.name '${{ env.pipelinePrincipalGitUserName }}' + + git pull + git status + git add . + git commit -m 'Push updated API Specs file' + git push diff --git a/utilities/tools/platform/Set-StaticTestDocumentation.ps1 b/utilities/tools/platform/Set-StaticTestDocumentation.ps1 new file mode 100644 index 0000000000..973833cdf3 --- /dev/null +++ b/utilities/tools/platform/Set-StaticTestDocumentation.ps1 @@ -0,0 +1,103 @@ +#region helper +<# +.SYNOPSIS +Get an outline of all Pester test cases implemented in the given test file + +.DESCRIPTION +Get an outline of all Pester test cases implemented in the given test file +The output is returned as Markdown + +.PARAMETER TestFilePath +Mandatory. The path to the test file to get the content from. + +.EXAMPLE +Get-TestsAsMarkdown -TestFilePath 'C:/ResourceModules/utilities/pipelines/staticValidation/module.tests.ps1' + +Get an outline of all Pester tests implemented in the test file 'module.tests.ps1' +#> +function Get-TestsAsMarkdown { + + [CmdletBinding()] + param ( + [Parameter(Mandatory = $true)] + [string] $TestFilePath + ) + + $content = Get-Content $TestFilePath + + $relevantContent = [System.Collections.ArrayList]@() + foreach ($line in $content) { + if ($line -match "^\s*Describe '(.*?)'.*$") { + $formatted = $Matches[1] + $formatted = (($formatted -split '\s*\[<.+?>\]\s*') -join ' ').Trim() + $relevantContent += "- **$formatted**" + } elseif ( $line -match "^\s*Context '(.*?)'.*$" ) { + $formatted = $Matches[1] + $formatted = (($formatted -split '\s*\[<.+?>\]\s*') -join ' ').Trim() + $relevantContent += " - **$formatted**" + } elseif ( $line -match "^\s*It '(.*?)'.*$" ) { + $formatted = $Matches[1] + $formatted = (($formatted -split '\s*\[<.+?>\]\s*') -join ' ').Trim() + $relevantContent += " 1. $formatted" + } + } + + return $relevantContent +} +#endregion + +<# +.SYNOPSIS +Update the current documentation in the given wiki file path with the latest test detail of the given test file path. + +.DESCRIPTION +Update the current documentation in the given wiki file path with the latest test detail of the given test file path. + +.PARAMETER TestFilePath +Mandatory. The path to the test file to get the content from. + +.PARAMETER WikiFilePath +Mandatory. The path to the Wiki file to update the data in. It should contain a header '# Static code validation' + +.EXAMPLE +Set-StaticTestDocumentation -TestFilePath 'C:/ResourceModules/utilities/pipelines/staticValidation/module.tests.ps1' -WikiFilePath 'C:/ResourceModules/docs/wiki/The CI environment - Static validation.md' + +Update the section '# Static code validation' of Wiki file 'The CI environment - Static validation.md' with the content of the Pester test file 'module.tests.ps1' +#> +function Set-StaticTestDocumentation { + + [CmdletBinding(SupportsShouldProcess = $true)] + param ( + [Parameter(Mandatory = $true)] + [string] $TestFilePath, + + [Parameter(Mandatory = $true)] + [string] $WikiFilePath + ) + + # Load external functions + $toolsRoot = Split-Path $PSScriptRoot -Parent + . (Join-Path $toolsRoot 'helper' 'Merge-FileWithNewContent.ps1') + + # Logic + $contentArray = Get-Content -Path $WikiFilePath + + $testOutline = @( + 'All module Unit tests are performed with the help of [Pester](https://github.com/pester/Pester) to ensure that the modules are configured correctly, documentation is up to date, and modules don''t turn stale.', + '', + 'The following activities are performed by the [`utilities/pipelines/staticValidation/module.tests.ps1`](https://github.com/Azure/ResourceModules/blob/main/utilities/pipelines/staticValidation/module.tests.ps1) script.', + '' + ) + $testOutline += Get-TestsAsMarkdown -TestFilePath $TestFilePath + + $newContent = Merge-FileWithNewContent -oldContent $contentArray -newContent $testOutline -sectionStartIdentifier '# Static code validation' + + Write-Verbose 'New content:' + Write-Verbose '============' + Write-Verbose ($newContent | Out-String) + + if ($PSCmdlet.ShouldProcess("File in path [$WikiFilePath]", 'Overwrite')) { + Set-Content -Path $WikiFilePath -Value $newContent -Force + Write-Verbose "File [$WikiFilePath] updated" -Verbose + } +} From be33d0e70a505a76f773d51b26b66d20c2623038 Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Fri, 20 Jan 2023 20:26:52 +0100 Subject: [PATCH 04/15] Changed title --- .../platformPipelines/platform.updateStaticTestDocs.yml | 2 +- .github/workflows/platform.updateStaticTestDocs.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.azuredevops/platformPipelines/platform.updateStaticTestDocs.yml b/.azuredevops/platformPipelines/platform.updateStaticTestDocs.yml index 9c406b5f4c..ed1cff1870 100644 --- a/.azuredevops/platformPipelines/platform.updateStaticTestDocs.yml +++ b/.azuredevops/platformPipelines/platform.updateStaticTestDocs.yml @@ -1,4 +1,4 @@ -name: ".Platform - Update Pester Test Documentation" +name: ".Platform - Update Static Test Documentation" pr: none diff --git a/.github/workflows/platform.updateStaticTestDocs.yml b/.github/workflows/platform.updateStaticTestDocs.yml index 128e052ab3..563df3ed1c 100644 --- a/.github/workflows/platform.updateStaticTestDocs.yml +++ b/.github/workflows/platform.updateStaticTestDocs.yml @@ -1,4 +1,4 @@ -name: ".Platform: Update Pester Test Documentation" +name: ".Platform: Update Static Test Documentation" on: workflow_dispatch: From 683dfa695f829fb4acb66a3e785b451d5a37ffeb Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Fri, 20 Jan 2023 20:27:26 +0100 Subject: [PATCH 05/15] Disabled condition for testing --- .github/workflows/platform.updateStaticTestDocs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/platform.updateStaticTestDocs.yml b/.github/workflows/platform.updateStaticTestDocs.yml index 563df3ed1c..38b3e987c4 100644 --- a/.github/workflows/platform.updateStaticTestDocs.yml +++ b/.github/workflows/platform.updateStaticTestDocs.yml @@ -15,7 +15,7 @@ env: jobs: job_update_static_test_docs: name: "Update file" - if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' + #if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' runs-on: ubuntu-20.04 steps: - name: "Checkout" From 5e447d7032b2dae6cdaecd477f0610f3da60486f Mon Sep 17 00:00:00 2001 From: CARMLPipelinePrincipal Date: Fri, 20 Jan 2023 19:28:39 +0000 Subject: [PATCH 06/15] Push updated API Specs file --- .../The CI environment - Static validation.md | 73 ++++++++++++++----- 1 file changed, 53 insertions(+), 20 deletions(-) diff --git a/docs/wiki/The CI environment - Static validation.md b/docs/wiki/The CI environment - Static validation.md index 8b2cf2d76c..93b25d8e93 100644 --- a/docs/wiki/The CI environment - Static validation.md +++ b/docs/wiki/The CI environment - Static validation.md @@ -16,25 +16,59 @@ All module Unit tests are performed with the help of [Pester](https://github.com The following activities are performed by the [`utilities/pipelines/staticValidation/module.tests.ps1`](https://github.com/Azure/ResourceModules/blob/main/utilities/pipelines/staticValidation/module.tests.ps1) script. -- **File & folder tests** validate that the module folder structure is set up in the intended way, e.g.: - - readme.md file exists - - template file (either `deploy.json` or `deploy.bicep`) exists - - compliance with file naming convention -- **Deployment template tests** check the template's structure and elements for errors as well as consistency matters, e.g.: - - template file (or the built bicep template) converts from JSON and has all expected properties - - variable names are camelCase - - the minimum set of outputs is returned (see [module design](./The%20library%20-%20Module%20design#outputs)) -- **Module (readme) documentation** contains all required sections, e.g.: - - is not empty - - contains all the mandatory sections - - describes all the parameters - - describes all outputs - - describes all cross-references -- **Module Test Files**, e.g.: - - at least one `deploy.test.bicep` exists - - files should (optionally) be valid JSON - - must contain all required parameters - - (if tokens are used) Tests that no token values (e.g., `11111111-1111-1111-1111-11111111111`) from the specified token list (i.e., `deploymentSpId`, `subscriptionId`, `managementGroupId`, `tenantId`) are used in the module test files. Instead, the token itself should be referenced. +- **File/folder tests** + - **General module folder tests** + 1. Module should have a GitHub workflow + 1. Module should have an Azure DevOps pipeline + 1. Module should contain a [`deploy.json`/`deploy.bicep`] file + 1. Module should contain a [`readme.md`] file + 1. Module should contain a [`.test`] folder + 1. Module should contain a [`version.json`] file + - **.test folder** + 1. Folder should contain one or more test files + 1. JSON test files in the `.test` folder should be valid json +- **Readme tests** + - **Readme content tests** + 1. `Readme.md` file should not be empty + 1. `Readme.md` file should contain these sections in order: Navigation, Resource Types, Parameters, Outputs, Cross-referenced modules, Deployment examples + 1. Resources section should contain all resources from the template file + 1. Resources section should not contain more resources than the template file + 1. Parameters section should contain a table for each existing parameter category in the following order: Required, Conditional, Optional, Generated + 1. Parameter tables should provide columns in the following order: Parameter Name, Type, Default Value, Allowed Values, Description. Each column should be present unless empty for all the rows. + 1. Parameters section should contain all parameters from the template file + 1. Outputs section should contain a table with these column names in order: Output Name, Type + 1. Output section should contain all outputs defined in the template file + 1. Dependencies section should contain all cross-references defined in the template file + 1. `Set-ModuleReadMe` script should not apply any updates +- **Test file tests** + - **General test file** + 1. Bicep test deployment name should contain [`-test-`] + 1. Bicep test deployment should have parameter [`serviceShort`] + 1. JSON test deployment name should contain [`-test-`] + 1. JSON test deployment should have parameter [`serviceShort`] + - **Token usage** + 1. [Tokens] Test file should not contain the plain value for token guid +- **Deployment template tests** + - **General template** + 1. The template file should not be empty + 1. Template schema version should be the latest + 1. Template schema should use HTTPS reference + 1. All apiVersion properties should be set to a static, hard-coded value + 1. The template file should contain required elements: `schema`, `contentVersion`, `resources` + 1. If delete lock is implemented, the template should have a lock parameter with an empty default value + 1. Parameter names should be camel-cased (no dashes or underscores and must start with lower-case letter) + 1. Variable names should be camel-cased (no dashes or underscores and must start with lower-case letter) + 1. Output names should be camel-cased (no dashes or underscores and must start with lower-case letter) + 1. CUA ID deployment should be present in the template + 1. Location output should be returned for resources that use it + 1. Resource Group output should exist for resources that are deployed into a resource group scope + 1. Resource name output should exist + 1. Resource ID output should exist + 1. All parameters in parameters files exist in template file (`deploy.json`) + 1. All required parameters in template file (`deploy.json`) should exist in parameters files + 1. All non-required parameters in template file should not have description that start with "Required." +- **API version tests** + 1. In used resource type should use one of the recent API version(s). Currently using ## Output example @@ -85,4 +119,3 @@ Test-ModuleLocally @TestModuleLocallyInput -Verbose ``` > You can use the `Get-Help` cmdlet to show more options on how you can use this script. - From 8553d0941d833559258fbc16ac84a26f2d5f59ae Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Fri, 20 Jan 2023 20:33:50 +0100 Subject: [PATCH 07/15] Introduced section header --- .../wiki/The CI environment - Static validation.md | 2 ++ .../tools/platform/Set-StaticTestDocumentation.ps1 | 14 ++++---------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/docs/wiki/The CI environment - Static validation.md b/docs/wiki/The CI environment - Static validation.md index 93b25d8e93..f59c0e06c9 100644 --- a/docs/wiki/The CI environment - Static validation.md +++ b/docs/wiki/The CI environment - Static validation.md @@ -16,6 +16,8 @@ All module Unit tests are performed with the help of [Pester](https://github.com The following activities are performed by the [`utilities/pipelines/staticValidation/module.tests.ps1`](https://github.com/Azure/ResourceModules/blob/main/utilities/pipelines/staticValidation/module.tests.ps1) script. +## Outline + - **File/folder tests** - **General module folder tests** 1. Module should have a GitHub workflow diff --git a/utilities/tools/platform/Set-StaticTestDocumentation.ps1 b/utilities/tools/platform/Set-StaticTestDocumentation.ps1 index 973833cdf3..f6b01e7741 100644 --- a/utilities/tools/platform/Set-StaticTestDocumentation.ps1 +++ b/utilities/tools/platform/Set-StaticTestDocumentation.ps1 @@ -57,12 +57,12 @@ Update the current documentation in the given wiki file path with the latest tes Mandatory. The path to the test file to get the content from. .PARAMETER WikiFilePath -Mandatory. The path to the Wiki file to update the data in. It should contain a header '# Static code validation' +Mandatory. The path to the Wiki file to update the data in. It should contain a header '## Outline' .EXAMPLE Set-StaticTestDocumentation -TestFilePath 'C:/ResourceModules/utilities/pipelines/staticValidation/module.tests.ps1' -WikiFilePath 'C:/ResourceModules/docs/wiki/The CI environment - Static validation.md' -Update the section '# Static code validation' of Wiki file 'The CI environment - Static validation.md' with the content of the Pester test file 'module.tests.ps1' +Update the section '## Outline' of Wiki file 'The CI environment - Static validation.md' with the content of the Pester test file 'module.tests.ps1' #> function Set-StaticTestDocumentation { @@ -82,15 +82,9 @@ function Set-StaticTestDocumentation { # Logic $contentArray = Get-Content -Path $WikiFilePath - $testOutline = @( - 'All module Unit tests are performed with the help of [Pester](https://github.com/pester/Pester) to ensure that the modules are configured correctly, documentation is up to date, and modules don''t turn stale.', - '', - 'The following activities are performed by the [`utilities/pipelines/staticValidation/module.tests.ps1`](https://github.com/Azure/ResourceModules/blob/main/utilities/pipelines/staticValidation/module.tests.ps1) script.', - '' - ) - $testOutline += Get-TestsAsMarkdown -TestFilePath $TestFilePath + $testOutline = Get-TestsAsMarkdown -TestFilePath $TestFilePath - $newContent = Merge-FileWithNewContent -oldContent $contentArray -newContent $testOutline -sectionStartIdentifier '# Static code validation' + $newContent = Merge-FileWithNewContent -oldContent $contentArray -newContent $testOutline -sectionStartIdentifier '## Outline' Write-Verbose 'New content:' Write-Verbose '============' From bc26c90372364700c545cdfb9ea781cb2cda7cbc Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Fri, 20 Jan 2023 20:36:04 +0100 Subject: [PATCH 08/15] Replaced task type --- .../platformPipelines/platform.updateStaticTestDocs.yml | 9 +++------ .github/workflows/platform.updateStaticTestDocs.yml | 6 ------ 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/.azuredevops/platformPipelines/platform.updateStaticTestDocs.yml b/.azuredevops/platformPipelines/platform.updateStaticTestDocs.yml index ed1cff1870..051043ac03 100644 --- a/.azuredevops/platformPipelines/platform.updateStaticTestDocs.yml +++ b/.azuredevops/platformPipelines/platform.updateStaticTestDocs.yml @@ -29,15 +29,12 @@ jobs: - checkout: self persistCredentials: true - - task: AzurePowerShell@5 + - task: PowerShell@2 displayName: "Update file" inputs: - azureSubscription: "$(serviceConnection)" - azurePowerShellVersion: "latestVersion" - preferredAzurePowerShellVersion: "" + targetType: inline pwsh: true - ScriptType: InlineScript - inline: | + script: | # Load used functions . (Join-Path '$(System.DefaultWorkingDirectory)' 'utilities' 'tools' 'platform' 'Set-StaticTestDocumentation.ps1') diff --git a/.github/workflows/platform.updateStaticTestDocs.yml b/.github/workflows/platform.updateStaticTestDocs.yml index 38b3e987c4..dda38fd0a3 100644 --- a/.github/workflows/platform.updateStaticTestDocs.yml +++ b/.github/workflows/platform.updateStaticTestDocs.yml @@ -24,12 +24,6 @@ jobs: fetch-depth: 0 token: "${{ secrets.PLATFORM_REPO_UPDATE_PAT }}" # Sets general GIT credentials up - - name: Azure Login - uses: Azure/login@v1 - with: - creds: ${{ secrets.AZURE_CREDENTIALS }} - enable-AzPSSession: true - - name: "Update file" shell: pwsh run: | From 1d512f6919844ffe57a26461b4c1d360aa7c2adb Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Fri, 20 Jan 2023 20:37:26 +0100 Subject: [PATCH 09/15] Re-enabled conditions --- .github/workflows/platform.updateStaticTestDocs.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/platform.updateStaticTestDocs.yml b/.github/workflows/platform.updateStaticTestDocs.yml index dda38fd0a3..6dbe1a8d6a 100644 --- a/.github/workflows/platform.updateStaticTestDocs.yml +++ b/.github/workflows/platform.updateStaticTestDocs.yml @@ -3,10 +3,10 @@ name: ".Platform: Update Static Test Documentation" on: workflow_dispatch: push: - # branches: - # - main - # paths: - # - 'utilities/pipelines/staticValidation/module.tests.ps1' + branches: + - main + paths: + - 'utilities/pipelines/staticValidation/module.tests.ps1' env: pipelinePrincipalGitUserName: "CARMLPipelinePrincipal" @@ -15,7 +15,7 @@ env: jobs: job_update_static_test_docs: name: "Update file" - #if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' + if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' runs-on: ubuntu-20.04 steps: - name: "Checkout" From 3caaf8601281b68ebfba40a0746ed678c6f33651 Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Fri, 20 Jan 2023 20:38:29 +0100 Subject: [PATCH 10/15] Fallback of Wiki to re-enable testing --- .../The CI environment - Static validation.md | 73 +++++-------------- 1 file changed, 20 insertions(+), 53 deletions(-) diff --git a/docs/wiki/The CI environment - Static validation.md b/docs/wiki/The CI environment - Static validation.md index f59c0e06c9..3624f7f2c7 100644 --- a/docs/wiki/The CI environment - Static validation.md +++ b/docs/wiki/The CI environment - Static validation.md @@ -18,59 +18,25 @@ The following activities are performed by the [`utilities/pipelines/staticValida ## Outline -- **File/folder tests** - - **General module folder tests** - 1. Module should have a GitHub workflow - 1. Module should have an Azure DevOps pipeline - 1. Module should contain a [`deploy.json`/`deploy.bicep`] file - 1. Module should contain a [`readme.md`] file - 1. Module should contain a [`.test`] folder - 1. Module should contain a [`version.json`] file - - **.test folder** - 1. Folder should contain one or more test files - 1. JSON test files in the `.test` folder should be valid json -- **Readme tests** - - **Readme content tests** - 1. `Readme.md` file should not be empty - 1. `Readme.md` file should contain these sections in order: Navigation, Resource Types, Parameters, Outputs, Cross-referenced modules, Deployment examples - 1. Resources section should contain all resources from the template file - 1. Resources section should not contain more resources than the template file - 1. Parameters section should contain a table for each existing parameter category in the following order: Required, Conditional, Optional, Generated - 1. Parameter tables should provide columns in the following order: Parameter Name, Type, Default Value, Allowed Values, Description. Each column should be present unless empty for all the rows. - 1. Parameters section should contain all parameters from the template file - 1. Outputs section should contain a table with these column names in order: Output Name, Type - 1. Output section should contain all outputs defined in the template file - 1. Dependencies section should contain all cross-references defined in the template file - 1. `Set-ModuleReadMe` script should not apply any updates -- **Test file tests** - - **General test file** - 1. Bicep test deployment name should contain [`-test-`] - 1. Bicep test deployment should have parameter [`serviceShort`] - 1. JSON test deployment name should contain [`-test-`] - 1. JSON test deployment should have parameter [`serviceShort`] - - **Token usage** - 1. [Tokens] Test file should not contain the plain value for token guid -- **Deployment template tests** - - **General template** - 1. The template file should not be empty - 1. Template schema version should be the latest - 1. Template schema should use HTTPS reference - 1. All apiVersion properties should be set to a static, hard-coded value - 1. The template file should contain required elements: `schema`, `contentVersion`, `resources` - 1. If delete lock is implemented, the template should have a lock parameter with an empty default value - 1. Parameter names should be camel-cased (no dashes or underscores and must start with lower-case letter) - 1. Variable names should be camel-cased (no dashes or underscores and must start with lower-case letter) - 1. Output names should be camel-cased (no dashes or underscores and must start with lower-case letter) - 1. CUA ID deployment should be present in the template - 1. Location output should be returned for resources that use it - 1. Resource Group output should exist for resources that are deployed into a resource group scope - 1. Resource name output should exist - 1. Resource ID output should exist - 1. All parameters in parameters files exist in template file (`deploy.json`) - 1. All required parameters in template file (`deploy.json`) should exist in parameters files - 1. All non-required parameters in template file should not have description that start with "Required." -- **API version tests** - 1. In used resource type should use one of the recent API version(s). Currently using +- **File & folder tests** validate that the module folder structure is set up in the intended way, e.g.: + - readme.md file exists + - template file (either `deploy.json` or `deploy.bicep`) exists + - compliance with file naming convention +- **Deployment template tests** check the template's structure and elements for errors as well as consistency matters, e.g.: + - template file (or the built bicep template) converts from JSON and has all expected properties + - variable names are camelCase + - the minimum set of outputs is returned (see [module design](./The%20library%20-%20Module%20design#outputs)) +- **Module (readme) documentation** contains all required sections, e.g.: + - is not empty + - contains all the mandatory sections + - describes all the parameters + - describes all outputs + - describes all cross-references +- **Module Test Files**, e.g.: + - at least one `deploy.test.bicep` exists + - files should (optionally) be valid JSON + - must contain all required parameters + - (if tokens are used) Tests that no token values (e.g., `11111111-1111-1111-1111-11111111111`) from the specified token list (i.e., `deploymentSpId`, `subscriptionId`, `managementGroupId`, `tenantId`) are used in the module test files. Instead, the token itself should be referenced. ## Output example @@ -121,3 +87,4 @@ Test-ModuleLocally @TestModuleLocallyInput -Verbose ``` > You can use the `Get-Help` cmdlet to show more options on how you can use this script. + From 7a15f883df4efa79c3298f8b8e660facd4859939 Mon Sep 17 00:00:00 2001 From: CARMLPipelinePrincipal Date: Fri, 20 Jan 2023 19:42:15 +0000 Subject: [PATCH 11/15] Push updated API Specs file --- .../The CI environment - Static validation.md | 73 ++++++++++++++----- 1 file changed, 53 insertions(+), 20 deletions(-) diff --git a/docs/wiki/The CI environment - Static validation.md b/docs/wiki/The CI environment - Static validation.md index 3624f7f2c7..f59c0e06c9 100644 --- a/docs/wiki/The CI environment - Static validation.md +++ b/docs/wiki/The CI environment - Static validation.md @@ -18,25 +18,59 @@ The following activities are performed by the [`utilities/pipelines/staticValida ## Outline -- **File & folder tests** validate that the module folder structure is set up in the intended way, e.g.: - - readme.md file exists - - template file (either `deploy.json` or `deploy.bicep`) exists - - compliance with file naming convention -- **Deployment template tests** check the template's structure and elements for errors as well as consistency matters, e.g.: - - template file (or the built bicep template) converts from JSON and has all expected properties - - variable names are camelCase - - the minimum set of outputs is returned (see [module design](./The%20library%20-%20Module%20design#outputs)) -- **Module (readme) documentation** contains all required sections, e.g.: - - is not empty - - contains all the mandatory sections - - describes all the parameters - - describes all outputs - - describes all cross-references -- **Module Test Files**, e.g.: - - at least one `deploy.test.bicep` exists - - files should (optionally) be valid JSON - - must contain all required parameters - - (if tokens are used) Tests that no token values (e.g., `11111111-1111-1111-1111-11111111111`) from the specified token list (i.e., `deploymentSpId`, `subscriptionId`, `managementGroupId`, `tenantId`) are used in the module test files. Instead, the token itself should be referenced. +- **File/folder tests** + - **General module folder tests** + 1. Module should have a GitHub workflow + 1. Module should have an Azure DevOps pipeline + 1. Module should contain a [`deploy.json`/`deploy.bicep`] file + 1. Module should contain a [`readme.md`] file + 1. Module should contain a [`.test`] folder + 1. Module should contain a [`version.json`] file + - **.test folder** + 1. Folder should contain one or more test files + 1. JSON test files in the `.test` folder should be valid json +- **Readme tests** + - **Readme content tests** + 1. `Readme.md` file should not be empty + 1. `Readme.md` file should contain these sections in order: Navigation, Resource Types, Parameters, Outputs, Cross-referenced modules, Deployment examples + 1. Resources section should contain all resources from the template file + 1. Resources section should not contain more resources than the template file + 1. Parameters section should contain a table for each existing parameter category in the following order: Required, Conditional, Optional, Generated + 1. Parameter tables should provide columns in the following order: Parameter Name, Type, Default Value, Allowed Values, Description. Each column should be present unless empty for all the rows. + 1. Parameters section should contain all parameters from the template file + 1. Outputs section should contain a table with these column names in order: Output Name, Type + 1. Output section should contain all outputs defined in the template file + 1. Dependencies section should contain all cross-references defined in the template file + 1. `Set-ModuleReadMe` script should not apply any updates +- **Test file tests** + - **General test file** + 1. Bicep test deployment name should contain [`-test-`] + 1. Bicep test deployment should have parameter [`serviceShort`] + 1. JSON test deployment name should contain [`-test-`] + 1. JSON test deployment should have parameter [`serviceShort`] + - **Token usage** + 1. [Tokens] Test file should not contain the plain value for token guid +- **Deployment template tests** + - **General template** + 1. The template file should not be empty + 1. Template schema version should be the latest + 1. Template schema should use HTTPS reference + 1. All apiVersion properties should be set to a static, hard-coded value + 1. The template file should contain required elements: `schema`, `contentVersion`, `resources` + 1. If delete lock is implemented, the template should have a lock parameter with an empty default value + 1. Parameter names should be camel-cased (no dashes or underscores and must start with lower-case letter) + 1. Variable names should be camel-cased (no dashes or underscores and must start with lower-case letter) + 1. Output names should be camel-cased (no dashes or underscores and must start with lower-case letter) + 1. CUA ID deployment should be present in the template + 1. Location output should be returned for resources that use it + 1. Resource Group output should exist for resources that are deployed into a resource group scope + 1. Resource name output should exist + 1. Resource ID output should exist + 1. All parameters in parameters files exist in template file (`deploy.json`) + 1. All required parameters in template file (`deploy.json`) should exist in parameters files + 1. All non-required parameters in template file should not have description that start with "Required." +- **API version tests** + 1. In used resource type should use one of the recent API version(s). Currently using ## Output example @@ -87,4 +121,3 @@ Test-ModuleLocally @TestModuleLocallyInput -Verbose ``` > You can use the `Get-Help` cmdlet to show more options on how you can use this script. - From 6e760e23d668fba474f8810d0277f6f25eae4407 Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Fri, 20 Jan 2023 20:45:00 +0100 Subject: [PATCH 12/15] Introduced display names --- .azuredevops/platformPipelines/platform.apiSpecs.yml | 1 + .azuredevops/platformPipelines/platform.updateReadMe.yml | 1 + .../platformPipelines/platform.updateStaticTestDocs.yml | 1 + .azuredevops/platformPipelines/platform.wiki-sync.yml | 3 ++- 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.azuredevops/platformPipelines/platform.apiSpecs.yml b/.azuredevops/platformPipelines/platform.apiSpecs.yml index b64f1a5e0b..83ce2988f8 100644 --- a/.azuredevops/platformPipelines/platform.apiSpecs.yml +++ b/.azuredevops/platformPipelines/platform.apiSpecs.yml @@ -18,6 +18,7 @@ variables: jobs: - job: Update_API_Specs_file + displayName: Update API Specs file pool: ${{ if ne(variables.vmImage, '') }}: vmImage: ${{ variables.vmImage }} diff --git a/.azuredevops/platformPipelines/platform.updateReadMe.yml b/.azuredevops/platformPipelines/platform.updateReadMe.yml index e0f2bbe900..caafdafd6e 100644 --- a/.azuredevops/platformPipelines/platform.updateReadMe.yml +++ b/.azuredevops/platformPipelines/platform.updateReadMe.yml @@ -26,6 +26,7 @@ variables: jobs: - job: Update_module_tables + displayName: Update module tables pool: ${{ if ne(variables.vmImage, '') }}: vmImage: ${{ variables.vmImage }} diff --git a/.azuredevops/platformPipelines/platform.updateStaticTestDocs.yml b/.azuredevops/platformPipelines/platform.updateStaticTestDocs.yml index 051043ac03..6a9acff28f 100644 --- a/.azuredevops/platformPipelines/platform.updateStaticTestDocs.yml +++ b/.azuredevops/platformPipelines/platform.updateStaticTestDocs.yml @@ -20,6 +20,7 @@ variables: jobs: - job: Update_Static_Test_Docs + displayName: Update Static Tests Documentation pool: ${{ if ne(variables.vmImage, '') }}: vmImage: ${{ variables.vmImage }} diff --git a/.azuredevops/platformPipelines/platform.wiki-sync.yml b/.azuredevops/platformPipelines/platform.wiki-sync.yml index abf22c1d2f..5bdf5ee830 100644 --- a/.azuredevops/platformPipelines/platform.wiki-sync.yml +++ b/.azuredevops/platformPipelines/platform.wiki-sync.yml @@ -23,7 +23,8 @@ variables: value: 'CARML@noreply.github.com' jobs: - - job: Update_module_tables + - job: sync_wiki + displayName: Sync Wiki pool: ${{ if ne('$(vmImage)', '') }}: vmImage: '$(vmImage)' From 6df1ebd672c35e9fe0af60156888961ade86ae91 Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Fri, 20 Jan 2023 20:54:58 +0100 Subject: [PATCH 13/15] Update to latest --- .azuredevops/platformPipelines/platform.apiSpecs.yml | 1 - .azuredevops/platformPipelines/platform.updateReadMe.yml | 1 - .azuredevops/platformPipelines/platform.wiki-sync.yml | 3 +-- 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/.azuredevops/platformPipelines/platform.apiSpecs.yml b/.azuredevops/platformPipelines/platform.apiSpecs.yml index 83ce2988f8..b64f1a5e0b 100644 --- a/.azuredevops/platformPipelines/platform.apiSpecs.yml +++ b/.azuredevops/platformPipelines/platform.apiSpecs.yml @@ -18,7 +18,6 @@ variables: jobs: - job: Update_API_Specs_file - displayName: Update API Specs file pool: ${{ if ne(variables.vmImage, '') }}: vmImage: ${{ variables.vmImage }} diff --git a/.azuredevops/platformPipelines/platform.updateReadMe.yml b/.azuredevops/platformPipelines/platform.updateReadMe.yml index caafdafd6e..e0f2bbe900 100644 --- a/.azuredevops/platformPipelines/platform.updateReadMe.yml +++ b/.azuredevops/platformPipelines/platform.updateReadMe.yml @@ -26,7 +26,6 @@ variables: jobs: - job: Update_module_tables - displayName: Update module tables pool: ${{ if ne(variables.vmImage, '') }}: vmImage: ${{ variables.vmImage }} diff --git a/.azuredevops/platformPipelines/platform.wiki-sync.yml b/.azuredevops/platformPipelines/platform.wiki-sync.yml index 5bdf5ee830..abf22c1d2f 100644 --- a/.azuredevops/platformPipelines/platform.wiki-sync.yml +++ b/.azuredevops/platformPipelines/platform.wiki-sync.yml @@ -23,8 +23,7 @@ variables: value: 'CARML@noreply.github.com' jobs: - - job: sync_wiki - displayName: Sync Wiki + - job: Update_module_tables pool: ${{ if ne('$(vmImage)', '') }}: vmImage: '$(vmImage)' From 7e823fa6520ecfbd76963a450dde9e2e9bbea3e6 Mon Sep 17 00:00:00 2001 From: Alexander Sehr Date: Fri, 3 Feb 2023 11:11:43 +0100 Subject: [PATCH 14/15] Update .github/workflows/platform.updateStaticTestDocs.yml Co-authored-by: Erika Gressi <56914614+eriqua@users.noreply.github.com> --- .github/workflows/platform.updateStaticTestDocs.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/platform.updateStaticTestDocs.yml b/.github/workflows/platform.updateStaticTestDocs.yml index 6dbe1a8d6a..972fa49ff2 100644 --- a/.github/workflows/platform.updateStaticTestDocs.yml +++ b/.github/workflows/platform.updateStaticTestDocs.yml @@ -6,7 +6,9 @@ on: branches: - main paths: + - '.github/workflows/platform.updateStaticTestDocs.yml' - 'utilities/pipelines/staticValidation/module.tests.ps1' + - utilities/tools/platform/Set-StaticTestDocumentation.ps1 env: pipelinePrincipalGitUserName: "CARMLPipelinePrincipal" From 2aaa1685bd4183dca3d810461ba7446d043b6a7f Mon Sep 17 00:00:00 2001 From: Alexander Sehr Date: Fri, 3 Feb 2023 11:11:50 +0100 Subject: [PATCH 15/15] Update .azuredevops/platformPipelines/platform.updateStaticTestDocs.yml Co-authored-by: Erika Gressi <56914614+eriqua@users.noreply.github.com> --- .../platformPipelines/platform.updateStaticTestDocs.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.azuredevops/platformPipelines/platform.updateStaticTestDocs.yml b/.azuredevops/platformPipelines/platform.updateStaticTestDocs.yml index 6a9acff28f..8f12160f03 100644 --- a/.azuredevops/platformPipelines/platform.updateStaticTestDocs.yml +++ b/.azuredevops/platformPipelines/platform.updateStaticTestDocs.yml @@ -9,7 +9,9 @@ trigger: - main paths: include: + - .azuredevops/platformPipelines/platform.updateStaticTestDocs.yml - 'utilities/pipelines/staticValidation/module.tests.ps1' + - utilities/tools/platform/Set-StaticTestDocumentation.ps1 variables: - template: "../../settings.yml"