Switch Windows hostedtoolcache provisioner to GitHub Actions NPM registry (#315)

* Toolcache: add basic error handling in Windows toolcache provisioner

* Toolcache: add GITHUB_FEED_TOKEN into packer templates for Windows

* Toolcache: separate toolcache.json for Windows

* Rework "Validate-ToolCache" script (#6)

* Rework validate toolcache script

* change boost root folder

* Add boost 1.69 for windows-2019

* Add toolcache config variable to Windows 16, 19

* Revert "Add toolcache config variable to Windows 16, 19"

* Add default boost version for validate-boost VS19

* Remove bjam test for boost

* Add boost 1.72 validation for win-2016

Co-authored-by: MaksimZhukov <46996400+MaksimZhukov@users.noreply.github.com>
Co-authored-by: Aleksandr Chebotov <47745270+al-cheb@users.noreply.github.com>
This commit is contained in:
Maksim Petrov
2020-01-29 10:41:09 +03:00
committed by GitHub
parent e0f5ff2061
commit 0967620111
9 changed files with 187 additions and 110 deletions

View File

@@ -8,18 +8,45 @@ Function Install-NpmPackage {
[CmdletBinding()]
param(
[Parameter(Mandatory=$true)]
[System.String]
$Name,
[System.String] $PackageName,
[Parameter(Mandatory=$true)]
[System.String]
$NpmRegistry
[System.Uri] $FeedPrefix
)
Write-Host "Installing npm '$Name' package from '$NpmRegistry'"
Push-Location -Path $env:TEMP
npm install $Name --registry=$NpmRegistry
$FeedUri = $FeedPrefix.AbsoluteUri
Write-Host "Installing npm $PackageName from ${FeedUri}"
npm install $PackageName --registry "${FeedUri}"
if($LASTEXITCODE) {
Write-Host "$PackageName installation failure; Error: ${LASTEXITCODE}"
exit 1
}
Pop-Location
}
Function NPMFeed-AuthSetup {
param(
[Parameter(Mandatory=$true)]
[System.String] $AccessToken,
[Parameter(Mandatory=$true)]
[System.Uri] $FeedPrefix
)
$FeedHost = $FeedPrefix.Host
Write-Host "Configure auth for github package registry"
$npmrcContent = "//${FeedHost}/:_authToken=${AccessToken}"
$npmrcContent | Out-File -FilePath "$($env:TEMP)/.npmrc" -Encoding utf8
}
$FeedPrefix = "https://npm.pkg.github.com"
$AccessToken = $env:GITHUB_FEED_TOKEN
# HostedToolCache Path
$Dest = "C:/"
$Path = "hostedtoolcache/windows"
@@ -33,16 +60,18 @@ setx AGENT_TOOLSDIRECTORY $ToolsDirectory /M
$ToolVersionsFileContent = Get-Content -Path "$env:ROOT_FOLDER/toolcache.json" -Raw
$ToolVersions = ConvertFrom-Json -InputObject $ToolVersionsFileContent
NPMFeed-AuthSetup -AccessToken $AccessToken -FeedPrefix $FeedPrefix
$ToolVersions.PSObject.Properties | ForEach-Object {
$PackageName = $_.Name
$PackageVersions = $_.Value
$NpmPackages = $PackageVersions | ForEach-Object { "$PackageName@$_" }
foreach($NpmPackage in $NpmPackages) {
Install-NpmPackage -Name $NpmPackage -NpmRegistry $env:TOOLCACHE_REGISTRY
Install-NpmPackage -PackageName $NpmPackage -FeedPrefix $FeedPrefix
}
}
#junction point from the previous Python2 directory to the toolcache Python2
Write-Host "Create symlink to Python2"
$python2Dir = (Get-Item -Path ($ToolsDirectory + '/Python/2.7*/x64')).FullName
cmd.exe /c mklink /d "C:\Python27amd64" "$python2Dir"
cmd.exe /c mklink /d "C:\Python27amd64" "$python2Dir"