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] Align Join-Path usage + minor formatting updates #1761

Merged
merged 5 commits into from
Aug 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 6 additions & 6 deletions .azuredevops/pipelineTemplates/jobs.publishModule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ jobs:
. (Join-Path '$(System.DefaultWorkingDirectory)' '$(pipelineFunctionsPath)' 'resourcePublish' 'Publish-ModuleToUniversalArtifactFeed.ps1')

#Prioritizing the bicep file
$TemplateFilePath = Join-Path -Path '$(ENVMODULEPATH)' -ChildPath 'deploy.bicep'
$TemplateFilePath = Join-Path '$(ENVMODULEPATH)' 'deploy.bicep'
if (-not (Test-Path $TemplateFilePath)) {
$TemplateFilePath = Join-Path -Path '$(ENVMODULEPATH)' -ChildPath 'deploy.json'
$TemplateFilePath = Join-Path '$(ENVMODULEPATH)' 'deploy.json'
}

$functionInput = @{
Expand Down Expand Up @@ -218,9 +218,9 @@ jobs:
. (Join-Path '$(System.DefaultWorkingDirectory)' '$(pipelineFunctionsPath)' 'resourcePublish' 'Publish-ModuleToTemplateSpec.ps1')

#Prioritizing the bicep file
$TemplateFilePath = Join-Path -Path '$(ENVMODULEPATH)' -ChildPath 'deploy.bicep'
$TemplateFilePath = Join-Path '$(ENVMODULEPATH)' 'deploy.bicep'
if (-not (Test-Path $TemplateFilePath)) {
$TemplateFilePath = Join-Path -Path '$(ENVMODULEPATH)' -ChildPath 'deploy.json'
$TemplateFilePath = Join-Path '$(ENVMODULEPATH)' 'deploy.json'
}

$functionInput = @{
Expand Down Expand Up @@ -278,9 +278,9 @@ jobs:
. (Join-Path '$(System.DefaultWorkingDirectory)' '$(pipelineFunctionsPath)' 'resourcePublish' 'Publish-ModuleToPrivateBicepRegistry.ps1')

#Prioritizing the bicep file
$TemplateFilePath = Join-Path -Path '$(ENVMODULEPATH)' -ChildPath 'deploy.bicep'
$TemplateFilePath = Join-Path '$(ENVMODULEPATH)' 'deploy.bicep'
if (-not (Test-Path $TemplateFilePath)) {
$TemplateFilePath = Join-Path -Path '$(ENVMODULEPATH)' -ChildPath 'deploy.json'
$TemplateFilePath = Join-Path '$(ENVMODULEPATH)' 'deploy.json'
}

$functionInput = @{
Expand Down
2 changes: 1 addition & 1 deletion .azuredevops/platformPipelines/platform.updateReadMe.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:

$functionInput = @{
ModulesPath = Join-Path '$(System.DefaultWorkingDirectory)' 'modules'
FilePath = Join-Path '$(System.DefaultWorkingDirectory)' 'modules/README.md'
FilePath = Join-Path '$(System.DefaultWorkingDirectory)' 'modules' 'README.md'
Organization = '$(System.CollectionUri)'.Split('/')[3]
RepositoryName = '$(Build.Repository.Name)'
ColumnsInOrder = @('Name', 'ProviderNamespace','ResourceType')
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/platform.updateReadMe.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:

$functionInput = @{
ModulesPath = Join-Path $env:GITHUB_WORKSPACE 'modules'
FilePath = Join-Path $env:GITHUB_WORKSPACE 'modules/README.md'
FilePath = Join-Path $env:GITHUB_WORKSPACE 'modules' 'README.md'
Organization = ($env:GITHUB_REPOSITORY).split('/')[0]
RepositoryName = ($env:GITHUB_REPOSITORY).split('/')[1]
ColumnsInOrder = @('Name', 'ProviderNamespace','ResourceType')
Expand Down
10 changes: 5 additions & 5 deletions utilities/pipelines/resourcePublish/Get-ModulesToPublish.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ function Find-TemplateFile {
}

#Prioritizing the bicep file
$TemplateFilePath = Join-Path -Path $FolderPath -ChildPath 'deploy.bicep'
$TemplateFilePath = Join-Path $FolderPath 'deploy.bicep'
if (-not (Test-Path $TemplateFilePath)) {
$TemplateFilePath = Join-Path -Path $FolderPath -ChildPath 'deploy.json'
$TemplateFilePath = Join-Path $FolderPath 'deploy.json'
}

if (-not (Test-Path $TemplateFilePath)) {
Expand Down Expand Up @@ -211,9 +211,9 @@ function Get-ParentModuleTemplateFile {
$ParentFolderPath = Split-Path $ModuleFolderPath -Parent

#Prioritizing the bicep file
$ParentTemplateFilePath = Join-Path -Path $ParentFolderPath -ChildPath 'deploy.bicep'
$ParentTemplateFilePath = Join-Path $ParentFolderPath 'deploy.bicep'
if (-not (Test-Path $TemplateFilePath)) {
$ParentTemplateFilePath = Join-Path -Path $ParentFolderPath -ChildPath 'deploy.json'
$ParentTemplateFilePath = Join-Path $ParentFolderPath 'deploy.json'
}

if (-not (Test-Path -Path $ParentTemplateFilePath)) {
Expand Down Expand Up @@ -283,7 +283,7 @@ function Get-ModuleVersionFromFile {
)

$ModuleFolder = Split-Path -Path $TemplateFilePath -Parent
$VersionFilePath = Join-Path -Path $ModuleFolder -ChildPath 'version.json'
$VersionFilePath = Join-Path $ModuleFolder 'version.json'

if (-not (Test-Path -Path $VersionFilePath)) {
throw "No version file found at: [$VersionFilePath]"
Expand Down
2 changes: 1 addition & 1 deletion utilities/pipelines/staticValidation/module.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ $script:jsonTemplateLoadFailedException = "Unable to load the deploy.json templa
$script:templateNotFoundException = 'No template file found in folder [{0}]' # -f $moduleFolderPath

# Import any helper function used in this test script
Import-Module (Join-Path $PSScriptRoot 'helper\helper.psm1') -Force
Import-Module (Join-Path $PSScriptRoot 'helper' 'helper.psm1') -Force

Describe 'File/folder tests' -Tag Modules {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Optional. A string for a custom output directory of the modified parameter file

.NOTES
- Make sure you provide the right information in the objects that contain tokens. This is in the form of
@(
@(
@{ Name = 'deploymentSpId'; Value = '12345678-1234-1234-1234-123456789123' }
@{ Name = 'tenantId'; Value = '12345678-1234-1234-1234-123456789123' }

Expand Down Expand Up @@ -60,7 +60,7 @@ function Convert-TokensInFileList {

begin {
# Load used funtions
. (Join-Path $PSScriptRoot './helper/Convert-TokenInFile.ps1')
. (Join-Path $PSScriptRoot 'helper' 'Convert-TokenInFile.ps1')
}

process {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function Convert-TokenInFile {
# Set Content
if ($OutputDirectory -and (Test-Path -Path $OutputDirectory -PathType Container)) {
# If Specific Output Directory Provided
$Path = (Join-Path -Path $OutputDirectory -ChildPath $FileName)
$Path = Join-Path $OutputDirectory $FileName
}
# Set Content
$File | Set-Content -Path $Path
Expand Down
10 changes: 5 additions & 5 deletions utilities/tools/ConvertTo-ARMTemplate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ param (
)

$rootPath = Get-Item -Path $Path | Select-Object -ExpandProperty 'FullName'
$modulesFolderPath = Join-Path -Path $rootPath -ChildPath 'modules'
$modulesFolderPath = Join-Path $rootPath 'modules'
if ($ConvertChildren) {
$BicepFilesToConvert = Get-ChildItem -Path $modulesFolderPath -Filter 'deploy.bicep' -Recurse -Force
} else {
Expand All @@ -66,7 +66,7 @@ if ($ConvertChildren) {
#region Remove existing deploy.json files
Write-Verbose 'Remove existing deploy.json files'

if (Test-Path -Path (Join-Path -Path $modulesFolderPath -ChildPath 'deploy.bicep')) {
if (Test-Path -Path (Join-Path $modulesFolderPath 'deploy.bicep')) {
$JsonFilesToRemove = Get-ChildItem -Path $modulesFolderPath -Filter 'deploy.json' -Recurse -Force -File
Write-Verbose "Remove existing deploy.json files - Remove [$($JsonFilesToRemove.count)] file(s)"
if ($PSCmdlet.ShouldProcess("[$($JsonFilesToRemove.count)] deploy.json files(s) in path [$modulesFolderPath]", 'Remove-Item')) {
Expand Down Expand Up @@ -132,7 +132,7 @@ if (-not $SkipMetadataCleanup) {
}

$moduleFolderPath = $_.Directory.FullName
$JSONFilePath = Join-Path -Path $moduleFolderPath -ChildPath 'deploy.json'
$JSONFilePath = Join-Path $moduleFolderPath 'deploy.json'
if (Test-Path -Path $JSONFilePath) {
$JSONFileContent = Get-Content -Path $JSONFilePath
$JSONObj = $JSONFileContent | ConvertFrom-Json
Expand Down Expand Up @@ -174,7 +174,7 @@ if (-not $SkipPipelineUpdate) {
Write-Verbose 'Update pipeline files'

# GitHub workflow files
$ghWorkflowFolderPath = Join-Path -Path $rootPath -ChildPath '.github\workflows'
$ghWorkflowFolderPath = Join-Path -Path $rootPath '.github' 'workflows'
if (Test-Path -Path $ghWorkflowFolderPath) {
$ghWorkflowFilesToUpdate = Get-ChildItem -Path $ghWorkflowFolderPath -Filter 'ms.*.yml' -File -Force
Write-Verbose ('Update workflow files - Processing [{0}] file(s)' -f $ghWorkflowFilesToUpdate.count)
Expand All @@ -190,7 +190,7 @@ if (-not $SkipPipelineUpdate) {
}

# Azure DevOps Pipelines
$adoPipelineFolderPath = Join-Path -Path $rootPath -ChildPath '.azuredevops\modulePipelines'
$adoPipelineFolderPath = Join-Path -Path $rootPath '.azuredevops' 'modulePipelines'
if (Test-Path -Path $adoPipelineFolderPath) {
$adoPipelineFilesToUpdate = Get-ChildItem -Path $adoPipelineFolderPath -Filter 'ms.*.yml' -File -Force
Write-Verbose ('Update Azure DevOps pipeline files - Processing [{0}] file(s)' -f $adoPipelineFilesToUpdate.count)
Expand Down
2 changes: 1 addition & 1 deletion utilities/tools/Set-ModuleReadMe.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ function Set-ModuleReadMe {
)

# Load external functions
. (Join-Path $PSScriptRoot 'helper/Merge-FileWithNewContent.ps1')
. (Join-Path $PSScriptRoot 'helper' 'Merge-FileWithNewContent.ps1')
. (Join-Path (Split-Path $PSScriptRoot -Parent) 'pipelines' 'sharedScripts' 'Get-NestedResourceList.ps1')

# Check template & make full path
Expand Down
9 changes: 5 additions & 4 deletions utilities/tools/Test-ModuleLocally.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,13 @@ function Test-ModuleLocally {
begin {
$repoRootPath = (Get-Item $PSScriptRoot).Parent.Parent
$ModuleName = Split-Path (Split-Path $TemplateFilePath -Parent) -Leaf
$utilitiesFolderPath = Split-Path $PSScriptRoot -Parent
Write-Verbose "Running local tests for [$ModuleName]"
# Load Tokens Converter Scripts
. (Join-Path $PSScriptRoot '../pipelines/tokensReplacement/Convert-TokensInFileList.ps1')
. (Join-Path $utilitiesFolderPath 'pipelines' 'tokensReplacement' 'Convert-TokensInFileList.ps1')
# Load Modules Validation / Deployment Scripts
. (Join-Path $PSScriptRoot '../pipelines/resourceDeployment/New-TemplateDeployment.ps1')
. (Join-Path $PSScriptRoot '../pipelines/resourceDeployment/Test-TemplateDeployment.ps1')
. (Join-Path $utilitiesFolderPath 'pipelines' 'resourceDeployment' 'New-TemplateDeployment.ps1')
. (Join-Path $utilitiesFolderPath 'pipelines' 'resourceDeployment' 'Test-TemplateDeployment.ps1')
}
process {

Expand All @@ -156,7 +157,7 @@ function Test-ModuleLocally {
}

# Construct Token Configuration Input
$GlobalVariablesObject = Get-Content -Path (Join-Path $PSScriptRoot '..\..\settings.yml') | ConvertFrom-Yaml -ErrorAction Stop | Select-Object -ExpandProperty variables
$GlobalVariablesObject = Get-Content -Path (Join-Path $repoRootPath 'settings.yml') | ConvertFrom-Yaml -ErrorAction Stop | Select-Object -ExpandProperty variables
$tokenConfiguration = @{
FilePathList = $moduleTestFiles
Tokens = @{}
Expand Down
8 changes: 4 additions & 4 deletions utilities/tools/Test-NamePrefixAvailability.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ function Test-NamePrefixAvailability {
Write-Debug ('{0} entered' -f $MyInvocation.MyCommand)

# Load helper Scripts
. (Join-Path $PSScriptRoot '../pipelines/tokensReplacement/Convert-TokensInFileList.ps1')
$root = (Get-Item $PSScriptRoot).Parent.Parent.FullName
$repoRoot = (Get-Item $PSScriptRoot).Parent.Parent.FullName
. (Join-Path $repoRoot 'utilities' 'pipelines' 'tokensReplacement' 'Convert-TokensInFileList.ps1')
}
process {

Expand All @@ -56,14 +56,14 @@ function Test-NamePrefixAvailability {
'Microsoft.ContainerRegistry/registries'
'Microsoft.KeyVault/vaults'
)
$parameterFiles = (Get-ChildItem -Path $root -Recurse -Filter '*.json').FullName | ForEach-Object { $_.Replace('\', '/') }
$parameterFiles = (Get-ChildItem -Path $repoRoot -Recurse -Filter '*.json').FullName | ForEach-Object { $_.Replace('\', '/') }
$parameterFiles = $parameterFiles | Where-Object { $_ -match '(?:{0}).*parameters\.json' -f ($relevantResourceTypes -join '|' -replace '/', '\/+') }

# Replace parameter file tokens
# -----------------------------

# Tokens in settings.yml
$GlobalVariablesObject = Get-Content -Path (Join-Path $PSScriptRoot '..\..\settings.yml') | ConvertFrom-Yaml -ErrorAction Stop | Select-Object -ExpandProperty variables
$GlobalVariablesObject = Get-Content -Path (Join-Path $repoRoot 'settings.yml') | ConvertFrom-Yaml -ErrorAction Stop | Select-Object -ExpandProperty variables

# Construct Token Configuration Input
$tokenConfiguration = @{
Expand Down