mirror of
https://github.com/miurahr/aqtinstall.git
synced 2025-12-17 04:34:37 +03:00
cache powershell modules
This change saves PowerShell modules used in the Azure Pipelines to a cache, and loads them when required. This is intended to prevent random failures when the PowerShell Gallery fails to provide the requested modules. These failures occur at random, possibly as a result of a backpressure mechanism. This change will also speed up all Windows Azure Pipelines jobs, since downloads from the PowerShell Gallery will no longer be necessary.
This commit is contained in:
@@ -46,6 +46,10 @@ jobs:
|
|||||||
vmImage: 'windows-2019'
|
vmImage: 'windows-2019'
|
||||||
strategy:
|
strategy:
|
||||||
matrix: $[ dependencies.MatricesGenerator.outputs['mtrx.windows'] ]
|
matrix: $[ dependencies.MatricesGenerator.outputs['mtrx.windows'] ]
|
||||||
|
variables:
|
||||||
|
MODULES_FOLDER: '$(System.DefaultWorkingDirectory)\CachedPowershellModules'
|
||||||
|
startYear: $[format('{0:yyyy}', pipeline.startTime)]
|
||||||
|
startMonth: $[format('{0:MM}', pipeline.startTime)]
|
||||||
steps:
|
steps:
|
||||||
- template: ci/steps.yml
|
- template: ci/steps.yml
|
||||||
|
|
||||||
|
|||||||
44
ci/steps.yml
44
ci/steps.yml
@@ -175,13 +175,35 @@ steps:
|
|||||||
displayName: Build accelbubble example application to test for android
|
displayName: Build accelbubble example application to test for android
|
||||||
|
|
||||||
##----------------------------------------------------
|
##----------------------------------------------------
|
||||||
# determine Windows build system
|
# Cache Powershell Modules in $MODULES_FOLDER
|
||||||
|
- task: Cache@2
|
||||||
|
inputs:
|
||||||
|
key: '"pwsh modules" | "$(startYear)" | "$(startMonth)"'
|
||||||
|
restorekeys: |
|
||||||
|
"pwsh modules" | "$(startYear)"
|
||||||
|
"pwsh modules"
|
||||||
|
path: $(MODULES_FOLDER)
|
||||||
|
cacheHitVar: PSModules_IsCached
|
||||||
|
condition: |
|
||||||
|
and(eq(variables['Agent.OS'], 'Windows_NT'),
|
||||||
|
eq(variables['SUBCOMMAND'], 'install-qt'))
|
||||||
|
displayName: Cache Powershell Modules
|
||||||
|
# On cache miss: Download Powershell Modules to $MODULES_FOLDER
|
||||||
- powershell: |
|
- powershell: |
|
||||||
Install-PackageProvider NuGet -Force
|
Install-PackageProvider NuGet -Force
|
||||||
Import-PackageProvider NuGet -Force
|
Import-PackageProvider NuGet -Force
|
||||||
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
|
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
|
||||||
Install-Module Pscx -AllowClobber -AllowPrerelease
|
md -p $(MODULES_FOLDER) # mkdir
|
||||||
Install-Module VSSetup -Scope CurrentUser
|
Save-Module -Name Pscx -AllowPrerelease -Path $(MODULES_FOLDER)
|
||||||
|
condition: |
|
||||||
|
and(eq(variables['Agent.OS'], 'Windows_NT'),
|
||||||
|
eq(variables['SUBCOMMAND'], 'install-qt'),
|
||||||
|
ne(variables.PSModules_IsCached, 'true'))
|
||||||
|
displayName: Download Powershell Modules for Windows on cache miss
|
||||||
|
|
||||||
|
##----------------------------------------------------
|
||||||
|
# determine Windows build system
|
||||||
|
- powershell: |
|
||||||
if ('$(ARCH)' -like '*msvc*') {
|
if ('$(ARCH)' -like '*msvc*') {
|
||||||
Write-Host '##vso[task.setvariable variable=TOOLCHAIN]MSVC'
|
Write-Host '##vso[task.setvariable variable=TOOLCHAIN]MSVC'
|
||||||
}
|
}
|
||||||
@@ -202,7 +224,9 @@ steps:
|
|||||||
}
|
}
|
||||||
cd $(WIN_QT_BINDIR)
|
cd $(WIN_QT_BINDIR)
|
||||||
unzip $(Build.SourcesDirectory)\ci\jom_1_1_3.zip
|
unzip $(Build.SourcesDirectory)\ci\jom_1_1_3.zip
|
||||||
condition: and(eq( variables['Agent.OS'], 'Windows_NT'), eq(variables['SUBCOMMAND'], 'install-qt'))
|
condition: |
|
||||||
|
and(eq(variables['Agent.OS'], 'Windows_NT'),
|
||||||
|
eq(variables['SUBCOMMAND'], 'install-qt'))
|
||||||
displayName: Detect toolchain for Windows and update PATH
|
displayName: Detect toolchain for Windows and update PATH
|
||||||
|
|
||||||
# When no modules
|
# When no modules
|
||||||
@@ -217,6 +241,12 @@ steps:
|
|||||||
displayName: Build test with qmake for Linux and macOS w/o extra module
|
displayName: Build test with qmake for Linux and macOS w/o extra module
|
||||||
- powershell: |
|
- powershell: |
|
||||||
if ( $env:TOOLCHAIN -eq 'MSVC' ) {
|
if ( $env:TOOLCHAIN -eq 'MSVC' ) {
|
||||||
|
# Load modules from cache
|
||||||
|
$Env:PSModulePath = '$(MODULES_FOLDER)', $Env:PSModulePath -join [System.IO.Path]::PathSeparator
|
||||||
|
Write-Host $Env:PSModulePath
|
||||||
|
Import-Module "Pscx"
|
||||||
|
Import-Module "VSSetup"
|
||||||
|
|
||||||
Import-VisualStudioVars -VisualStudioVersion $(VSVER) -Architecture $(ARCHITECTURE)
|
Import-VisualStudioVars -VisualStudioVersion $(VSVER) -Architecture $(ARCHITECTURE)
|
||||||
$env:Path += ";$(WIN_QT_BINDIR)"
|
$env:Path += ";$(WIN_QT_BINDIR)"
|
||||||
mkdir $(Build.BinariesDirectory)\tests
|
mkdir $(Build.BinariesDirectory)\tests
|
||||||
@@ -244,6 +274,12 @@ steps:
|
|||||||
condition: and(eq( variables['Agent.OS'], 'Windows_NT'), eq(variables['MODULE'], ''), eq(variables['SUBCOMMAND'], 'install-qt'))
|
condition: and(eq( variables['Agent.OS'], 'Windows_NT'), eq(variables['MODULE'], ''), eq(variables['SUBCOMMAND'], 'install-qt'))
|
||||||
displayName: build test with qmake w/o extra module
|
displayName: build test with qmake w/o extra module
|
||||||
- powershell: |
|
- powershell: |
|
||||||
|
# Load modules from cache
|
||||||
|
$Env:PSModulePath = '$(MODULES_FOLDER)', $Env:PSModulePath -join [System.IO.Path]::PathSeparator
|
||||||
|
Write-Host $Env:PSModulePath
|
||||||
|
Import-Module "Pscx"
|
||||||
|
Import-Module "VSSetup"
|
||||||
|
|
||||||
Import-VisualStudioVars -VisualStudioVersion $(VSVER) -Architecture $(ARCHITECTURE)
|
Import-VisualStudioVars -VisualStudioVersion $(VSVER) -Architecture $(ARCHITECTURE)
|
||||||
$env:Path += ";$(WIN_QT_BINDIR)"
|
$env:Path += ";$(WIN_QT_BINDIR)"
|
||||||
echo Add Qt to PATH: $env:PATH
|
echo Add Qt to PATH: $env:PATH
|
||||||
|
|||||||
Reference in New Issue
Block a user