Skip to content

Commit d77bb13

Browse files
authored
[macOS] cache most used GitHub actions
* Download actions/action_versions latest release on macOS and set ACTIONS_RUNNER_ACTION_ARCHIVE_CACHE. * Feedback.
1 parent c7517ab commit d77bb13

File tree

8 files changed

+43
-0
lines changed

8 files changed

+43
-0
lines changed

images/macos/provision/configuration/environment/bashrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export NUNIT3_PATH=/Library/Developer/nunit/3.6.0
1212

1313
export AGENT_TOOLSDIRECTORY=$HOME/hostedtoolcache
1414
export RUNNER_TOOL_CACHE=$HOME/hostedtoolcache
15+
export ACTIONS_RUNNER_ACTION_ARCHIVE_CACHE=$HOME/actionarchivecache
1516

1617
export PATH=/Library/Frameworks/Mono.framework/Versions/Current/Commands:$PATH
1718
export PATH=/Library/Frameworks/Python.framework/Versions/Current/bin:$PATH
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash -e -o pipefail
2+
3+
################################################################################
4+
## File: action-archive-cache.sh
5+
## Desc: Download latest release from https://github.com/actions/action-verions
6+
## and un-tar to $HOME/actionarchivecache
7+
## Maintainer: #actions-runtime and @TingluoHuang
8+
################################################################################
9+
10+
source ~/utils/utils.sh
11+
12+
echo "Check if ACTIONS_RUNNER_ACTION_ARCHIVE_CACHE folder exist..."
13+
if [ ! -d $ACTIONS_RUNNER_ACTION_ARCHIVE_CACHE ]; then
14+
mkdir -p $ACTIONS_RUNNER_ACTION_ARCHIVE_CACHE
15+
fi
16+
17+
downloadUrl=$(get_github_package_download_url "actions/action-versions" "contains(\"action-versions.tar.gz\")" "latest")
18+
echo "Downloading action-versions $downloadUrl"
19+
download_with_retries "$downloadUrl" "/tmp" action-versions.tar.gz
20+
tar -xzf /tmp/action-versions.tar.gz -C $ACTIONS_RUNNER_ACTION_ARCHIVE_CACHE
21+
22+
invoke_tests "ActionArchiveCache"

images/macos/templates/macOS-11.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@
183183
"type": "shell",
184184
"execute_command": "chmod +x {{ .Path }}; {{ .Vars }} {{ .Path }}",
185185
"scripts": [
186+
"./provision/core/action-archive-cache.sh",
186187
"./provision/core/commonutils.sh",
187188
"./provision/core/llvm.sh",
188189
"./provision/core/golang.sh",

images/macos/templates/macOS-12.anka.pkr.hcl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ build {
198198
}
199199
provisioner "shell" {
200200
scripts = [
201+
"./provision/core/action-archive-cache.sh",
201202
"./provision/core/llvm.sh",
202203
"./provision/core/golang.sh",
203204
"./provision/core/swiftlint.sh",

images/macos/templates/macOS-12.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@
185185
"type": "shell",
186186
"execute_command": "chmod +x {{ .Path }}; {{ .Vars }} {{ .Path }}",
187187
"scripts": [
188+
"./provision/core/action-archive-cache.sh",
188189
"./provision/core/llvm.sh",
189190
"./provision/core/golang.sh",
190191
"./provision/core/swiftlint.sh",

images/macos/templates/macOS-13.anka.pkr.hcl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ build {
194194
}
195195
provisioner "shell" {
196196
scripts = [
197+
"./provision/core/action-archive-cache.sh",
197198
"./provision/core/llvm.sh",
198199
"./provision/core/swiftlint.sh",
199200
"./provision/core/openjdk.sh",

images/macos/templates/macOS-13.arm64.anka.pkr.hcl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ build {
194194
}
195195
provisioner "shell" {
196196
scripts = [
197+
"./provision/core/action-archive-cache.sh",
197198
"./provision/core/llvm.sh",
198199
"./provision/core/openjdk.sh",
199200
"./provision/core/rust.sh",
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Describe "ActionArchiveCache" {
2+
Context "Action archive cache directory not empty" {
3+
It "$HOME/actionarchivecache not empty" {
4+
(Get-ChildItem -Path "$env:HOME/actionarchivecache/*.tar.gz" -Recurse).Count | Should -BeGreaterThan 0
5+
}
6+
}
7+
8+
Context "Action tarball not empty" {
9+
$testCases = Get-ChildItem -Path "$env:HOME/actionarchivecache/*.tar.gz" -Recurse | ForEach-Object { @{ ActionTarball = $_.FullName } }
10+
It "<ActionTarball>" -TestCases $testCases {
11+
param ([string] $ActionTarball)
12+
(Get-Item "$ActionTarball").Length | Should -BeGreaterThan 0
13+
}
14+
}
15+
}

0 commit comments

Comments
 (0)