Skip to content

Commit 2046499

Browse files
committed
Add workflow using matrix.
1 parent a405046 commit 2046499

File tree

1 file changed

+119
-0
lines changed

1 file changed

+119
-0
lines changed

Diff for: .github/workflows/ocaml-all.yaml

+119
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
name: OCaml Binding CI (Ubuntu + macOS)
2+
3+
on:
4+
push:
5+
branches: [ "**" ]
6+
pull_request:
7+
branches: [ "**" ]
8+
9+
jobs:
10+
build-test:
11+
strategy:
12+
matrix:
13+
os: [ubuntu-latest, macos-latest]
14+
ocaml-version: [5.3.0]
15+
fail-fast: false
16+
runs-on: ${{ matrix.os }}
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
22+
# Cache ccache (shared across runs)
23+
- name: Cache ccache
24+
uses: actions/cache@v4
25+
with:
26+
path: ~/.ccache
27+
key: ${{ runner.os }}-ccache-${{ github.sha }}
28+
restore-keys: |
29+
${{ runner.os }}-ccache-
30+
31+
# Cache opam (compiler + packages)
32+
- name: Cache opam
33+
uses: actions/cache@v4
34+
with:
35+
path: ~/.opam
36+
key: ${{ runner.os }}-opam-${{ matrix.ocaml-version }}-${{ github.sha }}
37+
restore-keys: |
38+
${{ runner.os }}-opam-${{ matrix.ocaml-version }}-
39+
40+
# Setup OCaml via action
41+
- uses: ocaml/setup-ocaml@v3
42+
with:
43+
ocaml-compiler: ${{ matrix.ocaml-version }}
44+
opam-disable-sandboxing: true
45+
46+
# Platform-specific dependencies
47+
- name: Install system dependencies (Ubuntu)
48+
if: matrix.os == 'ubuntu-latest'
49+
run: |
50+
sudo apt-get update
51+
sudo apt-get install -y \
52+
bubblewrap m4 libgmp-dev pkg-config ninja-build ccache
53+
54+
- name: Install system dependencies (macOS)
55+
if: matrix.os == 'macos-latest'
56+
run: |
57+
brew install gmp pkg-config ninja ccache
58+
59+
- name: Install required opam packages
60+
run: opam install -y ocamlfind zarith
61+
62+
# Configure
63+
- name: Configure with CMake
64+
env:
65+
RUNNER_OS: ${{ runner.os }}
66+
CC: ${{ matrix.os == 'macos-latest' && 'ccache clang' || 'ccache gcc' }}
67+
CXX: ${{ matrix.os == 'macos-latest' && 'ccache clang++' || 'ccache g++' }}
68+
run: |
69+
mkdir -p build
70+
cd build
71+
eval $(opam env)
72+
echo "CC: $CC"
73+
echo "CXX: $CXX"
74+
echo "OCAMLFIND: $(which ocamlfind)"
75+
echo "OCAML: $(which ocamlc)"
76+
echo "OCAML_VERSION: $(ocamlc -version)"
77+
echo "OCAMLLIB: $OCAMLLIB"
78+
env | grep OCAML
79+
cmake .. \
80+
-G Ninja \
81+
-DZ3_BUILD_LIBZ3_SHARED=ON \
82+
-DZ3_BUILD_OCAML_BINDINGS=ON \
83+
-DZ3_BUILD_JAVA_BINDINGS=OFF \
84+
-DZ3_BUILD_PYTHON_BINDINGS=OFF \
85+
-DZ3_BUILD_CLI=OFF \
86+
-DZ3_BUILD_TEST_EXECUTABLES=OFF \
87+
-DCMAKE_VERBOSE_MAKEFILE=TRUE
88+
89+
- name: Build Z3 and OCaml bindings
90+
run: |
91+
ccache -z || true
92+
cd build
93+
ninja build_z3_ocaml_bindings
94+
ccache -s || true
95+
96+
- name: Compile ml_example.byte
97+
run: |
98+
ocamlfind ocamlc -o ml_example.byte \
99+
-package zarith \
100+
-linkpkg \
101+
-I build/src/api/ml \
102+
-dllpath build/src/api/ml \
103+
build/src/api/ml/z3ml.cma \
104+
examples/ml/ml_example.ml
105+
106+
- name: Run ml_example.byte
107+
run: ./ml_example.byte
108+
109+
- name: Compile ml_example (native)
110+
run: |
111+
ocamlfind ocamlopt -o ml_example \
112+
-package zarith \
113+
-linkpkg \
114+
-I build/src/api/ml \
115+
build/src/api/ml/z3ml.cmxa \
116+
examples/ml/ml_example.ml
117+
118+
- name: Run ml_example (native)
119+
run: ./ml_example

0 commit comments

Comments
 (0)