mirror of
https://github.com/actions/runner-images.git
synced 2026-01-03 16:49:11 +08:00
[Windows] cache most used GitHub actions
* Download actions/action_versions latest release on Windows and set ACTIONS_RUNNER_ACTION_ARCHIVE_CACHE. * feedback * fix get latest package on Windows. * invoke test
This commit is contained in:
21
images/win/scripts/Installers/Install-ActionArchiveCache.ps1
Normal file
21
images/win/scripts/Installers/Install-ActionArchiveCache.ps1
Normal file
@@ -0,0 +1,21 @@
|
||||
################################################################################
|
||||
## File: Install-ActionArchiveCache.ps1
|
||||
## Desc: Download latest release from https://github.com/actions/action-versions
|
||||
## and un-zip to C:\actionarchivecache
|
||||
## Maintainer: #actions-runtime and @TingluoHuang
|
||||
################################################################################
|
||||
|
||||
if (-not (Test-Path $env:ACTIONS_RUNNER_ACTION_ARCHIVE_CACHE))
|
||||
{
|
||||
Write-Host "Creating action archive cache folder"
|
||||
New-Item -ItemType Directory -Path $env:ACTIONS_RUNNER_ACTION_ARCHIVE_CACHE | Out-Null
|
||||
}
|
||||
|
||||
$downloadUrl = Get-GitHubPackageDownloadUrl -RepoOwner "actions" -RepoName "action-versions" -Version "latest" -UrlFilter "*/v{Version}/action-versions.zip"
|
||||
Write-Host "Download Latest action-versions archive from $downloadUrl"
|
||||
$actionVersionsArchivePath = Start-DownloadWithRetry -Url $downloadUrl -Name "action-versions.zip"
|
||||
|
||||
Write-Host "Expand action-versions archive"
|
||||
Extract-7Zip -Path $actionVersionsArchivePath -DestinationPath $env:ACTIONS_RUNNER_ACTION_ARCHIVE_CACHE
|
||||
|
||||
Invoke-PesterTests -TestFile "ActionArchiveCache"
|
||||
@@ -41,4 +41,5 @@ $json | Out-File -FilePath $imageDataFile
|
||||
# Set static env vars
|
||||
setx ImageVersion $env:IMAGE_VERSION /m
|
||||
setx ImageOS $env:IMAGE_OS /m
|
||||
setx AGENT_TOOLSDIRECTORY $env:AGENT_TOOLSDIRECTORY /m
|
||||
setx AGENT_TOOLSDIRECTORY $env:AGENT_TOOLSDIRECTORY /m
|
||||
setx ACTIONS_RUNNER_ACTION_ARCHIVE_CACHE $env:ACTIONS_RUNNER_ACTION_ARCHIVE_CACHE /m
|
||||
|
||||
15
images/win/scripts/Tests/ActionArchiveCache.Tests.ps1
Normal file
15
images/win/scripts/Tests/ActionArchiveCache.Tests.ps1
Normal file
@@ -0,0 +1,15 @@
|
||||
Describe "ActionArchiveCache" {
|
||||
Context "Action archive cache directory not empty" {
|
||||
It "C:\actionarchivecache not empty" {
|
||||
(Get-ChildItem -Path "C:\actionarchivecache\*.zip" -Recurse).Count | Should -BeGreaterThan 0
|
||||
}
|
||||
}
|
||||
|
||||
Context "Action zipball not empty" {
|
||||
$testCases = Get-ChildItem -Path "C:\actionarchivecache\*.zip" -Recurse | ForEach-Object { @{ ActionZipball = $_.FullName } }
|
||||
It "<ActionZipball>" -TestCases $testCases {
|
||||
param ([string] $ActionZipball)
|
||||
(Get-Item "$ActionZipball").Length | Should -BeGreaterThan 0
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -146,6 +146,7 @@
|
||||
"IMAGE_VERSION={{user `image_version`}}",
|
||||
"IMAGE_OS={{user `image_os`}}",
|
||||
"AGENT_TOOLSDIRECTORY={{user `agent_tools_directory`}}",
|
||||
"ACTIONS_RUNNER_ACTION_ARCHIVE_CACHE=C:\\actionarchivecache\\",
|
||||
"IMAGEDATA_FILE={{user `imagedata_file`}}"
|
||||
],
|
||||
"scripts": [
|
||||
@@ -225,6 +226,7 @@
|
||||
{
|
||||
"type": "powershell",
|
||||
"scripts": [
|
||||
"{{ template_dir }}/scripts/Installers/Install-ActionArchiveCache.ps1",
|
||||
"{{ template_dir }}/scripts/Installers/Install-Ruby.ps1",
|
||||
"{{ template_dir }}/scripts/Installers/Install-PyPy.ps1",
|
||||
"{{ template_dir }}/scripts/Installers/Install-Toolset.ps1",
|
||||
@@ -362,4 +364,4 @@
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,6 +130,7 @@
|
||||
"IMAGE_VERSION={{user `image_version`}}",
|
||||
"IMAGE_OS={{user `image_os`}}",
|
||||
"AGENT_TOOLSDIRECTORY={{user `agent_tools_directory`}}",
|
||||
"ACTIONS_RUNNER_ACTION_ARCHIVE_CACHE=C:\\actionarchivecache\\",
|
||||
"IMAGEDATA_FILE={{user `imagedata_file`}}"
|
||||
],
|
||||
"scripts": [
|
||||
@@ -215,6 +216,7 @@
|
||||
{
|
||||
"type": "powershell",
|
||||
"scripts": [
|
||||
"{{ template_dir }}/scripts/Installers/Install-ActionArchiveCache.ps1",
|
||||
"{{ template_dir }}/scripts/Installers/Install-Ruby.ps1",
|
||||
"{{ template_dir }}/scripts/Installers/Install-PyPy.ps1",
|
||||
"{{ template_dir }}/scripts/Installers/Install-Toolset.ps1",
|
||||
|
||||
Reference in New Issue
Block a user