-
Notifications
You must be signed in to change notification settings - Fork 234
Sparse checkout docs repository in release step #1585
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,24 +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 | ||
| - 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: | | ||
|
|
@@ -30,14 +71,25 @@ 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 | ||
|
|
||
| - ${{ if not(parameters.SparseCheckoutPaths) }}: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I definitely like this approach better as it should allow both scenarios to work. It might actually be interesting make this an option in the sparse-checkout template itself if we find more patterns like this.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah you mean perhaps replacing all our checkouts with calls to some checkout template, and we can have a parameter like
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes having this split of full vs sparse clone might be a future improvement to consider. |
||
| - 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: | ||
| WorkingDirectory: ${{ parameters.WorkingDirectory }}/repo | ||
| WorkingDirectory: ${{ parameters.WorkingDirectory }}/repo | ||
| - task: PowerShell@2 | ||
| displayName: 'Apply Documentation Updates From Artifact' | ||
| inputs: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How does it pick-up the default branch? Are you sure git checkout without parameters checks out the default branch? As best I can tell it will be a noop.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From my testing (local and in-pipeline), it does. According to the docs:
Since we're in a state where sparse checkout paths are set but no blobs are downloaded, this seems to have the effect of grabbing all the relevant blobs. I could switch it back to using the regex that we're using elsewhere, but as this seems to work I thought it was much cleaner.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this works than great. If not I was think we could use the default branch template and the $(DefaultBranch) variable in this place.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I actually only discovered this because I copied that DefaultBranch code over and forgot to change the remote from |
||
| displayName: Sparse checkout at ${{ coalesce(repo.Commitish, 'default branch') }} | ||
| workingDirectory: ${{ coalesce(repo.WorkingDirectory, format('{0}/{1}', '$(System.DefaultWorkingDirectory)', repo.Name)) }} | ||
Uh oh!
There was an error while loading. Please reload this page.