Skip to content

Commit 5fb2f95

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

File tree

1 file changed

+111
-0
lines changed

1 file changed

+111
-0
lines changed

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

+111
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
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-local-packages: |
45+
ocamlfind
46+
zarith
47+
opam-disable-sandboxing: true
48+
49+
# Platform-specific dependencies
50+
- name: Install system dependencies (Ubuntu)
51+
if: matrix.os == 'ubuntu-latest'
52+
run: |
53+
sudo apt-get update
54+
sudo apt-get install -y \
55+
bubblewrap m4 libgmp-dev pkg-config ninja-build ccache
56+
57+
- name: Install system dependencies (macOS)
58+
if: matrix.os == 'macos-latest'
59+
run: |
60+
brew install gmp pkg-config ninja ccache
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+
opam exec -- cmake .. \
72+
-G Ninja \
73+
-DZ3_BUILD_LIBZ3_SHARED=ON \
74+
-DZ3_BUILD_OCAML_BINDINGS=ON \
75+
-DZ3_BUILD_JAVA_BINDINGS=OFF \
76+
-DZ3_BUILD_PYTHON_BINDINGS=OFF \
77+
-DZ3_BUILD_CLI=OFF \
78+
-DZ3_BUILD_TEST_EXECUTABLES=OFF \
79+
-DCMAKE_VERBOSE_MAKEFILE=TRUE
80+
81+
- name: Build Z3 and OCaml bindings
82+
run: |
83+
ccache -z || true
84+
cd build
85+
ninja build_z3_ocaml_bindings
86+
ccache -s || true
87+
88+
- name: Compile ml_example.byte
89+
run: |
90+
ocamlfind ocamlc -o ml_example.byte \
91+
-package zarith \
92+
-linkpkg \
93+
-I build/src/api/ml \
94+
-dllpath build/src/api/ml \
95+
build/src/api/ml/z3ml.cma \
96+
examples/ml/ml_example.ml
97+
98+
- name: Run ml_example.byte
99+
run: ./ml_example.byte
100+
101+
- name: Compile ml_example (native)
102+
run: |
103+
ocamlfind ocamlopt -o ml_example \
104+
-package zarith \
105+
-linkpkg \
106+
-I build/src/api/ml \
107+
build/src/api/ml/z3ml.cmxa \
108+
examples/ml/ml_example.ml
109+
110+
- name: Run ml_example (native)
111+
run: ./ml_example

0 commit comments

Comments
 (0)