Skip to content

Commit

Permalink
Docs onboarding cleanup (Azure#42042)
Browse files Browse the repository at this point in the history
* Docs onboarding cleanup

* REVERT - enable docs.ms publishing for azure-sdk-template for testing

* Revert "REVERT - enable docs.ms publishing for azure-sdk-template for testing"

This reverts commit 9ac66e5.
  • Loading branch information
danieljurek authored and mssfang committed Oct 21, 2024
1 parent d7afe26 commit 4957384
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 86 deletions.
85 changes: 0 additions & 85 deletions eng/scripts/Language-Settings.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -379,91 +379,6 @@ function Get-java-DocsMsMetadataForPackage($PackageInfo) {
}
}

# Defined in common.ps1 as:
# $ValidateDocsMsPackagesFn = "Validate-${Language}-DocMsPackages"
function Validate-java-DocMsPackages ($PackageInfo, $PackageInfos, $DocValidationImageId) {
# While eng/common/scripts/Update-DocsMsMetadata.ps1 is still passing a single packageInfo, process as a batch
if (!$PackageInfos) {
$PackageInfos = @($PackageInfo)
}

# The install-rex-validation-tool.yml will install the java2docfx jar file into the Build.BinariesDirectory
# which is a DevOps variable for the directory. In PS that variable is BUILD_BINARIESDIRECTORY.
# The reason why this is necessary is that the command for java2docfx is in the following format:
# java –jar java2docfx-1.0.0.jar.jar --packagesJsonFile "C\temp\package.json"
# or
# java –jar java2docfx-1.0.0.jar --package "<GroupId>:<ArtifactId>:<Version>"
# which means we need to know where, exactly, because the java command requires the full path
# to the jar file as an argument
$java2docfxJar = $null
if (!$Env:BUILD_BINARIESDIRECTORY) {
LogError "Env:BUILD_BINARIESDIRECTORY is not set and this is where the java2docfx jar file should be installed."
return $false
}
$java2docfxDir = Join-Path $Env:BUILD_BINARIESDIRECTORY "java2docfx"
if (!(Test-Path $java2docfxDir)) {
LogError "There should be a java2docfx directory under Env:BUILD_BINARIESDIRECTORY. Ensure that the /eng/pipelines/templates/steps/install-rex-validation-tool.yml template was run prior to whatever step is running this."
return $false
}
$java2docfxJarLoc = @(Get-ChildItem -Path $java2docfxDir -File -Filter "java2docfx*.jar")
if (!$java2docfxJarLoc) {
LogError "The java2docfx jar file should be installed in $java2docfxDir and is not there."
return $false
} else {
# In theory, this shouldn't happen as the install-rex-validation-tool.yml is the only thing
# that'll ever install the jar
if ($java2docfxJarLoc.Count -gt 1) {
Write-Host "There were $($java2docfxJarLoc.Count) java2docfx jar files found in $Build_BinariesDirectory, using the first one"
}
$java2docfxJar = $java2docfxJarLoc[0]
Write-Host "java2docfx jar location=$java2docfxJar"
}

$allSuccess = $true
$originLocation = Get-Location
foreach ($packageInfo in $PackageInfos) {
$artifact = "$($packageInfo.Group):$($packageInfo.Name):$($packageInfo.Version)"
$tempDirectory = Join-Path ([System.IO.Path]::GetTempPath()) "$($packageInfo.Group)-$($packageInfo.Name)-$($packageInfo.Version)"
New-Item $tempDirectory -ItemType Directory | Out-Null
# Set the location to the temp directory. The reason being is that it'll effectively be empty, no
# other jars, no POM files aka nothing Java related to pick up.
Set-Location $tempDirectory
try {
Write-Host "Calling java2docfx for $artifact"
Write-Host "java -jar ""$java2docfxJar"" -p ""$artifact"""
$java2docfxResults = java `
-jar "$java2docfxJar"`
-p "$artifact"
# JRS-TODO: The -o option is something I'm currently questioning the behavior of but
# I can do some initial testing without that option being set
# -p "$artifact" `
# -o "$tempDirectory"

if ($LASTEXITCODE -ne 0) {
LogWarning "java2docfx failed for $artifact"
$java2docfxResults | Write-Host
$allSuccess = $false
}
}
catch {
LogError "Exception while trying to download: $artifact"
LogError $_
LogError $_.ScriptStackTrace
$allSuccess = $false
}
finally {
# Ensure that the origianl location is restored
Set-Location $originLocation
# everything is contained within the temp directory, clean it up every time
if (Test-Path $tempDirectory) {
Remove-Item $tempDirectory -Recurse -Force
}
}
}

return $allSuccess
}

function Get-java-EmitterName() {
return "@azure-tools/typespec-java"
}
Expand Down
88 changes: 87 additions & 1 deletion eng/scripts/docs/Docs-Onboarding.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,90 @@ function Get-java-PackageIdentity($package) {
# $GetPackageIdentityFromCsvMetadata = "Get-${Language}-PackageIdentityFromCsvMetadata"
function Get-java-PackageIdentityFromCsvMetadata($package) {
return "$($package.GroupId):$($Package.Package)"
}
}


# Defined in common.ps1 as:
# $ValidateDocsMsPackagesFn = "Validate-${Language}-DocMsPackages"
function Validate-java-DocMsPackages ($PackageInfo, $PackageInfos, $DocValidationImageId) {
# While eng/common/scripts/Update-DocsMsMetadata.ps1 is still passing a single packageInfo, process as a batch
if (!$PackageInfos) {
$PackageInfos = @($PackageInfo)
}

# The install-rex-validation-tool.yml will install the java2docfx jar file into the Build.BinariesDirectory
# which is a DevOps variable for the directory. In PS that variable is BUILD_BINARIESDIRECTORY.
# The reason why this is necessary is that the command for java2docfx is in the following format:
# java –jar java2docfx-1.0.0.jar.jar --packagesJsonFile "C\temp\package.json"
# or
# java –jar java2docfx-1.0.0.jar --package "<GroupId>:<ArtifactId>:<Version>"
# which means we need to know where, exactly, because the java command requires the full path
# to the jar file as an argument
$java2docfxJar = $null
if (!$Env:BUILD_BINARIESDIRECTORY) {
LogError "Env:BUILD_BINARIESDIRECTORY is not set and this is where the java2docfx jar file should be installed."
return $false
}
$java2docfxDir = Join-Path $Env:BUILD_BINARIESDIRECTORY "java2docfx"
if (!(Test-Path $java2docfxDir)) {
LogError "There should be a java2docfx directory under Env:BUILD_BINARIESDIRECTORY. Ensure that the /eng/pipelines/templates/steps/install-rex-validation-tool.yml template was run prior to whatever step is running this."
return $false
}
$java2docfxJarLoc = @(Get-ChildItem -Path $java2docfxDir -File -Filter "java2docfx*.jar")
if (!$java2docfxJarLoc) {
LogError "The java2docfx jar file should be installed in $java2docfxDir and is not there."
return $false
} else {
# In theory, this shouldn't happen as the install-rex-validation-tool.yml is the only thing
# that'll ever install the jar
if ($java2docfxJarLoc.Count -gt 1) {
Write-Host "There were $($java2docfxJarLoc.Count) java2docfx jar files found in $Build_BinariesDirectory, using the first one"
}
$java2docfxJar = $java2docfxJarLoc[0]
Write-Host "java2docfx jar location=$java2docfxJar"
}

$allSuccess = $true
$originLocation = Get-Location
foreach ($packageInfo in $PackageInfos) {
$artifact = "$($packageInfo.Group):$($packageInfo.Name):$($packageInfo.Version)"
$tempDirectory = Join-Path ([System.IO.Path]::GetTempPath()) "$($packageInfo.Group)-$($packageInfo.Name)-$($packageInfo.Version)"
New-Item $tempDirectory -ItemType Directory | Out-Null
# Set the location to the temp directory. The reason being is that it'll effectively be empty, no
# other jars, no POM files aka nothing Java related to pick up.
Set-Location $tempDirectory
try {
Write-Host "Calling java2docfx for $artifact"
Write-Host "java -jar ""$java2docfxJar"" -p ""$artifact"""
$java2docfxResults = java `
-jar "$java2docfxJar"`
-p "$artifact"
# JRS-TODO: The -o option is something I'm currently questioning the behavior of but
# I can do some initial testing without that option being set
# -p "$artifact" `
# -o "$tempDirectory"

if ($LASTEXITCODE -ne 0) {
LogWarning "java2docfx failed for $artifact"
$java2docfxResults | Write-Host
$allSuccess = $false
}
}
catch {
LogError "Exception while trying to download: $artifact"
LogError $_
LogError $_.ScriptStackTrace
$allSuccess = $false
}
finally {
# Ensure that the origianl location is restored
Set-Location $originLocation
# everything is contained within the temp directory, clean it up every time
if (Test-Path $tempDirectory) {
Remove-Item $tempDirectory -Recurse -Force
}
}
}

return $allSuccess
}

0 comments on commit 4957384

Please sign in to comment.