diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 788803c5..fc1975a5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,23 +13,23 @@ on: jobs: build: runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + ocaml-compiler: ["4.14.x", "5.3.x"] steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up OCaml - uses: avsm/setup-ocaml@v1 + uses: ocaml/setup-ocaml@v3 with: - # Version of the OCaml compiler to initialise - ocaml-version: 4.11.1 + ocaml-compiler: ${{ matrix.ocaml-compiler }} - - name: install dependencies + - name: Install dependencies run: opam install . --deps-only --with-doc --with-test - - name: build - run: | - opam exec -- dune build @install @JS @main + - name: Build + run: opam exec -- dune build @install @JS @main - - name: runtest + - name: Test run: opam exec -- dune runtest - diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index b52b315b..54d805f1 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -5,29 +5,32 @@ on: branches: [ master ] jobs: - build: + format: runs-on: ubuntu-latest steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: - ref: ${{ github.head_ref }} + fetch-depth: 0 - name: Set up OCaml - uses: avsm/setup-ocaml@v1 + uses: ocaml/setup-ocaml@v3 with: - # Version of the OCaml compiler to initialise - ocaml-version: 4.11.1 - - - name: install dependencies - run: opam install ocamlformat.0.16.0 dune + ocaml-compiler: 4.14.x + + - name: Install formatter + run: opam install ocamlformat.0.26.2 dune - - name: format + - name: Check formatting run: | - opam exec -- dune build @fmt --auto-promote || true - - - name: commit - uses: stefanzweifel/git-auto-commit-action@v4.11.0 - with: - commit_message: Apply formatting changes - branch: ${{ github.head_ref }} + mapfile -t files < <(git diff --name-only --diff-filter=ACMRT \ + "origin/${{ github.base_ref }}...HEAD" -- '*.ml' '*.mli') + status=0 + for file in "${files[@]}"; do + formatted="$(mktemp)" + opam exec -- ocamlformat "$file" > "$formatted" + if ! diff --unified "$file" "$formatted"; then + status=1 + fi + rm "$formatted" + done + exit "$status" diff --git a/js/dune b/js/dune index d07a0745..2b634e8c 100644 --- a/js/dune +++ b/js/dune @@ -3,6 +3,7 @@ (modes js) (preprocess (pps js_of_ocaml-ppx)) + (flags :standard -open Mldoc__) (js_of_ocaml (flags --target-env browser)) (libraries angstrom js_of_ocaml mldoc)) diff --git a/lib/dune b/lib/dune index 59ae5319..e1b962fb 100644 --- a/lib/dune +++ b/lib/dune @@ -18,4 +18,4 @@ uri str xmlm) - (wrapped false)) + (wrapped true)) diff --git a/lib/mldoc.ml b/lib/mldoc.ml index 3133935f..51ebfb6f 100644 --- a/lib/mldoc.ml +++ b/lib/mldoc.ml @@ -3,6 +3,8 @@ module Document = Document module Block = Type_parser.Block module Inline = Inline +module Nested_link = Nested_link +module Pos = Pos module Exporters = Exporter.Exporters module Conf = Conf module Exporter = Exporter diff --git a/mldoc.opam b/mldoc.opam index d1432635..52a83342 100644 --- a/mldoc.opam +++ b/mldoc.opam @@ -43,5 +43,5 @@ build: [ ] pin-depends: [ [ "angstrom.dev" "git+https://github.com/logseq/angstrom#fork" ] - [ "xmlm.dev" "git+https://github.com/logseq/xmlm#fork" ] + [ "xmlm.dev" "git+https://github.com/logseq/xmlm#eb469d536e98c98f2754c0ff8813c92b3a17fe9f" ] ] diff --git a/test/dune b/test/dune index 7071d5f0..8397ba8a 100644 --- a/test/dune +++ b/test/dune @@ -50,3 +50,7 @@ (run %{zip}) (run %{export-md}) (run %{export-opml})))) +(env + (_ + (flags + (:standard -open Mldoc__)))) diff --git a/test/gen_md_files.ml b/test/gen_md_files.ml index c3a485cf..9c5fdf8d 100644 --- a/test/gen_md_files.ml +++ b/test/gen_md_files.ml @@ -29,7 +29,7 @@ let page_names n = let pagename i = let+ pagename_l = list_size (1 -- 10) - @@ frequency + @@ oneof_weighted [ (1, string_size ~gen:(oneofl char_table) (0 -- 5)) ; (1, oneofl unicode_table) ] @@ -44,7 +44,7 @@ let plain_inline_g = string_size ~gen:(char_range 'A' 'Z') (1 -- 100) >|= fun s -> Inline.Plain s let inline_g pagenames = - frequency [ (10, plain_inline_g); (1, page_ref_g pagenames) ] + oneof_weighted [ (10, plain_inline_g); (1, page_ref_g pagenames) ] let inlines_g pagenames = list_size (1 -- 10) (inline_g pagenames) @@ -54,15 +54,19 @@ let level_candidates max = let heading ?(init = false) pagenames state = let marker_g = - frequencyl - [ (1, Some "TODO"); (1, Some "DOING"); (1, Some "DONE"); (7, None) ] + oneof_weighted + [ (1, return (Some "TODO")) + ; (1, return (Some "DOING")) + ; (1, return (Some "DONE")) + ; (7, return None) + ] in let level_g = oneofl (if init then - [ 1 ] - else - level_candidates (state.last_level + 4)) + [ 1 ] + else + level_candidates (state.last_level + 4)) in inlines_g pagenames >>= fun inlines -> marker_g >>= fun marker -> @@ -90,7 +94,7 @@ let blocks_g pagenames : Type.blocks t = let* init_heading = heading ~init:true pagenames state in let init_heading_with_pos = (init_heading, dummy_pos) in let block_with_pos_g = - frequency [ (3, paragragh pagenames); (1, heading pagenames state) ] + oneof_weighted [ (3, paragragh pagenames); (1, heading pagenames state) ] >|= fun b -> (b, dummy_pos) in let* blocks' = list_size (10 -- 500) block_with_pos_g in diff --git a/test/test_zip.ml b/test/test_zip.ml index d12d3167..80f1c2a0 100644 --- a/test/test_zip.ml +++ b/test/test_zip.ml @@ -9,7 +9,7 @@ let g = match n with | 0 -> map leaf nat | n -> - frequency + oneof_weighted [ ( 5 , branch <$> ( 0 -- (n / 2) >>= fun n' ->