forked from Azure/azure-sdk-for-net
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sync eng/common directory with azure-sdk-tools repository for Tools PR …
- Loading branch information
Showing
4 changed files
with
60 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
|
||
. (Join-Path $PSScriptRoot common.ps1) | ||
Install-Module -Name powershell-yaml -RequiredVersion 0.4.1 -Force -Scope CurrentUser | ||
$ymlfiles = Get-ChildItem $RepoRoot | Where-Object {$_ -like '*.yml'} | ||
$affectedRepos = @() | ||
|
||
foreach ($file in $ymlfiles) | ||
{ | ||
Write-Host "Verifying '${file}'" | ||
$ymlContent = Get-Content $file.FullName -Raw | ||
$ymlObject = ConvertFrom-Yaml $ymlContent -Ordered | ||
|
||
if ($ymlObject.Contains("resources")) | ||
{ | ||
if ($ymlObject["resources"]["repositories"]) | ||
{ | ||
$repositories = $ymlObject["resources"]["repositories"] | ||
foreach ($repo in $repositories) | ||
{ | ||
$repoName = $repo["repository"] | ||
if (-not ($repo.Contains("ref"))) | ||
{ | ||
$errorMessage = "File: ${file}, Repository: ${repoName}." | ||
$affectedRepos.Add($errorMessage) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
if ($affectedRepos.Count -gt 0) | ||
{ | ||
Write-Error "Ref not found in the following Repository Resources." | ||
foreach ($errorMessage in $affectedRepos) | ||
{ | ||
Write-Information $errorMessage | ||
} | ||
Write-Information "Please ensure you add a Ref: when using repository resources" | ||
Write-Information "More Info at https://aka.ms/azsdk/engsys/tools-versioning" | ||
exit 1 | ||
} | ||
|
||
Write-Information "All repository resources in yaml files reference a valid tag" |