Skip to content

Commit 10e64e5

Browse files
committed
Support GitHub Actions aarch64 runners
GitHub now offers free aarch64 runners: https://github.blog/changelog/2025-01-16-linux-arm64-hosted-runners-now-available-for-free-in-public-repositories-public-preview/ Automatically select the default apk-tools-url and arch to match the CPU architecture of the current runner. Run armv7 and armhf without QEMU on aarch64 runners. For symmetry, allow emulating x86 and x86_64 on aarch64. Document how to run aarch64 without emulation. Change existing aarch64 examples to ppc64le, to avoid encouraging emulation of aarch64. Fixes #11.
1 parent ae3b3dd commit 10e64e5

File tree

6 files changed

+71
-19
lines changed

6 files changed

+71
-19
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ jobs:
1111
- v3.10 # some old branch
1212
arch:
1313
- x86_64
14-
- aarch64 # emulated
14+
- aarch64
1515
host-os:
1616
- ubuntu-latest
1717
- ubuntu-24.04
1818
- ubuntu-22.04
19+
- ubuntu-24.04-arm
20+
- ubuntu-22.04-arm
1921
runs-on: ${{ matrix.host-os }}
2022
env:
2123
MY_JOB_VAR: 'allons-y!'
@@ -91,7 +93,12 @@ jobs:
9193
shell: alpine.sh --root {0}
9294

9395
test-multi:
94-
runs-on: ubuntu-latest
96+
runs-on: ${{ matrix.host-os }}
97+
strategy:
98+
matrix:
99+
host-os:
100+
- ubuntu-latest
101+
- ubuntu-24.04-arm
95102
steps:
96103
- uses: actions/checkout@v6
97104

README.adoc

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ URL of the apk-tools static binary to use.
5353
It must end with `#!sha256!` followed by a SHA-256 hash of the file.
5454
This should normally be left at the default value.
5555
+
56-
Default: _see link:action.yml[]_
56+
Default: _see link:setup-alpine.sh[]_
5757

5858
[[arch]] arch::
5959
CPU architecture to emulate using https://www.qemu.org/docs/master/user/main.html[QEMU user space emulator].
60-
Allowed values are: `x86_64` (native), `x86` (native), `aarch64`, `armhf` footnote:[armhf is armv6 with hard-float.], `armv7`, `loongarch64` footnote:[loongarch64 is available since v3.21.], `ppc64le`, `riscv64` footnote:[riscv64 is available since v3.20.], and `s390x`.
60+
Allowed values are: `x86_64` (native on x86_64), `x86` (native on x86_64), `aarch64` (native on aarch64), `armhf` footnote:[armhf is armv6 with hard-float.] (native on aarch64), `armv7` (native on aarch64), `loongarch64` footnote:[loongarch64 is available since v3.21.], `ppc64le`, `riscv64` footnote:[riscv64 is available since v3.20.], and `s390x`.
6161
+
62-
Default: `x86_64`
62+
Default: _runner's native architecture_
6363

6464
branch::
6565
Alpine branch (aka release) to install: `vMAJOR.MINOR`, `latest-stable`, or `edge`.
@@ -159,19 +159,34 @@ steps:
159159
----
160160

161161

162+
=== Set up and use Alpine natively on aarch64
163+
164+
[source, yaml, subs="+attributes"]
165+
----
166+
runs-on: ubuntu-24.04-arm
167+
steps:
168+
- name: Setup latest Alpine Linux
169+
uses: {action-ref}
170+
171+
- name: Run script inside Alpine chroot
172+
run: uname -m
173+
shell: alpine.sh {0}
174+
----
175+
176+
162177
=== Set up and use Alpine for a different CPU architecture
163178

164179
[source, yaml, subs="+attributes"]
165180
----
166181
runs-on: ubuntu-latest
167182
steps:
168-
- name: Setup Alpine Linux {alpine-latest} for aarch64
183+
- name: Setup Alpine Linux {alpine-latest} for ppc64le
169184
uses: {action-ref}
170185
with:
171-
arch: aarch64
186+
arch: ppc64le
172187
branch: {alpine-latest}
173188
174-
- name: Run script inside Alpine chroot with aarch64 emulation
189+
- name: Run script inside Alpine chroot with ppc64le emulation
175190
run: uname -m
176191
shell: alpine.sh {0}
177192
----
@@ -200,19 +215,19 @@ steps:
200215
with:
201216
shell-name: alpine-x86_64.sh
202217
203-
- name: Setup latest Alpine Linux for aarch64
218+
- name: Setup latest Alpine Linux for ppc64le
204219
uses: {action-ref}
205220
with:
206-
arch: aarch64
207-
shell-name: alpine-aarch64.sh
221+
arch: ppc64le
222+
shell-name: alpine-ppc64le.sh
208223
209224
- name: Run script inside Alpine chroot
210225
run: uname -m
211226
shell: alpine-x86_64.sh {0}
212227
213-
- name: Run script inside Alpine chroot with aarch64 emulation
228+
- name: Run script inside Alpine chroot with ppc64le emulation
214229
run: uname -m
215-
shell: alpine-aarch64.sh {0}
230+
shell: alpine-ppc64le.sh {0}
216231
217232
- name: Run script on the host system (Ubuntu)
218233
run: cat /etc/os-release
@@ -229,8 +244,8 @@ runs-on: ubuntu-latest
229244
strategy:
230245
matrix:
231246
include:
232-
- rust-target: aarch64-unknown-linux-musl
233-
os-arch: aarch64
247+
- rust-target: ppc64le-unknown-linux-musl
248+
os-arch: ppc64le
234249
env:
235250
CROSS_SYSROOT: /mnt/alpine-${{ matrix.os-arch }}
236251
steps:

action.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,16 @@ inputs:
1212
hash of the file.
1313
This should normally be left at the default value.
1414
required: false
15-
default: https://gitlab.alpinelinux.org/api/v4/projects/5/packages/generic/v2.14.10/x86_64/apk.static#!sha256!34bb1a96f0258982377a289392d4ea9f3f4b767a4bb5806b1b87179b79ad8a1c
15+
default: ''
1616
arch:
1717
description: >
18-
CPU architecture to emulate using QEMU. Allowed values are: `x86_64` (native), `x86` (native),
19-
`aarch64`, `armhf` (armv6 with hard-float), `armv7`, `loongarch64` (available since v3.21), `ppc64le`, `riscv64` (available since v3.20), and `s390x`
18+
CPU architecture to emulate using QEMU. Allowed values are: `x86_64` (native on x86_64),
19+
`x86` (native on x86_64), `aarch64` (native on aarch64), `armhf` (armv6 with hard-float;
20+
native on aarch64), `armv7` (native on aarch64), `loongarch64` (available since v3.21),
21+
`ppc64le`, `riscv64` (available since v3.20), `s390x`, or the empty string to use the
22+
runner's native architecture.
2023
required: false
21-
default: x86_64
24+
default: ''
2225
branch:
2326
description: Alpine branch (aka release) to install (e.g. `v3.15`, `latest-stable`, `edge`).
2427
required: false

binfmts/qemu-i386

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package none
2+
interpreter /usr/local/bin/qemu-i386
3+
magic \x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x03\x00
4+
offset 0
5+
mask \xff\xff\xff\xff\xff\xfe\xfe\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff
6+
credentials yes
7+
fix_binary yes
8+
preserve yes

binfmts/qemu-x86_64

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package none
2+
interpreter /usr/local/bin/qemu-x86_64
3+
magic \x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x3e\x00
4+
offset 0
5+
mask \xff\xff\xff\xff\xff\xfe\xfe\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff
6+
credentials yes
7+
fix_binary yes
8+
preserve yes

setup-alpine.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ needs_emulator() {
8484
local host="$(qemu_arch "$(uname -m)")"
8585

8686
[ "$target" = "$host" ] && return 1
87+
[ "$host" = aarch64 ] && [ "$target" = arm ] && return 1
8788
[ "$host" = x86_64 ] && [ "$target" = i386 ] && return 1
8889
return 0
8990
}
@@ -133,12 +134,22 @@ mount_bind() {
133134

134135
case "$INPUT_APK_TOOLS_URL" in
135136
https://*\#\!sha256\!* | http://*\#\!sha256\!*) ;; # valid
137+
"")
138+
# default
139+
case "$(uname -m)" in
140+
x86_64) INPUT_APK_TOOLS_URL="https://gitlab.alpinelinux.org/api/v4/projects/5/packages/generic/v2.14.10/x86_64/apk.static#!sha256!34bb1a96f0258982377a289392d4ea9f3f4b767a4bb5806b1b87179b79ad8a1c" ;;
141+
aarch64) INPUT_APK_TOOLS_URL="https://gitlab.alpinelinux.org/api/v4/projects/5/packages/generic/v2.14.10/aarch64/apk.static#!sha256!e471d35aa221d031abe9b6288aede12a8e9f1a398954e5a2e1d1bce1727b4ef4" ;;
142+
*) die "Runner has unexpected CPU architecture $(uname -m)" \
143+
"Manually configure apk-tools-url for the runner's CPU architecture." ;;
144+
esac
145+
;;
136146
*) die 'Invalid input parameter: apk-tools-url' \
137147
"The value must start with https:// or http:// and end with '#!sha256!' followed by a SHA-256 hash of the file to be downloaded, but got: $INPUT_APK_TOOLS_URL"
138148
esac
139149

140150
case "$INPUT_ARCH" in
141151
x86_64 | x86 | aarch64 | armhf | armv7 | loongarch64 | ppc64le | riscv64 | s390x) ;; # valid
152+
"") INPUT_ARCH="$(uname -m)" ;; # default
142153
*) die 'Invalid input parameter: arch' \
143154
"Expected one of: x86_64, x86, aarch64, armhf, armv7, loongarch64, ppc64le, riscv64, s390x, but got: $INPUT_ARCH."
144155
esac

0 commit comments

Comments
 (0)