Skip to content

Commit 40669ce

Browse files
committed
CI: build Linux x64 binaries directly on runner (no docker)
1 parent 7d34b70 commit 40669ce

File tree

2 files changed

+34
-45
lines changed

2 files changed

+34
-45
lines changed

.github/workflows/ci.yml

Lines changed: 31 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,14 @@ jobs:
2424
strategy:
2525
fail-fast: false
2626
matrix:
27-
os: [
28-
macos-13, # x64
29-
macos-14, # ARM
30-
ubuntu-latest, # x64
31-
buildjet-2vcpu-ubuntu-2204-arm, # ARM
32-
windows-latest,
33-
]
3427
include:
35-
- os: macos-13
28+
- os: macos-13 # x64
3629
rust-target: x86_64-apple-darwin
37-
- os: macos-14
30+
- os: macos-14 # ARM
3831
rust-target: aarch64-apple-darwin
39-
- os: ubuntu-latest
32+
- os: ubuntu-latest # x64
4033
rust-target: x86_64-unknown-linux-musl
41-
- os: buildjet-2vcpu-ubuntu-2204-arm
34+
- os: buildjet-2vcpu-ubuntu-2204-arm # ARM
4235
rust-target: aarch64-unknown-linux-musl
4336
- os: windows-latest
4437
rust-target: x86_64-pc-windows-gnu
@@ -96,13 +89,10 @@ jobs:
9689
# for more info.
9790
# The container already comes with all required tools pre-installed
9891
# (see https://github.com/rescript-lang/docker-rescript-ci-build/blob/main/Dockerfile).
99-
static-binaries-linux:
100-
strategy:
101-
fail-fast: false
102-
matrix:
103-
os: [ubuntu-latest, buildjet-2vcpu-ubuntu-2204-arm]
104-
105-
runs-on: ${{matrix.os}}
92+
# Note: Static ARM64 binaries cannot be built directly on Ubuntu runner because of
93+
# https://github.com/ocaml/opam-repository/issues/26216
94+
static-binaries-linux-arm:
95+
runs-on: buildjet-2vcpu-ubuntu-2204-arm
10696

10797
steps:
10898
- name: Checkout
@@ -131,7 +121,7 @@ jobs:
131121
upload-linux-arm64-binaries:
132122
needs:
133123
- build-rewatch
134-
- static-binaries-linux
124+
- static-binaries-linux-arm
135125

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

@@ -140,7 +130,7 @@ jobs:
140130
uses: actions/checkout@v4
141131

142132
- name: Download static linux binaries
143-
if: runner.os == 'Linux'
133+
if: runner.os == 'Linux' && runner.arch == 'ARM64'
144134
uses: actions/download-artifact@v4
145135
with:
146136
name: static-binaries-linux-${{ runner.arch }}
@@ -171,18 +161,19 @@ jobs:
171161
build:
172162
needs:
173163
- build-rewatch
174-
- static-binaries-linux
175164

176165
strategy:
177166
fail-fast: false
178167
matrix:
179-
os: [
180-
macos-13, # x64
181-
macos-14, # ARM
182-
ubuntu-latest,
183-
windows-latest,
184-
]
185-
ocaml_compiler: [5.2.0]
168+
include:
169+
- os: macos-13 # x64
170+
ocaml_compiler: 5.2.0
171+
- os: macos-14 # ARM
172+
ocaml_compiler: 5.2.0
173+
- os: ubuntu-latest # x64
174+
ocaml_compiler: ocaml-variants.5.2.0+options,ocaml-option-static
175+
- os: windows-latest
176+
ocaml_compiler: 5.2.0
186177

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

@@ -204,12 +195,6 @@ jobs:
204195
with:
205196
fetch-depth: 2 # to be able to check for changes in subfolder jscomp/syntax later
206197

207-
- name: Download static linux binaries
208-
if: runner.os == 'Linux'
209-
uses: actions/download-artifact@v4
210-
with:
211-
name: static-binaries-linux-${{ runner.arch }}
212-
213198
- name: Get artifact dir name
214199
run: node .github/workflows/get_artifact_dir_name.js
215200

@@ -219,13 +204,6 @@ jobs:
219204
name: rewatch-${{ env.artifact_dir_name }}
220205
path: rewatch
221206

222-
- name: Make static linux binaries executable
223-
if: runner.os == 'Linux'
224-
run: |
225-
chmod +x ninja/ninja
226-
chmod +x rewatch/rewatch
227-
chmod +x _build/install/default/bin/*
228-
229207
- name: Install dependencies (Linux)
230208
if: runner.os == 'Linux'
231209
uses: awalsh128/[email protected]
@@ -239,6 +217,10 @@ jobs:
239217
with:
240218
python-version: '3.10'
241219

220+
# matrix.ocaml_compiler may contain commas
221+
- name: Get OPAM cache key
222+
run: echo "opam_cache_key=opam-env-v1-${{ matrix.os }}-${{ matrix.ocaml_compiler }}-${{ hashFiles('dune-project') }}" | sed 's/,/-/g' >> $GITHUB_ENV
223+
242224
- name: Restore OPAM environment
243225
id: cache-opam-env
244226
uses: actions/cache/restore@v4
@@ -250,7 +232,7 @@ jobs:
250232
.opam-path
251233
D:\cygwin
252234
D:\.opam
253-
key: opam-env-v1-${{ matrix.os }}-${{ matrix.ocaml_compiler }}-${{ hashFiles('dune-project') }}
235+
key: ${{ env.opam_cache_key }}
254236

255237
- name: Use OCaml ${{matrix.ocaml_compiler}}
256238
uses: ocaml/[email protected]
@@ -286,7 +268,7 @@ jobs:
286268
.opam-path
287269
D:\cygwin
288270
D:\.opam
289-
key: opam-env-v1-${{ matrix.os }}-${{ matrix.ocaml_compiler }}-${{ hashFiles('dune-project') }}
271+
key: ${{ env.opam_cache_key }}
290272

291273
- name: Use cached OPAM environment
292274
if: steps.cache-opam-env.outputs.cache-hit == 'true'
@@ -334,6 +316,10 @@ jobs:
334316
if: runner.os != 'Linux'
335317
run: opam exec -- dune build --display quiet --profile release
336318

319+
- name: Build compiler (Linux static)
320+
if: runner.os == 'Linux'
321+
run: opam exec -- dune build --display quiet --profile static
322+
337323
- name: Use Node.js
338324
uses: actions/setup-node@v4
339325
with:
@@ -349,7 +335,7 @@ jobs:
349335
arch: x64
350336

351337
- name: Build ninja
352-
if: runner.os != 'Linux'
338+
if: runner.os != 'Linux' || runner.arch != 'ARM64'
353339
run: node scripts/buildNinjaBinary.js
354340

355341
- name: Copy exes to platform bin dirs
@@ -425,7 +411,7 @@ jobs:
425411
path: ${{ env.artifact_dir_name }}
426412

427413
- name: "Upload artifacts: lib/ocaml"
428-
if: runner.os == 'Linux'
414+
if: runner.os == 'Linux' && runner.arch == 'X64'
429415
uses: actions/upload-artifact@v4
430416
with:
431417
name: lib-ocaml

scripts/buildNinjaBinary.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ if (platform === "win32") {
1414
if (process.platform === "darwin") {
1515
process.env["CXXFLAGS"] = "-flto";
1616
}
17+
else if (process.platform === "linux") {
18+
process.env["LDFLAGS"] = "-static";
19+
}
1720
child_process.execSync(buildCommand, { stdio: [0, 1, 2], cwd: ninjaDir });
1821
child_process.execSync(`strip ninja`, { stdio: [0, 1, 2], cwd: ninjaDir });
1922
}

0 commit comments

Comments
 (0)