Sync eng/common directory with azure-sdk-tools for PR 1559 (#2123)

* Handle empty files in Test-SampleMetadata

Relates to Azure/azure-sdk-for-java#20684

* Remove condition from verify-samples

* Use forward slash in path

* Fix directory typo

Co-authored-by: Heath Stewart <heaths@microsoft.com>
This commit is contained in:
Azure SDK Bot 2021-04-14 22:37:40 -07:00 committed by GitHub
parent 8002b63f61
commit 6b50feb0d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 7 deletions

View File

@ -5,15 +5,11 @@ parameters:
- name: ScriptDirectory
type: string
default: eng/common/scripts
- name: Condition
type: boolean
default: succeeded()
steps:
- pwsh: |
# If the last path segment is an absolute path it will be used entirely.
$root = [System.IO.Path]::Combine('$(Build.SourcesDireectory)', 'sdk', '${{ parameters.ServiceDirectory }}')
Get-ChildItem $root -Filter *.md -Recurse | ${{ parameters.ScriptDirectory }}\Test-SampleMetadata.ps1 -AllowParentProducts
$root = [System.IO.Path]::Combine('$(Build.SourcesDirectory)', 'sdk', '${{ parameters.ServiceDirectory }}')
Get-ChildItem $root -Filter *.md -Recurse | ${{ parameters.ScriptDirectory }}/Test-SampleMetadata.ps1 -AllowParentProducts
displayName: Verify sample metadata
workingDirectory: $(Build.SourcesDirectory)
condition: ${{ parameters.Condition }}

View File

@ -31,11 +31,13 @@ process {
}
[string[]] $content = $file | Get-Content
if (!$content[0].StartsWith('---')) {
if (!$content -or !$content[0].StartsWith('---')) {
Write-Verbose "Skipping $($file.FullName): does not contain frontmatter"
continue
}
Write-Verbose "Checking $($file.FullName)"
# Reset metadata and create mutable collections.
$products = [System.Collections.Generic.List[string]]::new()