From 25a3a04fb0352a05796bdfb39e96fc7df09ebd5a Mon Sep 17 00:00:00 2001 From: Peter Shepehrd <109117968+pshepherd10@users.noreply.github.com> Date: Thu, 9 Nov 2023 15:43:12 -0500 Subject: [PATCH] [Ubuntu] add runner-package to curated images (#8474) --- .../linux/scripts/installers/runner-package.sh | 18 ++++++++++++++++++ .../linux/scripts/tests/RunnerCache.Tests.ps1 | 7 +++++++ images/linux/ubuntu2004.json | 4 ++-- images/linux/ubuntu2204.pkr.hcl | 1 + 4 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 images/linux/scripts/installers/runner-package.sh create mode 100644 images/linux/scripts/tests/RunnerCache.Tests.ps1 diff --git a/images/linux/scripts/installers/runner-package.sh b/images/linux/scripts/installers/runner-package.sh new file mode 100644 index 000000000..1e8b063eb --- /dev/null +++ b/images/linux/scripts/installers/runner-package.sh @@ -0,0 +1,18 @@ +#!/bin/bash -e +################################################################################ +## File: runner-package.sh +## Desc: Downloads and Installs runner package +################################################################################ + +# Source the helpers for use with the script +source $HELPER_SCRIPTS/install.sh + +DOWNLOAD_URL=$(get_github_package_download_url "actions/runner" 'test("actions-runner-linux-x64-[0-9]+\\.[0-9]{3}\\.[0-9]+\\.tar\\.gz")') + +FILE_NAME="${DOWNLOAD_URL##*/}" + +sudo mkdir -p /opt/runner-cache + +download_with_retries "${DOWNLOAD_URL}" "/tmp" "${FILE_NAME}" + +sudo mv /tmp/$FILE_NAME /opt/runner-cache/$FILE_NAME diff --git a/images/linux/scripts/tests/RunnerCache.Tests.ps1 b/images/linux/scripts/tests/RunnerCache.Tests.ps1 new file mode 100644 index 000000000..76c1a7278 --- /dev/null +++ b/images/linux/scripts/tests/RunnerCache.Tests.ps1 @@ -0,0 +1,7 @@ +Describe "RunnerCache" { + Context "runner cache directory not empty" { + It "/opt/runner-cache not empty" { + (Get-ChildItem -Path "/opt/runner-cache/*.tar.gz" -Recurse).Count | Should -BeGreaterThan 0 + } + } +} diff --git a/images/linux/ubuntu2004.json b/images/linux/ubuntu2004.json index 875edeafb..2e524036f 100644 --- a/images/linux/ubuntu2004.json +++ b/images/linux/ubuntu2004.json @@ -197,6 +197,7 @@ "type": "shell", "scripts": [ "{{template_dir}}/scripts/installers/action-archive-cache.sh", + "{{template_dir}}/scripts/installers/runner-package.sh", "{{template_dir}}/scripts/installers/apt-common.sh", "{{template_dir}}/scripts/installers/azcopy.sh", "{{template_dir}}/scripts/installers/azure-cli.sh", @@ -258,8 +259,7 @@ "{{template_dir}}/scripts/installers/android.sh", "{{template_dir}}/scripts/installers/pypy.sh", "{{template_dir}}/scripts/installers/python.sh", - "{{template_dir}}/scripts/installers/zstd.sh" - ], + "{{template_dir}}/scripts/installers/zstd.sh" ], "environment_vars": [ "HELPER_SCRIPTS={{user `helper_script_folder`}}", "INSTALLER_SCRIPT_FOLDER={{user `installer_script_folder`}}", diff --git a/images/linux/ubuntu2204.pkr.hcl b/images/linux/ubuntu2204.pkr.hcl index 500d959f4..650711a87 100644 --- a/images/linux/ubuntu2204.pkr.hcl +++ b/images/linux/ubuntu2204.pkr.hcl @@ -281,6 +281,7 @@ build { execute_command = "sudo sh -c '{{ .Vars }} {{ .Path }}'" scripts = [ "${path.root}/scripts/installers/action-archive-cache.sh", + "${path.root}/scripts/installers/runner-package.sh", "${path.root}/scripts/installers/apt-common.sh", "${path.root}/scripts/installers/azcopy.sh", "${path.root}/scripts/installers/azure-cli.sh",