Skip to content

Commit 67c9e8c

Browse files
committed
Add support for ARM64 runners
* Support Graviton (a1) and Graviton2 (*6g*)
1 parent 48581a5 commit 67c9e8c

File tree

5 files changed

+67
-3
lines changed

5 files changed

+67
-3
lines changed

main.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ module "runners" {
6262

6363
instance_type = var.instance_type
6464

65+
ami_filter = substr(var.instance_type,0,2) == "a1" || substr(var.instance_type,1,2) == "6g" ? {name = ["amzn2-ami-hvm-2*-arm64-gp2"]} : {name = ["amzn2-ami-hvm-2.*-x86_64-ebs"]}
66+
6567
sqs_build_queue = aws_sqs_queue.queued_builds
6668
github_app = var.github_app
6769
enable_organization_runners = var.enable_organization_runners
@@ -92,9 +94,12 @@ module "runner_binaries" {
9294

9395
distribution_bucket_name = "${var.environment}-dist-${random_string.random.result}"
9496

97+
runner_architecture = substr(var.instance_type,0,2) == "a1" || substr(var.instance_type,1,2) == "6g" ? "arm64" : "x64"
98+
9599
lambda_zip = var.runner_binaries_syncer_lambda_zip
96100
lambda_timeout = var.runner_binaries_syncer_lambda_timeout
97101

102+
98103
role_path = var.role_path
99104
role_permissions_boundary = var.role_permissions_boundary
100105
}

modules/runner-binaries-syncer/lambdas/runner-binaries-syncer/src/syncer/handler.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ interface ReleaseAsset {
3131
downloadUrl: string;
3232
}
3333

34-
async function getLinuxReleaseAsset(): Promise<ReleaseAsset | undefined> {
34+
async function getLinuxReleaseAsset(runnerArch = 'x64'): Promise<ReleaseAsset | undefined> {
3535
const githubClient = new Octokit();
3636
const assets = await githubClient.repos.getLatestRelease({
3737
owner: 'actions',
3838
repo: 'runner',
3939
});
40-
const linuxAssets = assets.data.assets?.filter((a) => a.name?.includes('actions-runner-linux-x64-'));
40+
const linuxAssets = assets.data.assets?.filter((a) => a.name?.includes(`actions-runner-linux-${runnerArch}-`));
4141

4242
return linuxAssets?.length === 1
4343
? { name: linuxAssets[0].name, downloadUrl: linuxAssets[0].browser_download_url }
@@ -73,6 +73,8 @@ async function uploadToS3(s3: S3, cacheObject: CacheObject, actionRunnerReleaseA
7373
export const handle = async (): Promise<void> => {
7474
const s3 = new AWS.S3();
7575

76+
const runnerArch = process.env.GITHUB_RUNNER_ARCHITECTURE || 'x64'
77+
7678
const cacheObject: CacheObject = {
7779
bucket: process.env.S3_BUCKET_NAME as string,
7880
key: process.env.S3_OBJECT_KEY as string,
@@ -81,7 +83,7 @@ export const handle = async (): Promise<void> => {
8183
throw Error('Please check all mandatory variables are set.');
8284
}
8385

84-
const actionRunnerReleaseAsset = await getLinuxReleaseAsset();
86+
const actionRunnerReleaseAsset = await getLinuxReleaseAsset(runnerArch);
8587
if (actionRunnerReleaseAsset === undefined) {
8688
throw Error('Cannot find GitHub release asset.');
8789
}

modules/runner-binaries-syncer/runner-binaries-syncer.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ resource "aws_lambda_function" "syncer" {
1616
variables = {
1717
S3_BUCKET_NAME = aws_s3_bucket.action_dist.id
1818
S3_OBJECT_KEY = local.action_runner_distribution_object_key
19+
GITHUB_RUNNER_ARCHITECTURE = var.runner_architecture
1920
}
2021
}
2122

modules/runner-binaries-syncer/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,9 @@ variable "role_path" {
4848
type = string
4949
default = null
5050
}
51+
52+
variable "runner_architecture" {
53+
description = "The platform architecture for the runner instance (x64, arm64), defaults to 'x64'"
54+
type = string
55+
default = "x64"
56+
}

modules/runners/templates/user-data.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,56 @@ aws s3 cp ${s3_location_runner_distribution} actions-runner.tar.gz
2020
tar xzf ./actions-runner.tar.gz
2121
rm -rf actions-runner.tar.gz
2222

23+
# Patch for ARM64 (no ICU install by default)
24+
yum install -y patch
25+
patch -p1 <<ICU_PATCH
26+
diff -Naur a/bin/Runner.Listener.runtimeconfig.json b/bin/Runner.Listener.runtimeconfig.json
27+
--- a/bin/Runner.Listener.runtimeconfig.json 2020-07-01 02:21:09.000000000 +0000
28+
+++ b/bin/Runner.Listener.runtimeconfig.json 2020-07-28 00:02:38.748868613 +0000
29+
@@ -8,7 +8,8 @@
30+
}
31+
],
32+
"configProperties": {
33+
- "System.Runtime.TieredCompilation.QuickJit": true
34+
+ "System.Runtime.TieredCompilation.QuickJit": true,
35+
+ "System.Globalization.Invariant": true
36+
}
37+
}
38+
-}
39+
\ No newline at end of file
40+
+}
41+
diff -Naur a/bin/Runner.PluginHost.runtimeconfig.json b/bin/Runner.PluginHost.runtimeconfig.json
42+
--- a/bin/Runner.PluginHost.runtimeconfig.json 2020-07-01 02:21:22.000000000 +0000
43+
+++ b/bin/Runner.PluginHost.runtimeconfig.json 2020-07-28 00:02:59.358680003 +0000
44+
@@ -8,7 +8,8 @@
45+
}
46+
],
47+
"configProperties": {
48+
- "System.Runtime.TieredCompilation.QuickJit": true
49+
+ "System.Runtime.TieredCompilation.QuickJit": true,
50+
+ "System.Globalization.Invariant": true
51+
}
52+
}
53+
-}
54+
\ No newline at end of file
55+
+}
56+
diff -Naur a/bin/Runner.Worker.runtimeconfig.json b/bin/Runner.Worker.runtimeconfig.json
57+
--- a/bin/Runner.Worker.runtimeconfig.json 2020-07-01 02:21:16.000000000 +0000
58+
+++ b/bin/Runner.Worker.runtimeconfig.json 2020-07-28 00:02:19.159028531 +0000
59+
@@ -8,7 +8,8 @@
60+
}
61+
],
62+
"configProperties": {
63+
- "System.Runtime.TieredCompilation.QuickJit": true
64+
+ "System.Runtime.TieredCompilation.QuickJit": true,
65+
+ "System.Globalization.Invariant": true
66+
}
67+
}
68+
-}
69+
\ No newline at end of file
70+
+}
71+
ICU_PATCH
72+
2373
INSTANCE_ID=$(wget -q -O - http://169.254.169.254/latest/meta-data/instance-id)
2474
REGION=$(curl -s 169.254.169.254/latest/dynamic/instance-identity/document | jq -r .region)
2575

0 commit comments

Comments
 (0)