From fd3b8d220719347723c03b455bb742d426a7822e Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Tue, 5 Jul 2022 09:02:50 -0700 Subject: [PATCH] Enable verify-samples to handle multiple service directories (#3793) Co-authored-by: James Suplizio --- .../templates/steps/verify-samples.yml | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/eng/common/pipelines/templates/steps/verify-samples.yml b/eng/common/pipelines/templates/steps/verify-samples.yml index fef0f4ddd..d722cdcfd 100644 --- a/eng/common/pipelines/templates/steps/verify-samples.yml +++ b/eng/common/pipelines/templates/steps/verify-samples.yml @@ -1,15 +1,25 @@ parameters: - name: ServiceDirectory type: string - default: not-specified + default: '' + - name: ServiceDirectories + type: string + default: '' - name: ScriptDirectory type: string default: eng/common/scripts steps: - pwsh: | - # If the last path segment is an absolute path it will be used entirely. - $root = [System.IO.Path]::Combine('$(Build.SourcesDirectory)', 'sdk', '${{ parameters.ServiceDirectory }}') - Get-ChildItem $root -Filter *.md -Recurse | ${{ parameters.ScriptDirectory }}/Test-SampleMetadata.ps1 -AllowParentProducts + # Take whichever parameter has been set. If set, ServiceDirectory will be a single path or + # ServiceDirectories will be a comma separated list. + $ServiceDirectories = '${{ coalesce(parameters.ServiceDirectory, parameters.ServiceDirectories) }}' + $ScanPaths = @() + foreach ($ServiceDirectory in $ServiceDirectories.Split(',')) { + $ScanPath = [System.IO.Path]::Combine('$(Build.SourcesDirectory)', 'sdk', $ServiceDirectory) + Write-Host "Adding $ScanPath to the scanned paths" + $ScanPaths += $ScanPath + } + Get-ChildItem $ScanPaths -Filter *.md -Recurse | ${{ parameters.ScriptDirectory }}/Test-SampleMetadata.ps1 -AllowParentProducts displayName: Verify sample metadata workingDirectory: $(Build.SourcesDirectory)