Skip to content

Commit

Permalink
Sync eng/common directory with azure-sdk-tools for PR 1559 (Azure#14891)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
azure-sdk and heaths authored Apr 15, 2021
1 parent b301b9c commit 510acb8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
8 changes: 2 additions & 6 deletions eng/common/pipelines/templates/steps/verify-samples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
4 changes: 3 additions & 1 deletion eng/common/scripts/Test-SampleMetadata.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down

0 comments on commit 510acb8

Please sign in to comment.