From 87a4b2e591b50337a7a2d2c876ec7eecf3c8123d Mon Sep 17 00:00:00 2001 From: Heath Stewart Date: Wed, 14 Apr 2021 18:28:37 -0700 Subject: [PATCH 1/4] Handle empty files in Test-SampleMetadata Relates to Azure/azure-sdk-for-java#20684 --- eng/common/scripts/Test-SampleMetadata.ps1 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/eng/common/scripts/Test-SampleMetadata.ps1 b/eng/common/scripts/Test-SampleMetadata.ps1 index cd74690ca..523aeb31d 100644 --- a/eng/common/scripts/Test-SampleMetadata.ps1 +++ b/eng/common/scripts/Test-SampleMetadata.ps1 @@ -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() From b760e2ec3ee0b066e5b1e32f880154149ef8ea33 Mon Sep 17 00:00:00 2001 From: Heath Stewart Date: Wed, 14 Apr 2021 18:38:31 -0700 Subject: [PATCH 2/4] Remove condition from verify-samples --- eng/common/pipelines/templates/steps/verify-samples.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/eng/common/pipelines/templates/steps/verify-samples.yml b/eng/common/pipelines/templates/steps/verify-samples.yml index fcd87d2cc..05844393c 100644 --- a/eng/common/pipelines/templates/steps/verify-samples.yml +++ b/eng/common/pipelines/templates/steps/verify-samples.yml @@ -5,9 +5,6 @@ parameters: - name: ScriptDirectory type: string default: eng/common/scripts - - name: Condition - type: boolean - default: succeeded() steps: - pwsh: | @@ -16,4 +13,3 @@ steps: Get-ChildItem $root -Filter *.md -Recurse | ${{ parameters.ScriptDirectory }}\Test-SampleMetadata.ps1 -AllowParentProducts displayName: Verify sample metadata workingDirectory: $(Build.SourcesDirectory) - condition: ${{ parameters.Condition }} From 70fbb3dbc7908cc50479da0d82f630196de1d4b9 Mon Sep 17 00:00:00 2001 From: Heath Stewart Date: Wed, 14 Apr 2021 19:02:41 -0700 Subject: [PATCH 3/4] Use forward slash in path --- eng/common/pipelines/templates/steps/verify-samples.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/common/pipelines/templates/steps/verify-samples.yml b/eng/common/pipelines/templates/steps/verify-samples.yml index 05844393c..78d1b8521 100644 --- a/eng/common/pipelines/templates/steps/verify-samples.yml +++ b/eng/common/pipelines/templates/steps/verify-samples.yml @@ -10,6 +10,6 @@ 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 + Get-ChildItem $root -Filter *.md -Recurse | ${{ parameters.ScriptDirectory }}/Test-SampleMetadata.ps1 -AllowParentProducts displayName: Verify sample metadata workingDirectory: $(Build.SourcesDirectory) From f5c8b585bea8666d590bf9c0e7ee96e9d9bb4b4f Mon Sep 17 00:00:00 2001 From: Heath Stewart Date: Wed, 14 Apr 2021 19:20:48 -0700 Subject: [PATCH 4/4] Fix directory typo --- eng/common/pipelines/templates/steps/verify-samples.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/common/pipelines/templates/steps/verify-samples.yml b/eng/common/pipelines/templates/steps/verify-samples.yml index 78d1b8521..fef0f4ddd 100644 --- a/eng/common/pipelines/templates/steps/verify-samples.yml +++ b/eng/common/pipelines/templates/steps/verify-samples.yml @@ -9,7 +9,7 @@ parameters: 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 }}') + $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)