Skip to content

Commit 3d810f2

Browse files
authored
CI: build statically linked Linux arm64 binaries (#6098)
* dune build --display quiet * Build static arm64 Linux binaries
1 parent 8fbe1c1 commit 3d810f2

File tree

4 files changed

+71
-7
lines changed

4 files changed

+71
-7
lines changed

.github/workflows/ci.yml

Lines changed: 65 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,27 @@ jobs:
2121
# The container already comes with all required tools pre-installed
2222
# (see https://github.com/rescript-lang/docker-rescript-ci-build/blob/main/Dockerfile).
2323
static-binaries-linux:
24-
runs-on: ubuntu-latest
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
os: [ubuntu-latest, buildjet-2vcpu-ubuntu-2204-arm]
28+
29+
runs-on: ${{matrix.os}}
2530

2631
container:
27-
image: ghcr.io/rescript-lang/rescript-ci-build:v1.0.0
32+
image: ghcr.io/rescript-lang/rescript-ci-build:v1.1.0
2833

2934
steps:
35+
# See https://github.com/actions/runner/issues/801#issuecomment-1374967227.
36+
- name: Workaround for Github actions runner on Alpine arm64
37+
if: runner.arch == 'ARM64'
38+
run: sed -i "s:ID=alpine:ID=NotpineForGHA:" /etc/os-release
39+
3040
- name: Checkout
3141
uses: actions/checkout@v3
3242

3343
- name: Build compiler binaries
34-
run: opam exec -- dune build --profile static
44+
run: opam exec -- dune build --display quiet --profile static
3545

3646
- name: Build ninja binary
3747
working-directory: ninja
@@ -42,11 +52,52 @@ jobs:
4252
- name: "Upload artifacts"
4353
uses: actions/upload-artifact@v3
4454
with:
45-
name: static-binaries-linux
55+
name: static-binaries-linux-${{runner.arch}}
4656
path: |
4757
_build/install/default/bin
4858
ninja/ninja
4959
60+
# The full build including tests does not work on Linux ARM because setup-ocaml fails.
61+
# Therefore, only upload the binaries from the static build
62+
upload-linux-arm64-binaries:
63+
needs:
64+
- static-binaries-linux
65+
66+
runs-on: buildjet-2vcpu-ubuntu-2204-arm
67+
68+
steps:
69+
- name: Checkout
70+
uses: actions/checkout@v3
71+
72+
- name: Download static linux binaries
73+
if: runner.os == 'Linux'
74+
uses: actions/download-artifact@v3
75+
with:
76+
name: static-binaries-linux-${{ runner.arch }}
77+
78+
- name: Make static linux binaries executable
79+
if: runner.os == 'Linux'
80+
run: |
81+
chmod +x ninja/ninja
82+
chmod +x _build/install/default/bin/*
83+
84+
- name: Use Node.js
85+
uses: actions/setup-node@v3
86+
with:
87+
node-version: 16
88+
89+
- name: Copy exes to platform bin dirs
90+
run: node ./scripts/copyExes.js
91+
92+
- name: Prepare artifact upload
93+
run: node .github/workflows/get_artifact_info.js
94+
95+
- name: "Upload artifacts: binaries"
96+
uses: actions/upload-artifact@v3
97+
with:
98+
name: ${{ env.artifact_name }}
99+
path: ${{ env.artifact_path }}
100+
50101
build:
51102
needs: static-binaries-linux
52103

@@ -77,7 +128,7 @@ jobs:
77128
if: runner.os == 'Linux'
78129
uses: actions/download-artifact@v3
79130
with:
80-
name: static-binaries-linux
131+
name: static-binaries-linux-${{ runner.arch }}
81132

82133
- name: Make static linux binaries executable
83134
if: runner.os == 'Linux'
@@ -97,7 +148,7 @@ jobs:
97148

98149
- name: "Build compiler"
99150
if: runner.os != 'Linux'
100-
run: opam exec -- dune build --profile release
151+
run: opam exec -- dune build --display quiet --profile release
101152

102153
- name: Use Node.js
103154
uses: actions/setup-node@v3
@@ -236,7 +287,14 @@ jobs:
236287
strategy:
237288
fail-fast: false
238289
matrix:
239-
os: [macos-latest, ubuntu-latest, windows-latest, macos-arm]
290+
os:
291+
[
292+
macos-latest,
293+
macos-arm,
294+
ubuntu-latest,
295+
buildjet-2vcpu-ubuntu-2204-arm,
296+
windows-latest,
297+
]
240298

241299
runs-on: ${{matrix.os}}
242300

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"darwin",
3232
"darwinarm64",
3333
"linux",
34+
"linuxarm64",
3435
"win32",
3536
"docs/docson/build-schema.json",
3637
"lib",

packages/artifacts.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,10 @@ linux/bsb_helper.exe
965965
linux/bsc.exe
966966
linux/ninja.exe
967967
linux/rescript.exe
968+
linuxarm64/bsb_helper.exe
969+
linuxarm64/bsc.exe
970+
linuxarm64/ninja.exe
971+
linuxarm64/rescript.exe
968972
ninja.COPYING
969973
package.json
970974
rescript

scripts/moveArtifacts.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ chmod +x binaries-*/*.exe
66
mv binaries-darwin darwin
77
mv binaries-darwinarm64 darwinarm64
88
mv binaries-linux linux
9+
mv binaries-linuxarm64 linuxarm64
910
mv binaries-win32 win32
1011

1112
mv cmij-cache/*.bin lib

0 commit comments

Comments
 (0)