-
Notifications
You must be signed in to change notification settings - Fork 226
eng/common changes for docs metadata release #1725
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ef6d86f
Bring changes from JS docs metadata
danieljurek ed81079
Move business logic inside Update-DocsMsMetadata.ps1
danieljurek f9f57b7
Update with the latest changes in JS PR
danieljurek 09a6afc
Update from latest PR feedback
danieljurek 44526d9
Add check for empty path to prevent crashes when creating relative paths
danieljurek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
eng/common/pipelines/templates/steps/enable-long-path-support.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| steps: | ||
| - pwsh: | | ||
| if ($IsWindows) { | ||
| REG ADD HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem /f /v LongPathsEnabled /t REG_DWORD /d 1 | ||
| git config --system core.longpaths true | ||
| } | ||
| else { | ||
| Write-Host "This script is not executing on Windows, skipping registry modification." | ||
| } | ||
| displayName: Enable long path support if necessary |
14 changes: 14 additions & 0 deletions
14
eng/common/pipelines/templates/steps/set-daily-docs-branch-name.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| parameters: | ||
| - name: DailyBranchVariableName | ||
| type: string | ||
| default: TargetBranchName | ||
|
|
||
| steps: | ||
| - pwsh: | | ||
| $branchName = $env:DAILYDOCSBRANCHNAMEOVERRIDE | ||
| if (!$branchName) { | ||
| $branchName = "daily/$(Get-Date -Format 'yyyy-MM-dd')" | ||
| } | ||
| Write-Host "Daily Branch Name: $branchName" | ||
| Write-Host "##vso[task.setvariable variable=${{ parameters.DailyBranchVariableName }};]$branchName" | ||
| displayName: Set daily docs branch name in $(${{ parameters.DailyBranchVariableName }}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,16 @@ | ||
| parameters: | ||
| WorkingDirectory: '$(System.DefaultWorkingDirectory)' | ||
| RemoteRepo: 'origin' | ||
| DefaultBranchVariableName: DefaultBranch | ||
| steps: | ||
| - pwsh: | | ||
| $setDefaultBranch = (git remote show ${{ parameters.RemoteRepo }} | Out-String) -replace "(?ms).*HEAD branch: (\w+).*", '$1' | ||
| if ($LASTEXITCODE -ne 0) { | ||
| Write-Host "Not able to fetch the default branch from git command. Set to main." | ||
| $setDefaultBranch = 'main' | ||
| } | ||
| Write-Host "Setting DefaultBranch=$setDefaultBranch" | ||
| Write-Host "##vso[task.setvariable variable=DefaultBranch]$setDefaultBranch" | ||
| Write-Host "Setting ${{ parameters.DefaultBranchVariableName }}=$setDefaultBranch" | ||
| Write-Host "##vso[task.setvariable variable=${{ parameters.DefaultBranchVariableName }}]$setDefaultBranch" | ||
| displayName: "Setup Default Branch" | ||
| workingDirectory: ${{ parameters.workingDirectory }} | ||
| ignoreLASTEXITCODE: true |
95 changes: 95 additions & 0 deletions
95
eng/common/pipelines/templates/steps/update-docsms-metadata.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| parameters: | ||
| - name: PackageInfoLocations | ||
| type: object | ||
| default: [] | ||
| - 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 | ||
| - name: Language | ||
| type: string | ||
| default: '' | ||
| - name: DailyDocsBuild | ||
| type: boolean | ||
| default: false | ||
| - name: SparseCheckoutPaths | ||
| type: object | ||
| default: | ||
| - '**' | ||
|
|
||
| steps: | ||
| - template: /eng/common/pipelines/templates/steps/enable-long-path-support.yml | ||
|
|
||
| - pwsh: | | ||
| Write-Host "###vso[task.setvariable variable=DocRepoLocation]${{ parameters.WorkingDirectory }}/doc" | ||
| displayName: Set $(DocRepoLocation) | ||
|
|
||
| - template: /eng/common/pipelines/templates/steps/sparse-checkout.yml | ||
| parameters: | ||
| SkipDefaultCheckout: true | ||
| Repositories: | ||
| - Name: ${{ parameters.TargetDocRepoOwner }}/${{ parameters.TargetDocRepoName }} | ||
| WorkingDirectory: $(DocRepoLocation) | ||
| Paths: ${{ parameters.SparseCheckoutPaths }} | ||
|
|
||
| # If performing a daily docs build set the $(TargetBranchName) to a daily branch | ||
| # name and attempt to checkout the daily docs branch. If the branch doesn't | ||
| # exist, create it | ||
| - ${{ if eq(parameters.DailyDocsBuild, 'true') }}: | ||
| - template: /eng/common/pipelines/templates/steps/set-daily-docs-branch-name.yml | ||
|
|
||
| - pwsh: | | ||
| $ErrorActionPreference = "Continue" | ||
| $RemoteName = "origin" | ||
| $BranchName = "$(TargetBranchName)" | ||
| # Fetch and checkout remote branch if it already exists otherwise create a new branch. | ||
| git ls-remote --exit-code --heads $RemoteName $BranchName | ||
| if ($LASTEXITCODE -eq 0) { | ||
| Write-Host "git fetch $RemoteName $BranchName" | ||
| git fetch $RemoteName $BranchName | ||
| Write-Host "git checkout $BranchName." | ||
| git checkout $BranchName | ||
| } else { | ||
| Write-Host "git checkout -b $BranchName." | ||
| git checkout -b $BranchName | ||
| } | ||
| displayName: Checkout daily docs branch if it exists | ||
| workingDirectory: $(DocRepoLocation) | ||
|
|
||
| # If NOT performing a daily docs build, set the $(TargetBranchName) to the | ||
| # default branch of the documentation repository. | ||
| - ${{ if ne(parameters.DailyDocsBuild, 'true') }}: | ||
| - template: /eng/common/pipelines/templates/steps/set-default-branch.yml | ||
| parameters: | ||
| WorkingDirectory: $(DocRepoLocation) | ||
| DefaultBranchVariableName: TargetBranchName | ||
|
|
||
| - pwsh: | | ||
| $packageInfoJson = '${{ convertToJson(parameters.PackageInfoLocations) }}'.Trim('"') | ||
| $packageInfoLocations = ConvertFrom-Json $packageInfoJson | ||
| ${{ parameters.ScriptDirectory }}/Update-DocsMsMetadata.ps1 ` | ||
| -PackageInfoJsonLocations $packageInfoLocations ` | ||
| -DocRepoLocation "$(DocRepoLocation)" ` | ||
| -Language '${{parameters.Language}}' ` | ||
| -RepoId '${{ parameters.RepoId }}' | ||
| displayName: Apply Documentation Updates | ||
|
|
||
| - template: /eng/common/pipelines/templates/steps/git-push-changes.yml | ||
| parameters: | ||
| BaseRepoBranch: $(TargetBranchName) | ||
| BaseRepoOwner: ${{ parameters.TargetDocRepoOwner }} | ||
| CommitMsg: "Update docs metadata" | ||
| TargetRepoName: ${{ parameters.TargetDocRepoName }} | ||
| TargetRepoOwner: ${{ parameters.TargetDocRepoOwner }} | ||
| WorkingDirectory: $(DocRepoLocation) | ||
| ScriptDirectory: ${{ parameters.WorkingDirectory }}/${{ parameters.ScriptDirectory }} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like you found a good solution. Should I close #1642 ?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've run into this problem in other parts of the codebase. @weshaggard has designs to pull this logic into a yaml template of sorts.
I think valid arguments can be made for including this in sparse-checkout.yml (it's easier to do everything in one template call as opposed to two) or not (call the second template when you need it, don't bloat
sparse-checkout.yml).One deciding factor could be whether we would use this kind of branch-querying logic in a context which does not use sparse checkout.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is what you're suggesting basically a "checkout main and then make new branch" option?
We would also need to consider whether to support this parameter as global to the template and/or specific to each Repositories object.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the case where the branch does not exist, yes, check out
the defaultsome (probably the default) branch and then create the new branch. However the branch may already exist and in that case we want to just check out that branch.