Skip to content

Commit

Permalink
Taking the parameter literally (Azure#25878)
Browse files Browse the repository at this point in the history
  • Loading branch information
sima-zhu authored Dec 11, 2021
1 parent 04cb205 commit 7ecebab
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 26 deletions.
10 changes: 8 additions & 2 deletions eng/pipelines/docindex.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jobs:
DailyDocRepoLocation: $(Pipeline.Workspace)/daily
DocRepoOwner: Azure
DocRepoName: azure-docs-sdk-java
DocValidationImageId: azuresdkimages.azurecr.io/javarefautocr:latest
steps:
# Sync docs repo onboarding files/folders
- template: /eng/common/pipelines/templates/steps/sparse-checkout.yml
Expand All @@ -22,13 +23,18 @@ jobs:
Repositories:
- Name: $(DocRepoOwner)/$(DocRepoName)
WorkingDirectory: $(DocRepoLocation)

# Pull and build the docker image.
- template: /eng/common/pipelines/templates/steps/docker-pull-image.yml
parameters:
ContainerRegistryClientId: $(azuresdkimages-cr-clientid)
ContainerRegistryClientSecret: $(azuresdkimages-cr-clientsecret)
ImageId: "$(DocValidationImageId)"
# Call update docs ci script to onboard packages
- task: Powershell@2
inputs:
pwsh: true
filePath: eng/common/scripts/Update-DocsMsPackages.ps1
arguments: -DocRepoLocation $(DocRepoLocation)
arguments: -DocRepoLocation $(DocRepoLocation) -ImageId '$(DocValidationImageId)'
displayName: Update Docs Onboarding
condition: and(succeeded(), or(eq(variables['Build.Reason'], 'Schedule'), eq(variables['Force.MainUpdate'], 'true')))

Expand Down
35 changes: 22 additions & 13 deletions eng/pipelines/templates/stages/archetype-java-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -212,20 +212,22 @@ stages:
pool:
name: azsdk-pool-mms-ubuntu-2004-general
vmImage: MMSUbuntu20.04

strategy:
runOnce:
deploy:
steps:
- download: current
displayName: 'Download Artifact: ${{parameters.ArtifactName}}'
artifact: ${{parameters.ArtifactName}}
- template: /eng/common/pipelines/templates/steps/sparse-checkout.yml
parameters:
SkipDefaultCheckout: true
Paths:
- sdk/**/*.md
- sdk
- common/perf-test-core
- .github/CODEOWNERS
- download: current
displayName: 'Download Artifact: ${{parameters.ArtifactName}}'
artifact: ${{parameters.ArtifactName}}
- '!sdk/**/test-recordings'
- '!sdk/**/session-records'
- template: /eng/common/pipelines/templates/steps/update-docsms-metadata.yml
parameters:
PackageInfoLocations:
Expand Down Expand Up @@ -385,19 +387,26 @@ stages:
name: azsdk-pool-mms-ubuntu-2004-general
vmImage: MMSUbuntu20.04
steps:
- template: /eng/common/pipelines/templates/steps/sparse-checkout.yml
parameters:
SkipDefaultCheckout: true
Paths:
- sdk/**/*.md
- .github/CODEOWNERS
- download: current
displayName: 'Download Artifact: ${{parameters.ArtifactName}}'
artifact: ${{parameters.ArtifactName}}
- pwsh: |
Get-ChildItem -Recurse $(Pipeline.Workspace)/${{parameters.ArtifactName}}/
displayName: Show visible artifacts
# Docs daily updates is supposed to download packages from public feed repository, so we have to specify additional repositories in a POM or the profile.
# Here is maven documentation: https://maven.apache.org/guides/mini/guide-multiple-repositories.html
- powershell: |
# Linux mvn `setting.xml` is sitting under path `~/.m2/setting.xml`
Get-Command mvn
if (!(Test-Path '~/.m2/')) {
mkdir ~/.m2/
}
if (Test-Path '~/.m2/setting.xml') {
Write-Host "'setting.xml' exists. Overwriting the file to support multiple repositories."
}
Copy-Item "./eng/repo-docs/docms/daily.update.setting.xml" -Destination "~/.m2/settings.xml"
displayName: 'Configure mvn'
workingDirectory: $(Build.SourcesDirectory)
- template: /eng/common/pipelines/templates/steps/update-docsms-metadata.yml
parameters:
PackageInfoLocations:
Expand All @@ -411,4 +420,4 @@ stages:
DailyDocsBuild: true
SparseCheckoutPaths:
- docs-ref-services/
- metadata/
- metadata/
33 changes: 22 additions & 11 deletions eng/scripts/Language-Settings.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ function SourcePackageHasComFolder($artifactNamePrefix, $packageDirectory) {
$mvnResults = mvn `
dependency:copy `
-Dartifact="$packageArtifact" `
-DoutputDirectory="$packageDirectory"
-DoutputDirectory="$packageDirectory" | Out-Null

if ($LASTEXITCODE) {
LogWarning "Could not download source artifact: $packageArtifact"
Expand Down Expand Up @@ -309,7 +309,7 @@ function PackageDependenciesResolve($artifactNamePrefix, $packageDirectory) {
$artifactDownloadOutput = mvn `
dependency:copy `
-Dartifact="$pomArtifactName" `
-DoutputDirectory="$packageDirectory"
-DoutputDirectory="$packageDirectory" | Out-Null

if ($LASTEXITCODE) {
LogWarning "Could not download pom artifact: $pomArtifactName"
Expand All @@ -325,7 +325,7 @@ function PackageDependenciesResolve($artifactNamePrefix, $packageDirectory) {
-f $downloadedPomPath `
dependency:copy-dependencies `
-P '!azure-mgmt-sdk-test-jar' `
-DoutputDirectory="$packageDirectory"
-DoutputDirectory="$packageDirectory" | Out-Null

if ($LASTEXITCODE) {
LogWarning "Could not resolve dependencies for: $pomArtifactName"
Expand All @@ -336,7 +336,12 @@ function PackageDependenciesResolve($artifactNamePrefix, $packageDirectory) {
return $true
}

function ValidatePackage($groupId, $artifactId, $version, $workingDirectory) {
function ValidatePackage($groupId, $artifactId, $version) {
$workingDirectory = Join-Path ([System.IO.Path]::GetTempPath()) "validation"
if (!(Test-Path $workingDirectory)) {
New-Item -ItemType Directory -Force -Path $workingDirectory | Out-Null
}

$artifactNamePrefix = "${groupId}:${artifactId}:${version}"

$packageDirectory = Join-Path `
Expand All @@ -348,7 +353,7 @@ function ValidatePackage($groupId, $artifactId, $version, $workingDirectory) {
-and (PackageDependenciesResolve $artifactNamePrefix $packageDirectory)
}

function Update-java-DocsMsPackages($DocsRepoLocation, $DocsMetadata) {
function Update-java-DocsMsPackages($DocsRepoLocation, $DocsMetadata, $DocValidationImageId) {
Write-Host "Excluded packages:"
foreach ($excludedPackage in $PackageExclusions.Keys) {
Write-Host " $excludedPackage - $($PackageExclusions[$excludedPackage])"
Expand All @@ -372,9 +377,6 @@ function Update-java-DocsMsPackages($DocsRepoLocation, $DocsMetadata) {
function UpdateDocsMsPackages($DocConfigFile, $Mode, $DocsMetadata) {
$packageConfig = Get-Content $DocConfigFile -Raw | ConvertFrom-Json

$workingDirectory = Join-Path ([System.IO.Path]::GetTempPath()) ([System.IO.Path]::GetRandomFileName())
New-Item -ItemType Directory -Force -Path $workingDirectory | Out-Null

$packageOutputPath = 'docs-ref-autogen'
if ($Mode -eq 'preview') {
$packageOutputPath = 'preview/docs-ref-autogen'
Expand Down Expand Up @@ -439,7 +441,7 @@ function UpdateDocsMsPackages($DocConfigFile, $Mode, $DocsMetadata) {
# If upgrading the package, run basic sanity checks against the package
if ($package.packageVersion -ne $packageVersion) {
Write-Host "Validating new version detected for $packageName ($packageVersion)"
$validatePackageResult = ValidatePackage $package.packageGroupId $package.packageArtifactId $packageVersion $workingDirectory
$validatePackageResult = ValidatePackage $package.packageGroupId $package.packageArtifactId $packageVersion

if (!$validatePackageResult) {
LogWarning "Package is not valid: $packageName. Keeping old version."
Expand Down Expand Up @@ -480,7 +482,7 @@ function UpdateDocsMsPackages($DocConfigFile, $Mode, $DocsMetadata) {
}

Write-Host "Validating new package $($packageGroupId):$($packageName):$($packageVersion)"
$validatePackageResult = ValidatePackage $packageGroupId $packageName $packageVersion $workingDirectory
$validatePackageResult = ValidatePackage $packageGroupId $packageName $packageVersion
if (!$validatePackageResult) {
LogWarning "Package is not valid: ${packageGroupId}:$packageName. Cannot onboard."
continue
Expand Down Expand Up @@ -610,4 +612,13 @@ function Get-java-DocsMsMetadataForPackage($PackageInfo) {
PreviewReadMeLocation = 'docs-ref-services/preview'
Suffix = ''
}
}
}

function Validate-java-DocMsPackages ($PackageInfo, $DocValidationImageId)
{
if (!(ValidatePackage $PackageInfo.Group $PackageInfo.Name $PackageInfo.Version))
{
exit 1
}
return
}

0 comments on commit 7ecebab

Please sign in to comment.