Skip to content

Commit 6bc3b65

Browse files
committed
CI: build Linux x64 binaries directly on runner (no docker)
1 parent c0694b6 commit 6bc3b65

File tree

1 file changed

+36
-44
lines changed

1 file changed

+36
-44
lines changed

.github/workflows/ci.yml

Lines changed: 36 additions & 44 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,6 @@ jobs:
140130
uses: actions/checkout@v4
141131

142132
- name: Download static linux binaries
143-
if: runner.os == 'Linux'
144133
uses: actions/download-artifact@v4
145134
with:
146135
name: static-binaries-linux-${{ runner.arch }}
@@ -171,18 +160,19 @@ jobs:
171160
build:
172161
needs:
173162
- build-rewatch
174-
- static-binaries-linux
175163

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

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

@@ -204,12 +194,6 @@ jobs:
204194
with:
205195
fetch-depth: 2 # to be able to check for changes in subfolder jscomp/syntax later
206196

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-
213197
- name: Get artifact dir name
214198
run: node .github/workflows/get_artifact_dir_name.js
215199

@@ -219,13 +203,6 @@ jobs:
219203
name: rewatch-${{ env.artifact_dir_name }}
220204
path: rewatch
221205

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-
229206
- name: Install dependencies (Linux)
230207
if: runner.os == 'Linux'
231208
uses: awalsh128/[email protected]
@@ -239,6 +216,11 @@ jobs:
239216
with:
240217
python-version: '3.10'
241218

219+
# matrix.ocaml_compiler may contain commas
220+
- name: Get OPAM cache key
221+
shell: bash
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:
@@ -352,6 +338,12 @@ jobs:
352338
if: runner.os != 'Linux'
353339
run: node scripts/buildNinjaBinary.js
354340

341+
- name: Build ninja (Linux static)
342+
if: runner.os == 'Linux'
343+
env:
344+
LDFLAGS: -static
345+
run: node scripts/buildNinjaBinary.js
346+
355347
- name: Copy exes to platform bin dirs
356348
run: node ./scripts/copyExes.js
357349

@@ -425,7 +417,7 @@ jobs:
425417
path: ${{ env.artifact_dir_name }}
426418

427419
- name: "Upload artifacts: lib/ocaml"
428-
if: runner.os == 'Linux'
420+
if: runner.os == 'Linux' && runner.arch == 'X64'
429421
uses: actions/upload-artifact@v4
430422
with:
431423
name: lib-ocaml

0 commit comments

Comments
 (0)