diff --git a/.github/workflows/ocaml.yaml b/.github/workflows/ocaml.yaml new file mode 100644 index 00000000..19c8c65a --- /dev/null +++ b/.github/workflows/ocaml.yaml @@ -0,0 +1,86 @@ +name: OCaml + +on: + push: + branches: + - 'feature/*' + - 'bugfix/*' + - 'hotfix/*' + pull_request: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + env: + OCAML_JUPYTER_LOG: debug + strategy: + fail-fast: false + matrix: + ocaml-compiler: + - 4.11.0 + - 4.12.0 + - 4.13.0 + + steps: + - uses: actions/checkout@v2 + + - name: Setup OCaml + uses: ocaml/setup-ocaml@master + with: + ocaml-compiler: ${{ matrix.ocaml-compiler }} + + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: '3.9' + architecture: 'x64' + - name: Install Jupyter + run: pip install jupyter + + - name: Install dependencies + run: | + opam install . -y --deps-only --with-test + opam install 'merlin>3.0.0' -y + + - name: Cache dependencies + uses: actions/cache@v2 + with: + path: | + ~/.opam + ~/.local + key: ${{ runner.os }}-opam-${{ matrix.ocaml-compiler }}-${{ hashFiles('*.opam') }} + restore-keys: ${{ runner.os }}-opam-${{ matrix.ocaml-compiler }}- + + - name: Lint for opam files + run: opam lint *.opam + - name: Lint for source files + run: ./git/pre-commit + - name: Build + run: opam exec -- dune build + - name: Unit tests + run: opam exec -- dune runtest + + # ===== + # Integration tests + # ===== + + - name: Install ocaml-jupyter kernel + run: opam pin add jupyter . -y + - name: Install jupyter-archimedes + run: opam pin add jupyter-archimedes . -y + - name: Install kernelspec + run: | + ./config/ocaml-jupyter-opam-genspec + jupyter kernelspec install --user --name ocaml-jupyter "$(opam config var share)/jupyter" + echo '#use "topfind";;' >> ~/.ocamlinit + + - name: Build integration tests + run: opam exec -- dune build test/integration/runtest.exe + - name: An integration test for jupyter-notebook + run: opam exec -- ./_build/default/test/integration/runtest.exe test/integration/suite/jupyter-notebook.ml + - name: An integration test for ppx + run: opam exec -- ./_build/default/test/integration/runtest.exe test/integration/suite/ppx.ml + - name: An integration test for jupyter-archimedes + run: opam exec -- ./_build/default/test/integration/runtest.exe test/integration/suite/jupyter-archimedes.ml diff --git a/git/pre-commit b/git/pre-commit index 09bdbd2d..8ae38080 100755 --- a/git/pre-commit +++ b/git/pre-commit @@ -2,10 +2,6 @@ eval $(opam env) -if ! which ocp-indent 2>&1 >/dev/null; then - opam install -y 'ocp-indent>=1.7.0' -fi - exit_code=0 for fname in $(find jupyter jupyter-archimedes test -name '*.ml' -or -name '*.mli'); do diff --git a/jupyter.opam b/jupyter.opam index 468b0e32..90cf58cb 100644 --- a/jupyter.opam +++ b/jupyter.opam @@ -32,6 +32,8 @@ depends: [ "ppx_deriving_yojson" {>= "3.0"} "cryptokit" {>= "1.12"} "dune" {build & >= "1.0.0"} + "ounit2" {with-test & >= "2.0.0"} + "ocp-indent" {with-test & >= "1.7.0"} ] depopts: [ "merlin" diff --git a/test/completor/dune b/test/completor/dune index 46167610..1c484acb 100644 --- a/test/completor/dune +++ b/test/completor/dune @@ -3,7 +3,7 @@ (preprocess (pps lwt_ppx ppx_deriving.show ppx_deriving_yojson)) (libraries jupyter jupyter_completor - oUnit + ounit2 ppx_deriving.runtime) (flags ((:include %{workspace_root}/config/ocaml_flags.sexp) (:include %{workspace_root}/config/ocaml_test_flags.sexp)))) diff --git a/test/kernel/dune b/test/kernel/dune index 05a76417..3524db12 100644 --- a/test/kernel/dune +++ b/test/kernel/dune @@ -4,7 +4,7 @@ (preprocess (pps lwt_ppx ppx_deriving.show ppx_deriving_yojson)) (libraries jupyter jupyter_kernel - oUnit + ounit2 ppx_deriving.runtime) (flags ((:include %{workspace_root}/config/ocaml_flags.sexp) (:include %{workspace_root}/config/ocaml_test_flags.sexp)))) diff --git a/test/repl/dune b/test/repl/dune index 3ee9fff7..0f529fde 100644 --- a/test/repl/dune +++ b/test/repl/dune @@ -5,7 +5,7 @@ (preprocess (pps lwt_ppx ppx_deriving.show ppx_deriving_yojson)) (libraries jupyter jupyter_repl - oUnit + ounit2 ppx_deriving.runtime) (flags ((:include %{workspace_root}/config/ocaml_flags.sexp) (:include %{workspace_root}/config/ocaml_test_flags.sexp))))