Skip to content

Commit ca3e394

Browse files
authored
Build OCaml 5 files in CI (#189)
* Add CI * Add more things to CI * try to fix up ocaml build * more introspectable builds of mls and mlis * Add menhir * Move more useful pieces into the script that users can run
1 parent 28616a6 commit ca3e394

File tree

2 files changed

+134
-0
lines changed

2 files changed

+134
-0
lines changed

.github/workflows/jane_ocaml5.yml

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: jane_ocaml5
2+
on: [push, pull_request]
3+
jobs:
4+
jane_ocaml5:
5+
name: Check that resolved files build
6+
runs-on: ubuntu-latest
7+
steps:
8+
- name: Cache OCaml 4.14, dune, and menhir
9+
uses: actions/cache@v2
10+
id: cache
11+
with:
12+
path: ${{ github.workspace }}/ocaml-414/_install
13+
key: ocaml-414-dune-361-menhir-20210419--v1
14+
15+
- name: Checkout OCaml 4.14
16+
uses: actions/checkout@master
17+
if: steps.cache.outputs.cache-hit != 'true'
18+
with:
19+
repository: 'ocaml/ocaml'
20+
path: 'ocaml-414'
21+
ref: '4.14'
22+
23+
- name: Build OCaml 4.14
24+
if: steps.cache.outputs.cache-hit != 'true'
25+
working-directory: ocaml-414
26+
run: |
27+
./configure --prefix=$GITHUB_WORKSPACE/ocaml-414/_install
28+
make -j $J world.opt
29+
make install
30+
# Remove unneeded parts to shrink cache file
31+
rm -rf $GITHUB_WORKSPACE/ocaml-414/_install/{lib/ocaml/expunge,bin/*.byte}
32+
33+
- name: Checkout dune github repo
34+
uses: actions/checkout@master
35+
if: steps.cache.outputs.cache-hit != 'true'
36+
with:
37+
repository: 'ocaml/dune'
38+
ref: '3.6.1'
39+
path: 'dune'
40+
41+
- name: Build dune
42+
working-directory: dune
43+
if: steps.cache.outputs.cache-hit != 'true'
44+
run: |
45+
PATH=$GITHUB_WORKSPACE/ocaml-414/_install/bin:$PATH make release
46+
cp _boot/dune.exe $GITHUB_WORKSPACE/ocaml-414/_install/bin/dune
47+
48+
- name: Checkout menhir github repo
49+
uses: actions/checkout@master
50+
if: steps.cache.outputs.cache-hit != 'true'
51+
with:
52+
repository: 'LexiFi/menhir'
53+
ref: '20210419'
54+
path: 'menhir'
55+
56+
- name: Build menhir
57+
working-directory: menhir
58+
if: steps.cache.outputs.cache-hit != 'true'
59+
run: |
60+
PATH=$GITHUB_WORKSPACE/ocaml-414/_install/bin:$PATH dune build
61+
cp _build/install/default/bin/menhir $GITHUB_WORKSPACE/ocaml-414/_install/bin/menhir
62+
# Our dune rule uses `menhirLib.mli`, which we can't simply `cp`
63+
# because it's a symbolic link to a relative path.
64+
export TARGET_FILE=$GITHUB_WORKSPACE/ocaml-414/_install/lib/menhirLib/menhirLib.mli
65+
mkdir -p $(dirname $TARGET_FILE)
66+
cat _build/install/default/lib/menhirLib/menhirLib.mli > $TARGET_FILE
67+
68+
- name: Checkout the ocaml-jst repo
69+
uses: actions/checkout@master
70+
with:
71+
path: 'ocaml-jst'
72+
73+
- name: Configure
74+
working-directory: ocaml-jst
75+
run: |
76+
./configure --prefix=$GITHUB_WORKSPACE/ocaml-5/_install --with-dune=$GITHUB_WORKSPACE/ocaml-414/_install/bin/dune
77+
78+
- name: Check that resolved files build
79+
working-directory: ocaml-jst
80+
run: |
81+
export PATH=$GITHUB_WORKSPACE/ocaml-414/_install/bin:$PATH
82+
jane/build-resolved-files-for-ci

jane/build-resolved-files-for-ci

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
make -f Makefile.jst _build/_bootinstall
6+
7+
echo "==========="
8+
echo "Testing mlis"
9+
echo "==========="
10+
11+
# ocamlcommon mlis
12+
mlis=$(
13+
{ echo parsing/parser.mli
14+
echo {utils,typing,parsing,lambda}/*.mli
15+
} |
16+
tr ' ' '\n'
17+
)
18+
echo "$mlis"
19+
dune_targets=$(
20+
for mli in $mlis; do
21+
cmi=$(basename ${mli%.mli})
22+
echo _build/default/.ocamlcommon.objs/byte/$cmi.cmi
23+
done
24+
)
25+
echo "Dune targets:"
26+
echo "$dune_targets"
27+
dune b --workspace=duneconf/boot.ws $dune_targets
28+
29+
echo "==========="
30+
echo "Testing mls"
31+
echo "==========="
32+
33+
# ocamlcommon mls
34+
mls=$(
35+
{ echo parsing/parser.ml
36+
echo {utils,parsing}/*.ml
37+
} |
38+
tr ' ' '\n' |
39+
grep -v "utils/config.common.ml" |
40+
grep -v "utils/config.fixed.ml" |
41+
grep -v "utils/config.generated.ml"
42+
)
43+
echo "$mls"
44+
dune_targets=$(
45+
for ml in $mls; do
46+
cmx=$(basename ${ml%.ml})
47+
echo _build/default/.ocamlcommon.objs/native/$cmx.cmx
48+
done
49+
)
50+
echo "Dune targets:"
51+
echo "$dune_targets"
52+
dune b --workspace=duneconf/boot.ws $dune_targets

0 commit comments

Comments
 (0)