From ddeda27a3e10e4d65bd0686923e68d4c28600e16 Mon Sep 17 00:00:00 2001 From: Ben Broderick Phillips Date: Mon, 3 May 2021 22:22:41 -0400 Subject: [PATCH 1/3] Sparse checkout docs repository in release step --- .../templates/steps/docs-metadata-release.yml | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/eng/common/pipelines/templates/steps/docs-metadata-release.yml b/eng/common/pipelines/templates/steps/docs-metadata-release.yml index 53070e2f91182..19794a523ae70 100644 --- a/eng/common/pipelines/templates/steps/docs-metadata-release.yml +++ b/eng/common/pipelines/templates/steps/docs-metadata-release.yml @@ -14,11 +14,13 @@ parameters: Language: '' DocRepoDestinationPath: '' #usually docs-ref-services/ CIConfigs: '[]' - GHReviewersVariable: '' + GHReviewersVariable: '' GHTeamReviewersVariable: '' # externally set, as eng-common does not have the identity-resolver. Run as pre-step OnboardingBranch: '' CloseAfterOpenForTesting: false SkipPackageJson: false + Paths: + - '/*' steps: - pwsh: | @@ -30,14 +32,19 @@ steps: Write-Host "This script is not executing on Windows, skipping registry modification." } displayName: Enable Long Paths if Necessary - -- pwsh: | - git clone https://github.com/${{ parameters.TargetDocRepoOwner }}/${{ parameters.TargetDocRepoName }} ${{ parameters.WorkingDirectory }}/repo - displayName: Clone Documentation Repository - ignoreLASTEXITCODE: false + +- template: /eng/common/pipelines/templates/steps/sparse-checkout.yml + parameters: + SkipDefaultCheckout: true + Repositories: + - Name: ${{ parameters.TargetDocRepoOwner }}/${{ parameters.TargetDocRepoName }} + Commitish: master + WorkingDirectory: ${{ parameters.WorkingDirectory }}/repo + Paths: ${{ parameters.Paths }} + - template: /eng/common/pipelines/templates/steps/set-default-branch.yml parameters: - WorkingDirectory: ${{ parameters.WorkingDirectory }}/repo + WorkingDirectory: ${{ parameters.WorkingDirectory }}/repo - task: PowerShell@2 displayName: 'Apply Documentation Updates From Artifact' inputs: From 328e90f8e835d55952025ca15141d0b88c04634c Mon Sep 17 00:00:00 2001 From: Ben Broderick Phillips Date: Wed, 5 May 2021 01:17:10 -0400 Subject: [PATCH 2/3] Detect default branch for custom sparse checkout repository --- eng/common/pipelines/templates/steps/sparse-checkout.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/eng/common/pipelines/templates/steps/sparse-checkout.yml b/eng/common/pipelines/templates/steps/sparse-checkout.yml index cf81555d775d2..f98cd6060560f 100644 --- a/eng/common/pipelines/templates/steps/sparse-checkout.yml +++ b/eng/common/pipelines/templates/steps/sparse-checkout.yml @@ -32,6 +32,7 @@ steps: displayName: Init sparse checkout ${{ repo.Name }} workingDirectory: ${{ coalesce(repo.WorkingDirectory, format('{0}/{1}', '$(System.DefaultWorkingDirectory)', repo.Name)) }} - - pwsh: git checkout ${{ repo.Commitish }} - displayName: Sparse checkout at ${{ repo.Commitish }} + - pwsh: | + git checkout ${{ repo.Commitish }} # this will use the default branch if repo.Commitish is empty + displayName: Sparse checkout at ${{ coalesce(repo.Commitish, 'default branch') }} workingDirectory: ${{ coalesce(repo.WorkingDirectory, format('{0}/{1}', '$(System.DefaultWorkingDirectory)', repo.Name)) }} From 61c55d1f68ea7fe042cce45a7aa49657db74b732 Mon Sep 17 00:00:00 2001 From: Ben Broderick Phillips Date: Wed, 5 May 2021 01:17:27 -0400 Subject: [PATCH 3/3] Use sparse checkout paths parameter in docs metadata release --- .../templates/steps/docs-metadata-release.yml | 103 +++++++++++++----- 1 file changed, 74 insertions(+), 29 deletions(-) diff --git a/eng/common/pipelines/templates/steps/docs-metadata-release.yml b/eng/common/pipelines/templates/steps/docs-metadata-release.yml index 19794a523ae70..b3c844422585a 100644 --- a/eng/common/pipelines/templates/steps/docs-metadata-release.yml +++ b/eng/common/pipelines/templates/steps/docs-metadata-release.yml @@ -1,26 +1,65 @@ # intended to be used as part of a release process parameters: - ArtifactLocation: 'not-specified' - PackageRepository: 'not-specified' - ReleaseSha: 'not-specified' - RepoId: $(Build.Repository.Name) - WorkingDirectory: '' - ScriptDirectory: eng/common/scripts - TargetDocRepoName: '' - TargetDocRepoOwner: '' - PRBranchName: 'master-rdme' - PRLabels: 'auto-merge' - ArtifactName: '' - Language: '' - DocRepoDestinationPath: '' #usually docs-ref-services/ - CIConfigs: '[]' - GHReviewersVariable: '' - GHTeamReviewersVariable: '' # externally set, as eng-common does not have the identity-resolver. Run as pre-step - OnboardingBranch: '' - CloseAfterOpenForTesting: false - SkipPackageJson: false - Paths: - - '/*' + - name: ArtifactLocation + type: string + default: 'not-specified' + - name: PackageRepository + type: string + default: 'not-specified' + - name: ReleaseSha + type: string + default: 'not-specified' + - name: RepoId + type: string + default: $(Build.Repository.Name) + - name: WorkingDirectory + type: string + default: '' + - name: ScriptDirectory + type: string + default: eng/common/scripts + - name: TargetDocRepoName + type: string + default: '' + - name: TargetDocRepoOwner + type: string + default: '' + - name: PRBranchName + type: string + default: 'master-rdme' + - name: PRLabels + type: string + default: 'auto-merge' + - name: ArtifactName + type: string + default: '' + - name: Language + type: string + default: '' + - name: DocRepoDestinationPath + type: string + default: '' #usually docs-ref-services/ + - name: CIConfigs + type: string + default: '[]' + - name: GHReviewersVariable + type: string + default: '' + - name: GHTeamReviewersVariable + type: string + default: '' # externally set, as eng-common does not have the identity-resolver. Run as pre-step + - name: OnboardingBranch + type: string + default: '' + - name: CloseAfterOpenForTesting + type: boolean + default: false + - name: SkipPackageJson + type: object + default: false + - name: SparseCheckoutPaths + type: object + default: null steps: - pwsh: | @@ -33,14 +72,20 @@ steps: } displayName: Enable Long Paths if Necessary -- template: /eng/common/pipelines/templates/steps/sparse-checkout.yml - parameters: - SkipDefaultCheckout: true - Repositories: - - Name: ${{ parameters.TargetDocRepoOwner }}/${{ parameters.TargetDocRepoName }} - Commitish: master - WorkingDirectory: ${{ parameters.WorkingDirectory }}/repo - Paths: ${{ parameters.Paths }} +- ${{ if not(parameters.SparseCheckoutPaths) }}: + - pwsh: | + git clone https://github.com/${{ parameters.TargetDocRepoOwner }}/${{ parameters.TargetDocRepoName }} ${{ parameters.WorkingDirectory }}/repo + displayName: Clone Documentation Repository + ignoreLASTEXITCODE: false + +- ${{ if parameters.SparseCheckoutPaths }}: + - template: /eng/common/pipelines/templates/steps/sparse-checkout.yml + parameters: + SkipDefaultCheckout: true + Repositories: + - Name: ${{ parameters.TargetDocRepoOwner }}/${{ parameters.TargetDocRepoName }} + WorkingDirectory: ${{ parameters.WorkingDirectory }}/repo + Paths: ${{ parameters.SparseCheckoutPaths }} - template: /eng/common/pipelines/templates/steps/set-default-branch.yml parameters: