Skip to content
Merged
Show file tree
Hide file tree
Changes from 61 commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
300fbe7
Add dev version to Save-Package-Properties.ps1 and includd in build p…
danieljurek May 27, 2021
0ce3ba4
Now with fewer pipelines
danieljurek May 27, 2021
27c1584
Add daily docs.ms work to docindex.yml
danieljurek May 28, 2021
085dee2
Update-DocsMsMetadata and required functions
danieljurek Jun 4, 2021
b4f8b20
Common
danieljurek Jun 4, 2021
e4e7758
Docs meatadata release and daily docs build
danieljurek Jun 4, 2021
91ebcaa
eq
danieljurek Jun 4, 2021
7003acd
Loop over artifacts in paramaters.Artifacts
danieljurek Jun 4, 2021
922cc5e
Add PackageInfo to path
danieljurek Jun 4, 2021
98c861f
download: current
danieljurek Jun 7, 2021
ef16a12
Output artifacts
danieljurek Jun 7, 2021
0095868
Pool
danieljurek Jun 7, 2021
8ff7607
Use relative paths in package properties json file and use dev versio…
danieljurek Jun 8, 2021
9da3bb3
Skip checking out docs repo if it's already checked out
danieljurek Jun 8, 2021
e2621cc
Don't overcomplicate docs-metadata-release.yml
danieljurek Jun 8, 2021
b00629f
With parameters properly defined and redundant logic removed
danieljurek Jun 8, 2021
58f8600
Use TargetBranchName
danieljurek Jun 8, 2021
8c33ab7
Retain original version to differentiate where metadata and readme do…
danieljurek Jun 8, 2021
dd23cf7
Add docs repo support for GetDocsMetadata: first cut
danieljurek Jun 8, 2021
470c513
Sparse checkout needs to include metadata
danieljurek Jun 8, 2021
883168e
Add metadata from packages that aren't tracked in the CSV file yet
danieljurek Jun 9, 2021
de4d311
Use "dev" if the package has a "dev" version in JS. This will not wor…
danieljurek Jun 9, 2021
87e8e91
Refactor and use sparse checkout everywhere
danieljurek Jun 10, 2021
c7c8775
Refactor long path support
danieljurek Jun 10, 2021
01b6242
Correct path
danieljurek Jun 10, 2021
1d75a0a
Parameter names
danieljurek Jun 10, 2021
7a9d3a8
Remove unnecessary parameter
danieljurek Jun 10, 2021
e0a2a9b
Close quote
danieljurek Jun 10, 2021
d67ae0a
Add pipeline starting
danieljurek Jun 15, 2021
f7ac5f7
Keep the single quotes
danieljurek Jun 15, 2021
f691c23
Output link to CI build
danieljurek Jun 15, 2021
93f617e
Refactor:
danieljurek Jun 15, 2021
733eaf8
Apply suggestions from code review
danieljurek Jun 16, 2021
f9314e9
Review feedback: Save-Package-Properties.ps1
danieljurek Jun 21, 2021
3e5a09b
Add ability to specify variable name for default branch
danieljurek Jun 21, 2021
9b98ef7
Try convertToJson
danieljurek Jun 21, 2021
f831a49
Tab scope
danieljurek Jun 21, 2021
ac1fb20
Do doc artifact info loop in Update-DocsMsMetadata.ps1 instead of yam…
danieljurek Jun 21, 2021
6b174e5
Single quotes
danieljurek Jun 21, 2021
75f6e81
Remove template loop
danieljurek Jun 21, 2021
4db6e89
Remove extra template references
danieljurek Jun 21, 2021
8124235
Move convertToJson
danieljurek Jun 21, 2021
50349d8
Try different formatting given convertToJson
danieljurek Jun 21, 2021
7f0f8b9
Reverse Update-DocsMsMetadata.ps1 to operate on a single object. Loop…
danieljurek Jun 21, 2021
969c0dd
Loop in yaml, Rename Update-DocsMsMetadata parameter
danieljurek Jun 21, 2021
f85ebce
Try re-formatting yaml
danieljurek Jun 21, 2021
01a1c34
Spell parameters properly
danieljurek Jun 21, 2021
64c69a8
Missing backtick
danieljurek Jun 21, 2021
edd9215
Remove extra logging
danieljurek Jun 21, 2021
c12283a
First cut at default implementation
danieljurek Jun 21, 2021
05dfffb
Move business logic inside Update-DocsMsMetadata.ps1, PowerShell can …
danieljurek Jun 22, 2021
d8bcc2a
Use proper function name
danieljurek Jun 23, 2021
8ea8dab
PackageProps has a DevVersion
danieljurek Jun 23, 2021
8ea7c19
No DefaultImplementation in this change. This should be part of a wid…
danieljurek Jun 28, 2021
e14e5a5
Straggling master -> main rename
danieljurek Jun 28, 2021
0cada0d
Merge branch 'main' into djurek/daily-ref-docs-2
danieljurek Jun 28, 2021
4b940d4
Use existing devops starting logic
danieljurek Jun 28, 2021
0d9a9df
Remove extra condition
danieljurek Jun 28, 2021
b2103a2
Fix backslashes
danieljurek Jun 28, 2021
44b6ebc
Correct number of backslashes
danieljurek Jun 28, 2021
428f8d5
Use variable for branch name
danieljurek Jun 28, 2021
44754a2
Update eng/scripts/Language-Settings.ps1
danieljurek Jun 29, 2021
cd44528
Review feedback
danieljurek Jun 29, 2021
abcea10
Do not replace the default branch with the tag in links when doing a …
danieljurek Jun 29, 2021
b054eb3
Conditions on docs version for template project
danieljurek Jun 29, 2021
2871f74
Do not run PublishDocsToNightlyBranch if TestPipeline is true
danieljurek Jun 29, 2021
581e30d
Merge branch 'main' into djurek/daily-ref-docs-2
danieljurek Jun 30, 2021
0067a24
Merge branch 'main' into djurek/daily-ref-docs-2
danieljurek Jun 30, 2021
3f909d6
Performance improvements, switch to Linux to take advantage of paths …
danieljurek Jun 30, 2021
c770216
Add markdown files to sparse checkout
danieljurek Jun 30, 2021
8f707a9
Reproduce failure for template publishing
danieljurek Jun 30, 2021
a16c00e
Remove eng, it's already there by default
danieljurek Jul 1, 2021
2e03f12
Fix instances where metadata might not be available because of filter…
danieljurek Jul 1, 2021
57dd780
Merge branch 'main' into djurek/daily-ref-docs-2
danieljurek Jul 1, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions eng/common/pipelines/templates/steps/enable-long-path-support.yml
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
parameters:
- name: DailyBranchVariableName
Comment thread
danieljurek marked this conversation as resolved.
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 }})
5 changes: 3 additions & 2 deletions eng/common/pipelines/templates/steps/set-default-branch.yml
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 eng/common/pipelines/templates/steps/update-docsms-metadata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
parameters:
- name: Artifacts
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
Comment thread
weshaggard marked this conversation as resolved.

- 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) {
Comment thread
danieljurek marked this conversation as resolved.
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)
Comment thread
danieljurek marked this conversation as resolved.
DefaultBranchVariableName: TargetBranchName

- pwsh: |
$artifactInfoJson = '${{ convertToJson(parameters.Artifacts) }}'.Trim('"')
$artifactInfo = ConvertFrom-Json $artifactInfoJson
${{ parameters.ScriptDirectory }}/Update-DocsMsMetadata.ps1 `
-PackageInfoJsonLocations $artifactInfo `
Comment thread
danieljurek marked this conversation as resolved.
Outdated
-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 }}
7 changes: 5 additions & 2 deletions eng/common/scripts/Invoke-DevOpsAPI.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,17 @@ function Start-DevOpsBuild {
$DefinitionId,
[ValidateNotNullOrEmpty()]
[Parameter(Mandatory = $true)]
$Base64EncodedAuthToken
$Base64EncodedAuthToken,
[Parameter(Mandatory = $false)]
[string]$BuildParametersJson
)

$uri = "$DevOpsAPIBaseURI" -F $Organization, $Project , "build" , "builds", ""

$parameters = @{
sourceBranch = $SourceBranch
definition = @{ id = $DefinitionId }
parameters = $BuildParametersJson
}

return Invoke-RestMethod `
Expand Down Expand Up @@ -157,4 +160,4 @@ function Add-RetentionLease {
-MaximumRetryCount 3 `
-ContentType "application/json"

}
}
1 change: 1 addition & 0 deletions eng/common/scripts/Package-Properties.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class PackageProps
{
[string]$Name
[string]$Version
[string]$DevVersion
[string]$DirectoryPath
[string]$ServiceDirectory
[string]$ReadMePath
Expand Down
15 changes: 12 additions & 3 deletions eng/common/scripts/Queue-Pipeline.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ param(
[string]$VsoQueuedPipelines,

[Parameter(Mandatory = $true)]
[string]$Base64EncodedAuthToken
[string]$Base64EncodedAuthToken,

[Parameter(Mandatory = $false)]
[string]$BuildParametersJson
)

. (Join-Path $PSScriptRoot common.ps1)
Expand Down Expand Up @@ -46,7 +49,13 @@ if ($CancelPreviousBuilds)
}

try {
$resp = Start-DevOpsBuild -SourceBranch $SourceBranch -DefinitionId $DefinitionId -Base64EncodedAuthToken $Base64EncodedAuthToken
$resp = Start-DevOpsBuild `
-Organization $Organization `
-Project $Project `
-SourceBranch $SourceBranch `
-DefinitionId $DefinitionId `
-Base64EncodedAuthToken $Base64EncodedAuthToken `
-BuildParametersJson $BuildParametersJson
}
catch {
LogError "Start-DevOpsBuild failed with exception:`n$_"
Expand All @@ -64,4 +73,4 @@ if ($VsoQueuedPipelines) {
}
$QueuedPipelineLinks
Write-Host "##vso[task.setvariable variable=$VsoQueuedPipelines]$QueuedPipelineLinks"
}
}
70 changes: 66 additions & 4 deletions eng/common/scripts/Save-Package-Properties.ps1
Original file line number Diff line number Diff line change
@@ -1,12 +1,75 @@
<#
.SYNOPSIS
Saves package properties from source into JSON files

.DESCRIPTION
Saves package properties in source of a given service directory to JSON files.
JSON files are named in the form <package name>.json or <artifact name>.json if
an artifact name property is available in the package properties.

Can optionally add a dev version property which can be used logic for daily
builds.

.PARAMETER serviceDirectory
Service directory in which to search for packages

.PARAMETER outDirectory
Output location (generally a package artifact directory in DevOps) for JSON
files

.PARAMETER addDevVersion
Reads the version out of the source and adds a DevVersion property to the
package properties JSON file. If the package properties JSON file already
exists, read the Version property from the existing package properties JSON file
and set that as the Version property for the new output. This has the effect of
"adding" a DevVersion property to the file which could be different from the
Verison property in that file.
#>

[CmdletBinding()]
Param (
[Parameter(Mandatory=$True)]
[string] $serviceDirectory,
[Parameter(Mandatory=$True)]
[string] $outDirectory
[string] $outDirectory,
[switch] $addDevVersion
)

. (Join-Path $PSScriptRoot common.ps1)

function SetOutput($outputPath, $incomingPackageSpec) {
$outputObject = $incomingPackageSpec

if ($addDevVersion) {
# Use the "Version" property which was provided by the incoming package spec
# as the DevVersion. This may be overridden later.
$outputObject.DevVersion = $incomingPackageSpec.Version

# If there is an exsiting package info json file read that and set the
# Version property from that JSON file.
if (Test-Path $outputPath) {
$originalObject = ConvertFrom-Json (Get-Content $outputPath -Raw)
$outputObject.Version = $originalObject.Version
}
}

# Set file paths to relative paths
$outputObject.DirectoryPath = GetRelativePath $outputObject.DirectoryPath
$outputObject.ReadMePath = GetRelativePath $outputObject.ReadMePath
$outputObject.ChangeLogPath = GetRelativePath $outputObject.ChangeLogPath

Set-Content `
-Path $outputPath `
-Value (ConvertTo-Json -InputObject $outputObject -Depth 100)
}

function GetRelativePath($path) {
$relativeTo = Resolve-Path $PSScriptRoot/../../../
# Replace "\" with "/" so the path is valid across other platforms and tools
$relativePath = [IO.Path]::GetRelativePath($relativeTo, $path) -replace "\\", '/'
return $relativePath
}

$allPackageProperties = Get-AllPkgProperties $serviceDirectory
if ($allPackageProperties)
{
Expand All @@ -29,9 +92,8 @@ if ($allPackageProperties)
$configFilePrefix = $pkg.ArtifactName
}
$outputPath = Join-Path -Path $outDirectory "$configFilePrefix.json"
$outputObject = $pkg | ConvertTo-Json
Set-Content -Path $outputPath -Value $outputObject
}
SetOutput $outputPath $pkg
}
}

Get-ChildItem -Path $outDirectory
Expand Down
Loading