Skip to content

Commit ffff653

Browse files
committed
Build rewatch in CI
1 parent 0480d0d commit ffff653

File tree

6 files changed

+113
-32
lines changed

6 files changed

+113
-32
lines changed

.github/workflows/ci.yml

Lines changed: 88 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,67 @@ env:
2020
OCAMLRUNPARAM: b
2121

2222
jobs:
23+
build-rewatch:
24+
strategy:
25+
fail-fast: false
26+
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+
]
34+
include:
35+
- os: macos-13
36+
rust-target: x86_64-apple-darwin
37+
- os: macos-14
38+
rust-target: aarch64-apple-darwin
39+
- os: ubuntu-latest
40+
rust-target: x86_64-unknown-linux-musl
41+
- os: buildjet-2vcpu-ubuntu-2204-arm
42+
rust-target: aarch64-unknown-linux-musl
43+
- os: windows-latest
44+
rust-target: x86_64-pc-windows-gnu
45+
46+
runs-on: ${{matrix.os}}
47+
48+
env:
49+
RUST_BACKTRACE: "1"
50+
SCCACHE_GHA_ENABLED: "true"
51+
RUSTC_WRAPPER: "sccache"
52+
53+
steps:
54+
- name: Checkout
55+
uses: actions/checkout@v4
56+
57+
- name: Install musl gcc
58+
if: runner.os == 'Linux'
59+
run: sudo apt-get install -y musl-tools
60+
61+
- name: Set up sccache
62+
uses: mozilla-actions/sccache-action@v0.0.4
63+
with:
64+
version: "v0.8.0"
65+
66+
- name: Install rust toolchain
67+
uses: dtolnay/rust-toolchain@master
68+
with:
69+
toolchain: stable
70+
targets: ${{matrix.rust-target}}
71+
72+
- name: Build rewatch
73+
run: cargo build --manifest-path rewatch/Cargo.toml --target ${{matrix.rust-target}} --release
74+
75+
- name: Get artifact dir name
76+
run: node .github/workflows/get_artifact_dir_name.js
77+
78+
- name: "Upload artifact: rewatch binary"
79+
uses: actions/upload-artifact@v4
80+
with:
81+
name: rewatch-${{env.artifact_dir_name}}
82+
path: rewatch/target/${{matrix.rust-target}}/release/rewatch${{ runner.os == 'Windows' && '.exe' || '' }}
83+
2384
# Build statically linked Linux binaries in an Alpine-based Docker container
2485
# See https://ocamlpro.com/blog/2021_09_02_generating_static_and_portable_executables_with_ocaml
2586
# for more info.
@@ -59,6 +120,7 @@ jobs:
59120
# Therefore, only upload the binaries from the static build
60121
upload-linux-arm64-binaries:
61122
needs:
123+
- build-rewatch
62124
- static-binaries-linux
63125

64126
runs-on: buildjet-2vcpu-ubuntu-2204-arm
@@ -73,31 +135,33 @@ jobs:
73135
with:
74136
name: static-binaries-linux-${{ runner.arch }}
75137

76-
- name: Make static linux binaries executable
77-
if: runner.os == 'Linux'
78-
run: |
79-
chmod +x ninja/ninja
80-
chmod +x _build/install/default/bin/*
81-
82138
- name: Use Node.js
83139
uses: actions/setup-node@v4
84140
with:
85141
node-version: 18
86142

143+
- name: Get artifact dir name
144+
run: node .github/workflows/get_artifact_dir_name.js
145+
146+
- name: Download rewatch binary
147+
uses: actions/download-artifact@v4
148+
with:
149+
name: rewatch-${{ env.artifact_dir_name }}
150+
path: rewatch
151+
87152
- name: Copy exes to platform bin dirs
88153
run: node ./scripts/copyExes.js
89154

90-
- name: Prepare artifact upload
91-
run: node .github/workflows/get_artifact_info.js
92-
93155
- name: "Upload artifacts: binaries"
94156
uses: actions/upload-artifact@v4
95157
with:
96-
name: ${{ env.artifact_name }}
97-
path: ${{ env.artifact_path }}
158+
name: binaries-${{ env.artifact_dir_name }}
159+
path: ${{ env.artifact_dir_name }}
98160

99161
build:
100-
needs: static-binaries-linux
162+
needs:
163+
- build-rewatch
164+
- static-binaries-linux
101165

102166
strategy:
103167
fail-fast: false
@@ -133,10 +197,20 @@ jobs:
133197
with:
134198
name: static-binaries-linux-${{ runner.arch }}
135199

200+
- name: Get artifact dir name
201+
run: node .github/workflows/get_artifact_dir_name.js
202+
203+
- name: Download rewatch binary
204+
uses: actions/download-artifact@v4
205+
with:
206+
name: rewatch-${{ env.artifact_dir_name }}
207+
path: rewatch
208+
136209
- name: Make static linux binaries executable
137210
if: runner.os == 'Linux'
138211
run: |
139212
chmod +x ninja/ninja
213+
chmod +x rewatch/rewatch
140214
chmod +x _build/install/default/bin/*
141215
142216
- name: Use OCaml ${{matrix.ocaml_compiler}}
@@ -252,14 +326,11 @@ jobs:
252326
KEYCDN_PASSWORD: ${{ secrets.KEYCDN_PASSWORD }}
253327
run: bash playground/upload_bundle.sh
254328

255-
- name: Prepare artifact upload
256-
run: node .github/workflows/get_artifact_info.js
257-
258329
- name: "Upload artifacts: binaries"
259330
uses: actions/upload-artifact@v4
260331
with:
261-
name: ${{ env.artifact_name }}
262-
path: ${{ env.artifact_path }}
332+
name: binaries-${{ env.artifact_dir_name }}
333+
path: ${{ env.artifact_dir_name }}
263334

264335
- name: "Upload artifacts: lib/ocaml"
265336
if: runner.os == 'Linux'
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const fs = require("fs");
2+
const os = require("os");
3+
4+
const artifactDirName = require("../../scripts/bin_path").dirName;
5+
6+
// Pass artifactDirName to subsequent GitHub actions
7+
fs.appendFileSync(
8+
process.env.GITHUB_ENV,
9+
`artifact_dir_name=${artifactDirName}${os.EOL}`
10+
);

.github/workflows/get_artifact_info.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

packages/artifacts.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ darwin/bsb_helper.exe
99
darwin/bsc.exe
1010
darwin/ninja.exe
1111
darwin/rescript.exe
12+
darwin/rewatch.exe
1213
darwinarm64/bsb_helper.exe
1314
darwinarm64/bsc.exe
1415
darwinarm64/ninja.exe
1516
darwinarm64/rescript.exe
17+
darwinarm64/rewatch.exe
1618
docs/docson/build-schema.json
1719
lib/bstracing
1820
lib/es6/arg.js
@@ -1056,10 +1058,12 @@ linux/bsb_helper.exe
10561058
linux/bsc.exe
10571059
linux/ninja.exe
10581060
linux/rescript.exe
1061+
linux/rewatch.exe
10591062
linuxarm64/bsb_helper.exe
10601063
linuxarm64/bsc.exe
10611064
linuxarm64/ninja.exe
10621065
linuxarm64/rescript.exe
1066+
linuxarm64/rewatch.exe
10631067
ninja.COPYING
10641068
package.json
10651069
rescript
@@ -1073,4 +1077,5 @@ scripts/rescript_postinstall.js
10731077
win32/bsb_helper.exe
10741078
win32/bsc.exe
10751079
win32/ninja.exe
1076-
win32/rescript.exe
1080+
win32/rescript.exe
1081+
win32/rewatch.exe

scripts/copyExes.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const { duneBinDir } = require("./dune");
88
const { absolutePath: platformBinDir } = require("./bin_path");
99

1010
const ninjaDir = path.join(__dirname, "..", "ninja");
11+
const rewatchDir = path.join(__dirname, "..", "rewatch");
1112

1213
if (!fs.existsSync(platformBinDir)) {
1314
fs.mkdirSync(platformBinDir);
@@ -34,3 +35,4 @@ copyExe(duneBinDir, "rescript");
3435
copyExe(duneBinDir, "bsc");
3536
copyExe(duneBinDir, "bsb_helper");
3637
copyExe(ninjaDir, "ninja");
38+
copyExe(rewatchDir, "rewatch");

scripts/makeArtifactList.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,13 @@ if (isCheckMode) {
4747

4848
function getFilesAddedByCI() {
4949
const platforms = ["darwin", "darwinarm64", "linux", "linuxarm64", "win32"];
50-
const exes = ["bsb_helper.exe", "bsc.exe", "ninja.exe", "rescript.exe"];
50+
const exes = [
51+
"bsb_helper.exe",
52+
"bsc.exe",
53+
"ninja.exe",
54+
"rescript.exe",
55+
"rewatch.exe",
56+
];
5157

5258
const files = ["ninja.COPYING"];
5359

0 commit comments

Comments
 (0)