diff --git a/.drom b/.drom index 84398f89..9b7a01d7 100644 --- a/.drom +++ b/.drom @@ -5,7 +5,7 @@ version:0.9.0 # hash of toml configuration files # used for generation of all files -cfd502831bbf686b41df41219629c1c4:. +812a88073a143fbfd65d11dd1ac586fd:. # end context for . # begin context for .github/workflows/workflow.yml @@ -15,7 +15,7 @@ eee26f5d13b222b48706c4fcbd98a19a:.github/workflows/workflow.yml # begin context for .gitignore # file .gitignore -f7a24abcad0ba9301c03bb64464b1718:.gitignore +33c88a25e8b40f3683f6c03ec26be5db:.gitignore # end context for .gitignore # begin context for .ocamlformat @@ -55,7 +55,7 @@ f7a24abcad0ba9301c03bb64464b1718:.gitignore # begin context for README.md # file README.md -616ddd2660258447be65bdb664b9241d:README.md +5d523350230459e853bc57803b729e29:README.md # end context for README.md # begin context for docs/README.txt @@ -88,11 +88,31 @@ e739f3026aa997af4026bc428f4c9ef6:docs/favicon.png c8281f46ba9a11d0b61bc8ef67eaa357:docs/style.css # end context for docs/style.css +# begin context for docs\README.txt +# file docs\README.txt +bfbacf00053bb9ab2a6e2ce94ed4a642:docs\README.txt +# end context for docs\README.txt + +# begin context for docs\favicon.png +# file docs\favicon.png +e739f3026aa997af4026bc428f4c9ef6:docs\favicon.png +# end context for docs\favicon.png + +# begin context for docs\style.css +# file docs\style.css +c8281f46ba9a11d0b61bc8ef67eaa357:docs\style.css +# end context for docs\style.css + # begin context for dot_gitattributes # file dot_gitattributes 20bbe7a5dbb3c3278a1511d960616fe5:dot_gitattributes # end context for dot_gitattributes +# begin context for dot_github\workflows\workflow.yml +# file dot_github\workflows\workflow.yml +004b92dd628d26b4f8a5a5139bf4aa79:dot_github\workflows\workflow.yml +# end context for dot_github\workflows\workflow.yml + # begin context for drom.toml # file drom.toml 9949d65b87e55480a30122e9e77ae7d3:drom.toml @@ -105,7 +125,7 @@ e850a13c004f963e9f5a568eac93c217:dune # begin context for dune-project # file dune-project -c063288437da29a5a21e8c76c1906adc:dune-project +7f0439af8599faf105447755ebd72e7e:dune-project # end context for dune-project # begin context for opam/drom.opam @@ -143,6 +163,16 @@ e55d659410b556d7bc60183d8ff1f788:opam/drom_toml.opam cda3f8bad69d9c6e8cbeab1c720d739a:scripts/static-build.sh # end context for scripts/static-build.sh +# begin context for scripts\after.sh +# file scripts\after.sh +cb2282903fb6ae1ac71fb2fbbcccffbd:scripts\after.sh +# end context for scripts\after.sh + +# begin context for scripts\before.sh +# file scripts\before.sh +97c9b1f22a04f7c0b42477aee6f4393e:scripts\before.sh +# end context for scripts\before.sh + # begin context for sphinx/_static/css/fixes.css # file sphinx/_static/css/fixes.css 68b329da9893e34099c7d8ad5cb9c940:sphinx/_static/css/fixes.css @@ -173,6 +203,21 @@ a44c87f3a364dd95f55427fe40b2c5d1:sphinx/about.rst 8f504f01aea592543c0a662b81169d91:sphinx/license.rst # end context for sphinx/license.rst +# begin context for sphinx\conf.py +# file sphinx\conf.py +67496ee935ab27fdabb4544f4f81eeb6:sphinx\conf.py +# end context for sphinx\conf.py + +# begin context for sphinx\license.rst +# file sphinx\license.rst +8f504f01aea592543c0a662b81169d91:sphinx\license.rst +# end context for sphinx\license.rst + +# begin context for sphinx\under_static\css\fixes.css +# file sphinx\under_static\css\fixes.css +20bbe7a5dbb3c3278a1511d960616fe5:sphinx\under_static\css\fixes.css +# end context for sphinx\under_static\css\fixes.css + # begin context for src/drom/dune # file src/drom/dune 68aec4169671c0163b98bb38205d2e4d:src/drom/dune @@ -198,6 +243,11 @@ a44c87f3a364dd95f55427fe40b2c5d1:sphinx/about.rst bb6803d414fd5a5479ed6381914604de:src/drom/package.toml # end context for src/drom/package.toml +# begin context for src/drom\index.mld +# file src/drom\index.mld +2818d15f527a37c2cfafe85ef89f675b:src/drom\index.mld +# end context for src/drom\index.mld + # begin context for src/drom_lib/dune # file src/drom_lib/dune 103b365e9f24dbbae02b6be22b3efd0a:src/drom_lib/dune @@ -218,6 +268,21 @@ c4d6597dc5b0966758c213bfffb9d594:src/drom_lib/package.toml a3e5d8a00664ceaa6addf376bedf6de1:src/drom_lib/version.mlt # end context for src/drom_lib/version.mlt +# begin context for src/drom_lib\dune +# file src/drom_lib\dune +8c189e7a8bac651b008889b1dd38a8fe:src/drom_lib\dune +# end context for src/drom_lib\dune + +# begin context for src/drom_lib\index.mld +# file src/drom_lib\index.mld +3e03ec5e98f99c1d5b09dd366177ad13:src/drom_lib\index.mld +# end context for src/drom_lib\index.mld + +# begin context for src/drom_lib\version.mlt +# file src/drom_lib\version.mlt +a3e5d8a00664ceaa6addf376bedf6de1:src/drom_lib\version.mlt +# end context for src/drom_lib\version.mlt + # begin context for src/toml.7.1.0/dune # file src/toml.7.1.0/dune 0841a2e47118b9fcd9b900f84ff66c34:src/toml.7.1.0/dune @@ -243,6 +308,16 @@ d1b05207fce876a1b44a8b268bcaf226:src/toml.7.1.0/index.mld a3e5d8a00664ceaa6addf376bedf6de1:src/toml.7.1.0/version.mlt # end context for src/toml.7.1.0/version.mlt +# begin context for src/toml.7.1.0\index.mld +# file src/toml.7.1.0\index.mld +d1b05207fce876a1b44a8b268bcaf226:src/toml.7.1.0\index.mld +# end context for src/toml.7.1.0\index.mld + +# begin context for src/toml.7.1.0\version.mlt +# file src/toml.7.1.0\version.mlt +a3e5d8a00664ceaa6addf376bedf6de1:src/toml.7.1.0\version.mlt +# end context for src/toml.7.1.0\version.mlt + # begin context for test/expect-tests/dune # file test/expect-tests/dune d7e2675a767e30edf28d061c94f0ec62:test/expect-tests/dune @@ -312,3 +387,13 @@ ee63957b3b77455a12e6c269a5032c3f:test/output-tests/test2.expected # file test/output-tests/test2.ml e8eaab7626ef0aace5e570fffe81f869:test/output-tests/test2.ml # end context for test/output-tests/test2.ml + +# begin context for test\inline-tests\test.ml +# file test\inline-tests\test.ml +37b8bc6035cda6302a80178c61f9626e:test\inline-tests\test.ml +# end context for test\inline-tests\test.ml + +# begin context for test\output-tests\test1.expected +# file test\output-tests\test1.expected +dc8d6157230e9ef8e965865f990fbc49:test\output-tests\test1.expected +# end context for test\output-tests\test1.expected diff --git a/.gitignore b/.gitignore index 4469f6e8..183b145f 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ *~ _build .merlin +.vscode /_drom /_opam /_build diff --git a/README.md b/README.md index 5cd68cea..e8503f94 100644 --- a/README.md +++ b/README.md @@ -14,48 +14,3 @@ will generate files for Github Actions CI and Github pages. * General Documentation: https://ocamlpro.github.io/drom/sphinx * API Documentation: https://ocamlpro.github.io/drom/doc * Sources: https://github.com/ocamlpro/drom - - -## Simple Example - -You can create a new OCaml project with: - -``` -$ drom new my-client --skeleton mini_prg -Creating project "my-client" with skeleton "mini_prg", license "LGPL2" - and sources in src/my-client: -Creating directory my-client -Using skeleton "program" for package "my-client" -[master (root-commit) 8d83262] Initial commit - -└── my-client/ - ├── .drom (drom state, do not edit) - ├── .github/ - │ └── workflows/ - │ └── workflow.yml - ├── .gitignore - ├── CHANGES.md - ├── LICENSE.md - ├── Makefile - ├── README.md - ├── drom.toml <────────── project config EDIT ! - ├── dune - ├── dune-project - ├── opam/ - │ └── my-client.opam - ├── scripts/ - │ ├── after.sh - │ ├── before.sh - │ └── copy-bin.sh - └── src/ - └── my-client/ - ├── dune - ├── main.ml - ├── package.toml <────────── package config EDIT ! - └── version.mlt -``` - -This project uses the minimalist `mini_prg` skeleton, but other skeletons -like `program` or `library` have more files. - - diff --git a/dot_github/workflows/workflow.yml b/dot_github/workflows/workflow.yml new file mode 100644 index 00000000..5c7c8f41 --- /dev/null +++ b/dot_github/workflows/workflow.yml @@ -0,0 +1,105 @@ +name: Main Workflow + +on: + pull_request: + branches: + - master + push: + branches: + - master + +jobs: + build: + strategy: + fail-fast: false + matrix: + os: + - ubuntu-latest + - macos-latest + - windows-latest + ocaml-compiler: + - 4.14.1 + skip_test: + - false + + include: + - os: ubuntu-latest + ocaml-compiler: 4.08.0 + skip_test: true + + + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Retrieve opam cache + uses: actions/cache@v2 + id: cache-opam + with: + path: ~/.opam + key: v2-${{ runner.os }}-drom-${{ matrix.ocaml-compiler }}-${{ hashFiles('opam/*.opam') }} +# restore-keys: | +# v2-${{ runner.os }}-opam-${{ matrix.ocaml-compiler }}- + + - name: Use OCaml ${{ matrix.ocaml-compiler }} + uses: avsm/setup-ocaml@v2 + with: + ocaml-compiler: ${{ matrix.ocaml-compiler }} + opam-pin: false + opam-depext: false + + - name: Set git user + run: | + git config --global user.name github-actions + git config --global user.email github-actions-bot@users.noreply.github.com + + # define opam-repo = "git+https://" to add an extra opam repo + + - run: opam pin add . -y --no-action + + - run: opam depext -y drom drom_lib drom_toml +# if: steps.cache-opam.outputs.cache-hit != 'true' + + - run: opam install -y opam/*.opam --deps-only --with-test +# if: steps.cache-opam.outputs.cache-hit != 'true' + +# - run: opam upgrade --fixup +# if: steps.cache-opam.outputs.cache-hit == 'true' + + - run: dos2unix scripts/*.sh + if: matrix.os == 'windows-latest' + + - run: make build + + - name: run test suite + run: | + ./scripts/before.sh test + opam exec -- dune build @runtest + ./scripts/after.sh test + if: matrix.skip_test != 'true' + + - name: test source is well formatted + run: make fmt + continue-on-error: true + if: matrix.ocaml-compiler == '4.14.1' && matrix.os == 'ubuntu-latest' + + - name: build-doc + if: github.ref == 'refs/heads/master' && matrix.ocaml-compiler == '4.14.1' && matrix.os == 'ubuntu-latest' + run: | + sudo apt install -yqq python3-sphinx python3-sphinx-rtd-theme + opam install -y dune odoc + make doc + touch _drom/docs/.nojekyll + touch _drom/docs/sphinx/.nojekyll + touch _drom/docs/doc/.nojekyll + + - name: deploy-doc + uses: JamesIves/github-pages-deploy-action@3.6.2 + if: github.ref == 'refs/heads/master' && matrix.ocaml-compiler == '4.14.1' && matrix.os == 'ubuntu-latest' + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BRANCH: gh-pages + FOLDER: _drom/docs/ + CLEAN: true diff --git a/dune-project b/dune-project index e4232f49..8afe42f5 100644 --- a/dune-project +++ b/dune-project @@ -1,5 +1,4 @@ (lang dune 2.8) -(using dune_site 0.1) ; This file was generated by drom, using drom.toml (cram enable) @@ -52,6 +51,7 @@ (ez_cmdliner (and (>= 0.2.0) (< 1.0.0))) (drom_toml (= version)) (directories ( >= 0.2 )) + bos ppx_inline_test ppx_expect odoc diff --git a/sphinx/under_static/css/fixes.css b/sphinx/under_static/css/fixes.css new file mode 100644 index 00000000..e69de29b diff --git a/src/drom_lib/dune b/src/drom_lib/dune index bc43c911..a8a3cc4f 100644 --- a/src/drom_lib/dune +++ b/src/drom_lib/dune @@ -4,11 +4,7 @@ (name drom_lib) (public_name drom_lib) (wrapped true) - ; use field 'dune-libraries' to add libraries without opam deps - (libraries ppx_protocol_conv otoml omd jingoo fmt ez_subst ez_opam_file ez_file ez_cmdliner drom_toml directories bigarray ppx_protocol_conv.runtime ppx_protocol_conv.driver) - ; use field 'dune-flags' to set this value - (flags (:standard)) - ; use field 'dune-stanzas' to add more stanzas here + (libraries ppx_protocol_conv otoml omd jingoo fmt ez_subst ez_opam_file ez_file ez_cmdliner drom_toml directories bos bigarray ppx_protocol_conv.runtime ppx_protocol_conv.driver) (preprocess (pps ppx_deriving.show ppx_protocol_conv)) ) @@ -22,5 +18,4 @@ (documentation (package drom_lib)) -; use field 'dune-trailer' to add more stuff here diff --git a/src/drom_lib/globals.ml b/src/drom_lib/globals.ml index 4822cbff..92f2f77f 100644 --- a/src/drom_lib/globals.ml +++ b/src/drom_lib/globals.ml @@ -87,12 +87,20 @@ let find_ancestor_file file f = in iter dir "" -let opam_root = - lazy - ( try Sys.getenv "OPAMROOT" with - | Not_found -> home_dir // ".opam" ) +(** [opam_root ()] returns the opam root directory. + + @raise Error.Error if any error happens. *) +let opam_root : unit -> string = + let compute = lazy begin + (* Don't use OPAMROOT or hardcoded directories. `opam` gives its own + way to give it. *) + let cmd = Bos.Cmd.(v "opam" % "var" % "root") in + match Bos.OS.Cmd.(run_out cmd |> to_string) with + | Ok dir -> dir + | Error _ -> Error.raise "%s: unknown error" __FUNCTION__ + end in + fun () -> Lazy.force compute -let opam_root () = Lazy.force opam_root let verbose_subst = try diff --git a/src/drom_lib/package.toml b/src/drom_lib/package.toml index 6fa769b6..b2d33cae 100644 --- a/src/drom_lib/package.toml +++ b/src/drom_lib/package.toml @@ -64,6 +64,7 @@ jingoo = ">=1.5.0" omd = ">=2.0" otoml = ">=1.0.4" ppx_protocol_conv = ">=5.2.1" +bos = ">=0.2.1" # package tools dependencies [tools]