mirror of
https://github.com/actions/runner-images-sangeeth.git
synced 2025-12-20 06:29:50 +00:00
[Ubuntu] cache most used GitHub actions
This commit is contained in:
26
images/linux/scripts/installers/action-archive-cache.sh
Executable file
26
images/linux/scripts/installers/action-archive-cache.sh
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/bin/bash -e
|
||||
################################################################################
|
||||
## File: action-archive-cache.sh
|
||||
## Desc: Download latest release from https://github.com/actions/action-verions
|
||||
## and un-tar to /opt/actionarchivecache
|
||||
## Maintainer: #actions-runtime and @TingluoHuang
|
||||
################################################################################
|
||||
|
||||
# Source the helpers for use with the script
|
||||
source $HELPER_SCRIPTS/install.sh
|
||||
source $HELPER_SCRIPTS/etc-environment.sh
|
||||
|
||||
# Prepare directory and env variable for ACTIONS_RUNNER_ACTION_ARCHIVE_CACHE
|
||||
ACTION_ARCHIVE_CACHE_DIR=/opt/actionarchivecache
|
||||
mkdir -p $ACTION_ARCHIVE_CACHE_DIR
|
||||
chmod -R 777 $ACTION_ARCHIVE_CACHE_DIR
|
||||
echo "Setting up ACTIONS_RUNNER_ACTION_ARCHIVE_CACHE variable to ${ACTION_ARCHIVE_CACHE_DIR}"
|
||||
addEtcEnvironmentVariable ACTIONS_RUNNER_ACTION_ARCHIVE_CACHE ${ACTION_ARCHIVE_CACHE_DIR}
|
||||
|
||||
# Download latest release from github.com/actions/action-versions and untar to /opt/actionarchivecache
|
||||
downloadUrl=$(get_github_package_download_url "actions/action-versions" "contains(\"action-versions.tar.gz\")")
|
||||
echo "Downloading action-versions $downloadUrl"
|
||||
download_with_retries "$downloadUrl" "/tmp" action-versions.tar.gz
|
||||
tar -xzf /tmp/action-versions.tar.gz -C $ACTION_ARCHIVE_CACHE_DIR
|
||||
|
||||
invoke_tests "ActionArchiveCache"
|
||||
15
images/linux/scripts/tests/ActionArchiveCache.Tests.ps1
Normal file
15
images/linux/scripts/tests/ActionArchiveCache.Tests.ps1
Normal file
@@ -0,0 +1,15 @@
|
||||
Describe "ActionArchiveCache" {
|
||||
Context "Action archive cache directory not empty" {
|
||||
It "/opt/actionarchivecache not empty" {
|
||||
(Get-ChildItem -Path "/opt/actionarchivecache/*.tar.gz" -Recurse).Count | Should -BeGreaterThan 0
|
||||
}
|
||||
}
|
||||
|
||||
Context "Action tarball not empty" {
|
||||
$testCases = Get-ChildItem -Path "/opt/actionarchivecache/*.tar.gz" -Recurse | ForEach-Object { @{ ActionTarball = $_.FullName } }
|
||||
It "<ActionTarball>" -TestCases $testCases {
|
||||
param ([string] $ActionTarball)
|
||||
(Get-Item "$ActionTarball").Length | Should -BeGreaterThan 0
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user