Skip to content

Commit 0bcea77

Browse files
committed
Update deps + switch to opam on CI
1 parent 8b31e42 commit 0bcea77

File tree

8 files changed

+294
-154
lines changed

8 files changed

+294
-154
lines changed

.github/workflows/ci.yml

+205-94
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,20 @@ on:
44
pull_request:
55
branches:
66
- master
7+
push:
8+
branches:
9+
- release
710

811
jobs:
9-
build:
10-
name: Build on ${{ matrix.os }}
11-
runs-on: ${{ matrix.os }}
12+
check:
13+
name: PR check
14+
runs-on: ubuntu-latest
15+
if: ${{ github.event_name == 'pull_request' && github.base_ref == 'master' }}
1216
strategy:
1317
matrix:
18+
os: [ubuntu-latest]
19+
ocaml-version: [4.14.1]
1420
node-version: [16.x]
15-
os: [macOS-latest, windows-latest]
1621

1722
steps:
1823
- name: Checkout repo
@@ -25,7 +30,7 @@ jobs:
2530

2631
- name: Print Yarn cache
2732
id: print-yarn-cache
28-
run: echo "::set-output name=yarn-cache::$(yarn cache dir)"
33+
run: echo "yarn-cache=$(yarn cache dir)" >> $GITHUB_OUTPUT
2934

3035
- name: Restore Yarn cache
3136
id: yarn-cache
@@ -37,25 +42,16 @@ jobs:
3742
- name: Install Yarn deps
3843
run: yarn install
3944

40-
- name: Install Esy
41-
run: npm install -g [email protected]
42-
43-
- name: Install Esy deps
44-
run: esy install
45-
46-
- name: Print Esy cache
47-
id: print-esy-cache
48-
run: node .github/workflows/scripts/print-esy-cache.js
49-
50-
- name: Restore Esy cache
51-
id: esy-cache
52-
uses: actions/cache@v1
45+
- name: Setup OCaml ${{ matrix.ocaml-version }}
46+
uses: ocaml/setup-ocaml@v2
5347
with:
54-
path: ${{ steps.print-esy-cache.outputs.esy-cache }}
55-
key: ${{ matrix.os }}-esy-${{ hashFiles('**/index.json') }}
48+
ocaml-compiler: ${{ matrix.ocaml-version }}
5649

57-
- name: Build ppx
58-
run: esy build
50+
- name: Install Opam deps
51+
run: opam install . --deps-only --with-test
52+
53+
- name: Build PPX
54+
run: opam exec -- dune build
5955

6056
- name: Build ReScript lib
6157
run: |
@@ -64,69 +60,120 @@ jobs:
6460
cd ../examples
6561
yarn run build
6662
67-
- name: Run ppx tests
68-
# FIXME: Snapshot tests are broken on Win
69-
if: matrix.os != 'windows-latest'
70-
run: esy x test.exe
63+
- name: Run PPX tests
64+
run: opam exec -- dune exec test.exe
7165

7266
- name: Run integration tests
7367
run: |
7468
cd specs
7569
yarn run test
7670
71+
72+
build_linux:
73+
name: Build on ${{ matrix.container-os }}
74+
runs-on: ${{ matrix.host-os }}
75+
# if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/release' }}
76+
strategy:
77+
matrix:
78+
host-os: [ubuntu-latest]
79+
container-os: [linux-alpine]
80+
ocaml-version: [4.14.1]
81+
node-version: [16.x]
82+
container:
83+
image: alex35mil/alpine-ocaml-opam-node-yarn:alpine-3.19-ocaml-4.14-node-16.20-yarn-1.22-o5gm
84+
85+
steps:
86+
- name: Checkout repo
87+
uses: actions/checkout@v2
88+
89+
- name: Print Yarn cache
90+
id: print-yarn-cache
91+
run: echo "yarn-cache=$(yarn cache dir)" >> $GITHUB_OUTPUT
92+
93+
- name: Restore Yarn cache
94+
id: yarn-cache
95+
uses: actions/cache@v1
96+
with:
97+
path: ${{ steps.print-yarn-cache.outputs.yarn-cache }}
98+
key: ${{ matrix.container-os }}-yarn-${{ hashFiles('**/yarn.lock') }}
99+
100+
- name: Install Yarn deps
101+
run: yarn install
102+
103+
- name: Setup OCaml ${{ matrix.ocaml-version }}
104+
run: opam init -a --disable-sandboxing --compiler=${{ matrix.ocaml-version }}
105+
106+
- name: Install Opam deps
107+
run: opam install . --deps-only --with-test
108+
109+
- name: Build PPX
110+
run: opam exec -- dune build --profile static
111+
112+
- name: Build ReScript lib
113+
run: |
114+
cd lib
115+
yarn run build
116+
cd ../examples
117+
yarn run build
118+
119+
- name: Run PPX tests
120+
run: opam exec -- dune exec test.exe
121+
122+
# NOTE: Integration tests are broken on Alpine
123+
# - name: Run integration tests
124+
# run: |
125+
# cd specs
126+
# yarn run test
127+
77128
- name: Upload artifacts
78129
uses: actions/upload-artifact@v1
79130
with:
80-
name: ${{ matrix.os }}
131+
name: ${{ matrix.container-os }}
81132
path: _build/default/ppx/bin/bin.exe
82133

83-
build_linux:
134+
build_macos:
84135
name: Build on ${{ matrix.os }}
85136
runs-on: ${{ matrix.os }}
137+
# if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/release' }}
86138
strategy:
87139
matrix:
88-
os: [ubuntu-latest]
89-
90-
container:
91-
image: alexfedoseev/alpine-node-yarn-esy:0.0.10
140+
os: [macos-13, macos-14]
141+
ocaml-version: [4.14.1]
142+
node-version: [16.x]
92143

93144
steps:
94145
- name: Checkout repo
95146
uses: actions/checkout@v2
96147

97-
- name: Apply static linking patch
98-
run: git apply linux.patch
148+
- name: Setup Node ${{ matrix.node-version }}
149+
uses: actions/setup-node@v1
150+
with:
151+
node-version: ${{ matrix.node-version }}
99152

100153
- name: Print Yarn cache
101154
id: print-yarn-cache
102-
run: echo "::set-output name=yarn-cache::$(yarn cache dir)"
155+
run: echo "yarn-cache=$(yarn cache dir)" >> $GITHUB_OUTPUT
103156

104157
- name: Restore Yarn cache
105158
id: yarn-cache
106159
uses: actions/cache@v1
107160
with:
108161
path: ${{ steps.print-yarn-cache.outputs.yarn-cache }}
109-
key: ${{ matrix.os }}-yarn-${{ hashFiles('yarn.lock') }}-v1
162+
key: ${{ matrix.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
110163

111164
- name: Install Yarn deps
112165
run: yarn install
113166

114-
- name: Install Esy deps
115-
run: esy install
116-
117-
- name: Print Esy cache
118-
id: print-esy-cache
119-
run: node .github/workflows/scripts/print-esy-cache.js
120-
121-
- name: Restore Esy cache
122-
id: esy-cache
123-
uses: actions/cache@v1
167+
- name: Setup OCaml ${{ matrix.ocaml-version }}
168+
uses: ocaml/setup-ocaml@v2
124169
with:
125-
path: ${{ steps.print-esy-cache.outputs.esy-cache }}
126-
key: ${{ matrix.os }}-esy-${{ hashFiles('esy.lock/index.json') }}
170+
ocaml-compiler: ${{ matrix.ocaml-version }}
171+
172+
- name: Install Opam deps
173+
run: opam install . --deps-only --with-test
127174

128-
- name: Build ppx
129-
run: esy build
175+
- name: Build PPX
176+
run: opam exec -- dune build
130177

131178
- name: Build ReScript lib
132179
run: |
@@ -135,27 +182,29 @@ jobs:
135182
cd ../examples
136183
yarn run build
137184
138-
- name: Run ppx tests
139-
run: esy x test.exe
185+
- name: Run PPX tests
186+
run: opam exec -- dune exec test.exe
140187

141-
# FIXME: Integration tests are broken on Linux
142-
# - name: Run integration tests
143-
# run: |
144-
# cd specs
145-
# yarn run test
188+
- name: Run integration tests
189+
run: |
190+
cd specs
191+
yarn run test
146192
147193
- name: Upload artifacts
148194
uses: actions/upload-artifact@v1
149195
with:
150196
name: ${{ matrix.os }}
151197
path: _build/default/ppx/bin/bin.exe
152198

153-
rc:
154-
needs:
155-
- build
156-
- build_linux
157-
name: Prepare RC
158-
runs-on: ubuntu-latest
199+
build_windows:
200+
name: Build on ${{ matrix.os }}
201+
runs-on: ${{ matrix.os }}
202+
# if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/release' }}
203+
strategy:
204+
matrix:
205+
os: [windows-latest]
206+
ocaml-version: [4.14.1]
207+
node-version: [16.x]
159208

160209
steps:
161210
- name: Checkout repo
@@ -164,45 +213,107 @@ jobs:
164213
- name: Setup Node ${{ matrix.node-version }}
165214
uses: actions/setup-node@v1
166215
with:
167-
node-version: 16.x
216+
node-version: ${{ matrix.node-version }}
168217

169-
- name: Download Linux artifacts
170-
uses: actions/download-artifact@v1
171-
with:
172-
name: ubuntu-latest
173-
path: _bin/linux
218+
- name: Print Yarn cache
219+
id: print-yarn-cache
220+
run: echo "::set-output name=yarn-cache::$(yarn cache dir)" # Using the old way as the new way doesn't work on windows
174221

175-
- name: Download macOS artifacts
176-
uses: actions/download-artifact@v1
222+
- name: Restore Yarn cache
223+
id: yarn-cache
224+
uses: actions/cache@v1
177225
with:
178-
name: macOS-latest
179-
path: _bin/darwin
226+
path: ${{ steps.print-yarn-cache.outputs.yarn-cache }}
227+
key: ${{ matrix.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
180228

181-
- name: Download Windows artifacts
182-
uses: actions/download-artifact@v1
229+
- name: Install Yarn deps
230+
run: yarn install
231+
232+
- name: Setup OCaml ${{ matrix.ocaml-version }}
233+
uses: ocaml/setup-ocaml@v2
183234
with:
184-
name: windows-latest
185-
path: _bin/windows
235+
ocaml-compiler: ${{ matrix.ocaml-version }}
186236

187-
- name: Move artifacts
237+
- name: Install Opam deps
238+
run: opam install . --deps-only --with-test
239+
240+
- name: Build PPX
241+
run: opam exec -- dune build
242+
243+
- name: Build ReScript lib
188244
run: |
189-
mkdir -p _release/bin
190-
mv _bin/darwin/bin.exe _release/bin/re-formality-ppx-darwin-x64.exe
191-
mv _bin/windows/bin.exe _release/bin/re-formality-ppx-win-x64.exe
192-
mv _bin/linux/bin.exe _release/bin/re-formality-ppx-linux-x64.exe
193-
rm -rf _bin
245+
cd lib
246+
yarn run build
247+
cd ../examples
248+
yarn run build
194249
195-
- name: Move lib files
250+
- name: Run PPX tests
251+
run: opam exec -- dune exec test.exe
252+
253+
- name: Run integration tests
196254
run: |
197-
mkdir -p _release/src
198-
cp README.md _release/README.md
199-
cp lib/bsconfig.json _release/bsconfig.json
200-
cp -a lib/src/. _release/src/
201-
cp .github/workflows/scripts/postinstall.js _release/postinstall.js
202-
node .github/workflows/scripts/write-package-json.js
203-
204-
- name: Upload release
255+
cd specs
256+
yarn run test
257+
258+
- name: Upload artifacts
205259
uses: actions/upload-artifact@v1
206260
with:
207-
name: release
208-
path: _release
261+
name: ${{ matrix.os }}
262+
path: _build/default/ppx/bin/bin.exe
263+
264+
# rc:
265+
# needs:
266+
# - build
267+
# - build_linux
268+
# name: Prepare RC
269+
# runs-on: ubuntu-latest
270+
#
271+
# steps:
272+
# - name: Checkout repo
273+
# uses: actions/checkout@v2
274+
#
275+
# - name: Setup Node ${{ matrix.node-version }}
276+
# uses: actions/setup-node@v1
277+
# with:
278+
# node-version: 16.x
279+
#
280+
# - name: Download Linux artifacts
281+
# uses: actions/download-artifact@v1
282+
# with:
283+
# name: ubuntu-latest
284+
# path: _bin/linux
285+
#
286+
# - name: Download macOS artifacts
287+
# uses: actions/download-artifact@v1
288+
# with:
289+
# name: macOS-latest
290+
# path: _bin/darwin
291+
#
292+
# - name: Download Windows artifacts
293+
# uses: actions/download-artifact@v1
294+
# with:
295+
# name: windows-latest
296+
# path: _bin/windows
297+
#
298+
# - name: Move artifacts
299+
# run: |
300+
# mkdir -p _release/bin
301+
# mv _bin/darwin/bin.exe _release/bin/re-formality-ppx-darwin-x64.exe
302+
# mv _bin/windows/bin.exe _release/bin/re-formality-ppx-win-x64.exe
303+
# mv _bin/linux/bin.exe _release/bin/re-formality-ppx-linux-x64.exe
304+
# rm -rf _bin
305+
#
306+
# - name: Move lib files
307+
# run: |
308+
# mkdir -p _release/src
309+
# cp README.md _release/README.md
310+
# cp lib/bsconfig.json _release/bsconfig.json
311+
# cp -a lib/src/. _release/src/
312+
# cp .github/workflows/scripts/postinstall.js _release/postinstall.js
313+
# node .github/workflows/scripts/write-package-json.js
314+
#
315+
# - name: Upload release
316+
# uses: actions/upload-artifact@v1
317+
# with:
318+
# name: release
319+
# path: _release

0 commit comments

Comments
 (0)