Skip to content

Commit

Permalink
merge from main
Browse files Browse the repository at this point in the history
  • Loading branch information
azure-sdk committed Nov 2, 2021
1 parent c91dd83 commit 9e95b3c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 27 deletions.
16 changes: 13 additions & 3 deletions eng/pipelines/docindex.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ jobs:
DocRepoLocation: $(Pipeline.Workspace)/docs
DocRepoOwner: MicrosoftDocs
DocRepoName: azure-docs-sdk-node
ImageId: azuresdkimages.azurecr.io/jsrefautocr:latest
steps:
# Sync docs repo (this can be sparse)
- template: /eng/common/pipelines/templates/steps/sparse-checkout.yml
Expand All @@ -22,15 +23,23 @@ 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: '$(ImageId)'


# 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 '$(ImageId)'
displayName: Update Docs Onboarding

condition: and(succeeded(), or(eq(variables['Build.Reason'], 'Schedule'), eq(variables['Force.MainUpdate'], 'true')))

# Push changes to docs repo
- template: /eng/common/pipelines/templates/steps/set-default-branch.yml
parameters:
Expand Down Expand Up @@ -60,8 +69,9 @@ jobs:
inputs:
pwsh: true
filePath: eng/common/scripts/Update-DocsMsPackages.ps1
arguments: -DocRepoLocation $(DocRepoLocation)
arguments: -DocRepoLocation $(DocRepoLocation) -ImageId '$(ImageId)'
displayName: Update Docs Onboarding for Daily branch

- template: /eng/common/pipelines/templates/steps/git-push-changes.yml
parameters:
BaseRepoBranch: $(DailyDocsBranchName)
Expand Down
3 changes: 1 addition & 2 deletions eng/scripts/Language-Settings.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,7 @@ function ValidatePackagesForDocs($packages) {
$validationOutput = $packages | Foreach-Object -Parallel {
# Get value for variables outside of the Foreach-Object scope
$scriptRoot = "$using:scriptRoot"
$workingDirectory = "$using:tempDirectory"
return ."$scriptRoot\validate-docs-package.ps1" -Package $_ -WorkingDirectory $workingDirectory
return ."$scriptRoot\validate-docs-package.ps1" -Package $_ -DocValidationImageId "$using:imageId"
}

# Clean up temp folder
Expand Down
36 changes: 14 additions & 22 deletions eng/scripts/validate-docs-package.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,53 +4,45 @@ Validates packages by simulating docs CI steps
.PARAMETER Package
An object describing a package configuration to validate in the format used by
docs CI onboarding format.
docker image, which is the wrapping of docs CI build commands.
Required attributes:
- name: The name of the package
Supported optional attributes:
- registry: The registry to use for the package if it's not NPM
Example:
```
@{
name = "@azure/attestation@dev";
folder = "./types";
registry = "<url>";
...
}
```
.PARAMETER WorkingDirectory
Supplied to `npm install ... --prefix $WorkingDirectory`. The place where the
node_modules folder is created and the package is installed
.PARAMETER docValidationImageId
The image name for package validation in format of '$containerRegistry/$imageName:$tag'.
e.g. azuresdkimages.azurecr.io/jsrefautocr:latest
#>

param(
[object] $Package,
[string] $WorkingDirectory
[string] $DocValidationImageId
)
."$PSScriptRoot\..\common\scripts\common.ps1"

function GetResult($success, $package, $output) {
return @{ Success = $success; Package = $package; Output = $output }
}

$prefixDirectory = New-Item -ItemType Directory -Force -Path "$WorkingDirectory\$($Package.name)"
Write-Host "docker run --restart=on-failure:3 -e TARGET_PACKAGE='$($Package.name)' TARGET_REGISTRY='$($Package.registry)'' TARGET_FOLDER='$($Package.folder)'' $DocValidationImageId"
$installOutput = docker run --restart=on-failure:3 -e TARGET_PACKAGE=$($Package.name) TARGET_REGISTRY="$($Package.registry)" TARGET_FOLDER="$($Package.folder)" $DocValidationImageId 2>&1

$additionalParameters = @()
if ($Package.registry) {
Write-Host $Package.registry
$additionalParameters += @("--registry", $Package.registry)
# The docker exit codes: https://docs.docker.com/engine/reference/run/#exit-status
# If the docker failed because of docker itself instead of the application,
# we should skip the validation and keep the packages.
if ($LASTEXITCODE -eq 125 -Or $LASTEXITCODE -eq 126 -Or $LASTEXITCODE -eq 127) {
LogWarning "The `docker` command does not work with exit code $LASTEXITCODE. Skipvalidation of $($Package.name)."
}

Write-Host "npm install $($Package.name) --prefix $prefixDirectory $additionalParameters"
$installOutput = npm install $Package.name --prefix $prefixDirectory @additionalParameters 2>&1
if ($LASTEXITCODE -ne 0) {
LogWarning "Package install failed: $($Package.name)"
elseif ($LASTEXITCODE -ne 0) {
LogWarning "Package $($Package.name) ref docs validation failed."
return GetResult $false $package $installOutput
}

return GetResult $true $package $installOutput

0 comments on commit 9e95b3c

Please sign in to comment.