Skip to content

CI: build statically linked Linux arm64 binaries #6098

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 65 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,27 @@ jobs:
# The container already comes with all required tools pre-installed
# (see https://github.com/rescript-lang/docker-rescript-ci-build/blob/main/Dockerfile).
static-binaries-linux:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, buildjet-2vcpu-ubuntu-2204-arm]

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

container:
image: ghcr.io/rescript-lang/rescript-ci-build:v1.0.0
image: ghcr.io/rescript-lang/rescript-ci-build:v1.1.0

steps:
# See https://github.com/actions/runner/issues/801#issuecomment-1374967227.
- name: Workaround for Github actions runner on Alpine arm64
if: runner.arch == 'ARM64'
run: sed -i "s:ID=alpine:ID=NotpineForGHA:" /etc/os-release

- name: Checkout
uses: actions/checkout@v3

- name: Build compiler binaries
run: opam exec -- dune build --profile static
run: opam exec -- dune build --display quiet --profile static

- name: Build ninja binary
working-directory: ninja
Expand All @@ -42,11 +52,52 @@ jobs:
- name: "Upload artifacts"
uses: actions/upload-artifact@v3
with:
name: static-binaries-linux
name: static-binaries-linux-${{runner.arch}}
path: |
_build/install/default/bin
ninja/ninja

# The full build including tests does not work on Linux ARM because setup-ocaml fails.
# Therefore, only upload the binaries from the static build
upload-linux-arm64-binaries:
needs:
- static-binaries-linux

runs-on: buildjet-2vcpu-ubuntu-2204-arm

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Download static linux binaries
if: runner.os == 'Linux'
uses: actions/download-artifact@v3
with:
name: static-binaries-linux-${{ runner.arch }}

- name: Make static linux binaries executable
if: runner.os == 'Linux'
run: |
chmod +x ninja/ninja
chmod +x _build/install/default/bin/*

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 16

- name: Copy exes to platform bin dirs
run: node ./scripts/copyExes.js

- name: Prepare artifact upload
run: node .github/workflows/get_artifact_info.js

- name: "Upload artifacts: binaries"
uses: actions/upload-artifact@v3
with:
name: ${{ env.artifact_name }}
path: ${{ env.artifact_path }}

build:
needs: static-binaries-linux

Expand Down Expand Up @@ -77,7 +128,7 @@ jobs:
if: runner.os == 'Linux'
uses: actions/download-artifact@v3
with:
name: static-binaries-linux
name: static-binaries-linux-${{ runner.arch }}

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

- name: "Build compiler"
if: runner.os != 'Linux'
run: opam exec -- dune build --profile release
run: opam exec -- dune build --display quiet --profile release

- name: Use Node.js
uses: actions/setup-node@v3
Expand Down Expand Up @@ -236,7 +287,14 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest, macos-arm]
os:
[
macos-latest,
macos-arm,
ubuntu-latest,
buildjet-2vcpu-ubuntu-2204-arm,
windows-latest,
]

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

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"darwin",
"darwinarm64",
"linux",
"linuxarm64",
"win32",
"docs/docson/build-schema.json",
"lib",
Expand Down
4 changes: 4 additions & 0 deletions packages/artifacts.txt
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,10 @@ linux/bsb_helper.exe
linux/bsc.exe
linux/ninja.exe
linux/rescript.exe
linuxarm64/bsb_helper.exe
linuxarm64/bsc.exe
linuxarm64/ninja.exe
linuxarm64/rescript.exe
ninja.COPYING
package.json
rescript
Expand Down
1 change: 1 addition & 0 deletions scripts/moveArtifacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ chmod +x binaries-*/*.exe
mv binaries-darwin darwin
mv binaries-darwinarm64 darwinarm64
mv binaries-linux linux
mv binaries-linuxarm64 linuxarm64
mv binaries-win32 win32

mv cmij-cache/*.bin lib
Expand Down