Skip to content
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

Support moniker specific folders for readmes (and incoming service overviews) #1233

Merged
5 commits merged into from
Dec 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ steps:
-WorkDirectory "${{ parameters.WorkingDirectory }}"
-DocRepoLocation "${{ parameters.WorkingDirectory }}/repo"
-Language "${{parameters.Language}}"
-DocRepoContentLocation ${{ parameters.DocRepoDestinationPath }}
-Configs "${{ parameters.CIConfigs }}"
scbedd marked this conversation as resolved.
Show resolved Hide resolved
pwsh: true
env:
GH_TOKEN: $(azuresdk-github-pat)
Expand All @@ -65,7 +65,7 @@ steps:
-RepoId ${{ parameters.RepoId }}
-Repository ${{ parameters.PackageRepository }}
-ReleaseSHA ${{ parameters.ReleaseSha }}
-CIRepository "${{ parameters.WorkingDirectory }}/repo"
-DocRepoLocation "${{ parameters.WorkingDirectory }}/repo"
-Configs "${{ parameters.CIConfigs }}"
pwsh: true
env:
Expand Down Expand Up @@ -107,7 +107,7 @@ steps:
-RepoId ${{ parameters.RepoId }}
-Repository ${{ parameters.PackageRepository }}
-ReleaseSHA ${{ parameters.ReleaseSha }}
-CIRepository "${{ parameters.WorkingDirectory }}/repo"
-DocRepoLocation "${{ parameters.WorkingDirectory }}/repo"
-Configs "${{ parameters.CIConfigs }}"
pwsh: true
env:
Expand Down
11 changes: 6 additions & 5 deletions eng/common/scripts/update-docs-ci.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ param (
$Repository, # EG: "Maven", "PyPI", "NPM"

[Parameter(Mandatory = $true)]
$CIRepository,
$DocRepoLocation, # the location of the cloned doc repo

[Parameter(Mandatory = $true)]
$Configs
$Configs # The configuration elements informing important locations within the cloned doc repo
)

. (Join-Path $PSScriptRoot common.ps1)
Expand All @@ -37,7 +37,8 @@ $targets = ($Configs | ConvertFrom-Json).targets
#{
# path_to_config:
# mode:
# monikerid
# monikerid:
# content_folder:
#}

$apiUrl = "https://api.github.com/repos/$repoId"
Expand All @@ -50,13 +51,13 @@ foreach ($config in $targets) {
if ($config.mode -eq "Preview") { $includePreview = $true } else { $includePreview = $false }
$pkgsFiltered = $pkgs | ? { $_.IsPrerelease -eq $includePreview}

if ($pkgs) {
if ($pkgsFiltered) {
Write-Host "Given the visible artifacts, CI updates against $($config.path_to_config) will be processed for the following packages."
Write-Host ($pkgsFiltered | % { $_.PackageId + " " + $_.PackageVersion })

if ($UpdateDocCIFn -and (Test-Path "Function:$UpdateDocCIFn"))
{
&$UpdateDocCIFn -pkgs $pkgsFiltered -ciRepo $CIRepository -locationInDocRepo $config.path_to_config -monikerId $config.monikerid
&$UpdateDocCIFn -pkgs $pkgsFiltered -ciRepo $DocRepoLocation -locationInDocRepo $config.path_to_config -monikerId $config.monikerid
}
else
{
Expand Down
83 changes: 51 additions & 32 deletions eng/common/scripts/update-docs-metadata.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,24 @@
# powershell core is a requirement for successful execution.
param (
# arguments leveraged to parse and identify artifacts
[Parameter(Mandatory = $true)]
$ArtifactLocation, # the root of the artifact folder. DevOps $(System.ArtifactsDirectory)
[Parameter(Mandatory = $true)]
$WorkDirectory, # a clean folder that we can work in
[Parameter(Mandatory = $true)]
$ReleaseSHA, # the SHA for the artifacts. DevOps: $(Release.Artifacts.<artifactAlias>.SourceVersion) or $(Build.SourceVersion)
[Parameter(Mandatory = $true)]
$RepoId, # full repo id. EG azure/azure-sdk-for-net DevOps: $(Build.Repository.Id). Used as a part of VerifyPackages
[Parameter(Mandatory = $true)]
$Repository, # EG: "Maven", "PyPI", "NPM"

# arguments necessary to power the docs release
[Parameter(Mandatory = $true)]
$DocRepoLocation, # the location on disk where we have cloned the documentation repository
[Parameter(Mandatory = $true)]
$Language, # EG: js, java, dotnet. Used in language for the embedded readme.
$DocRepoContentLocation = "docs-ref-services/" # within the doc repo, where does our readme go?
[Parameter(Mandatory = $true)]
$Configs # The configuration elements informing important locations within the cloned doc repo
)

. (Join-Path $PSScriptRoot common.ps1)
Expand Down Expand Up @@ -80,41 +88,52 @@ $pkgs = VerifyPackages -artifactLocation $ArtifactLocation `
-releaseSha $ReleaseSHA `
-continueOnError $True

if ($pkgs) {
Write-Host "Given the visible artifacts, readmes will be copied for the following packages"
Write-Host ($pkgs | % { $_.PackageId })
$targets = ($Configs | ConvertFrom-Json).targets

foreach ($packageInfo in $pkgs) {
# sync the doc repo
$semVer = [AzureEngSemanticVersion]::ParseVersionString($packageInfo.PackageVersion)
$rdSuffix = ""
if ($semVer.IsPreRelease) {
$rdSuffix = "-pre"
}

$readmeName = "$($packageInfo.PackageId.Replace('azure-','').Replace('Azure.', '').Replace('@azure/', '').ToLower())-readme$rdSuffix.md"
$readmeLocation = Join-Path $DocRepoLocation $DocRepoContentLocation $readmeName
foreach ($config in $targets) {
if ($config.mode -eq "Preview") { $includePreview = $true } else { $includePreview = $false }
$pkgsFiltered = $pkgs | ? { $_.IsPrerelease -eq $includePreview}
scbedd marked this conversation as resolved.
Show resolved Hide resolved

if ($packageInfo.ReadmeContent) {
$adjustedContent = GetAdjustedReadmeContent -pkgInfo $packageInfo
}

if ($adjustedContent) {
try {
Push-Location $DocRepoLocation
Set-Content -Path $readmeLocation -Value $adjustedContent -Force
if ($pkgsFiltered) {
Write-Host "Given the visible artifacts, $($config.mode) Readme updates against $($config.path_to_config) will be processed for the following packages."
Write-Host ($pkgsFiltered | % { $_.PackageId + " " + $_.PackageVersion })

foreach ($packageInfo in $pkgsFiltered) {
$readmeName = "$($packageInfo.PackageId.Replace('azure-','').Replace('Azure.', '').Replace('@azure/', '').ToLower())-readme.md"
$readmeFolder = Join-Path $DocRepoLocation $config.content_folder
$readmeLocation = Join-Path $readmeFolder $readmeName

# what happens if this is the first time we've written to this folder? It won't exist. Resolve that.
if(!(Test-Path $readmeFolder)) {
New-Item -ItemType Directory -Force -Path $readmeFolder
}

Write-Host "Updated readme for $readmeName."
} catch {
Write-Host $_
} finally {
Pop-Location
if ($packageInfo.ReadmeContent) {
$adjustedContent = GetAdjustedReadmeContent -pkgInfo $packageInfo
}

if ($adjustedContent) {
try {
Push-Location $DocRepoLocation
Set-Content -Path $readmeLocation -Value $adjustedContent -Force

Write-Host "Updated readme for $readmeName."
} catch {
Write-Host $_
} finally {
Pop-Location
}
} else {
Write-Host "Unable to parse a header out of the readmecontent for PackageId $($packageInfo.PackageId)"
}
} else {
Write-Host "Unable to parse a header out of the readmecontent for PackageId $($packageInfo.PackageId)"
}
}
else {
Write-Host "No readmes discovered for $($config.mode) doc release under folder $ArtifactLocation."
}


}
else {
Write-Host "No readmes discovered for doc release under folder $ArtifactLocation."
}