package fromager
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=95a6fd40d040b6de00079f1f0f2080ef919e95f6008e63c1df2b3dcc65ded654
sha512=4f14ad769cec82c99bf724cdd8a0021c858df20c30b3303ca78b510f1620cf63313971f80a788fe445da0f65b5f61b2f113286ba8b0750f165108556caaae780
Description
Published: 07 Dec 2021
README
Fromager
Fromager helps you format your codebase by enforcing a common configuration (ocamlformat version, files and directories to ignore).
Note that fromager actually doesn't add much besides perhaps a better error message or a nicer configuration format (toml) than ocamlformat. For this reason, I give indications on how to do the same things with .ocamlformat
in this README.
Installation & Usage
If you have Opam, the package manager of OCaml, simply do:
$ opam install fromager
$ fromager
It's that simple! You don't even need an .ocamlformat
file.
Configuring Fromager
By default, fromager ignores any directory starting with an underscore (e.g. _opam
) or with a dot (e.g. .git
).
You can optionally create a fromage.toml
file at the root of your project:
[config]
ocamlformat_version = "0.18.0"
ignored_files = []
ignored_dirs = [ "./some", "./ignored/directories" ]
By design, you can't tweak ocamlformat as it is discouraged.
To do this with ocamlformat directly:
create an
.ocamlformat
file withversion=0.18.0
as contentcreate an
.ocamlformat-ignore
file with files or folders you want to ignore
Enforce formatting in CI by adding a Fromager Github action
name: Run Fromager
on:
[pull_request]
jobs:
run_fromager:
strategy:
fail-fast: false
matrix:
os:
- macos-latest
- ubuntu-latest
ocaml-version:
- 4.07.1
runs-on: ${{ matrix.os }}
steps:
- name: Get code
uses: actions/checkout@v2
- name: Use OCaml ${{ matrix.ocaml-version }}
uses: avsm/setup-ocaml@v1
with:
ocaml-version: ${{ matrix.ocaml-version }}
- name: Build
run: |
eval $(opam env)
opam pin add . -y
- name: Format
run: |
eval $(opam env)
opam install fromager
fromager
git diff --exit-code
to do this with ocamlformat, replace the format step with:
-name: Format
run: |
eval $(opam env)
opam install ocamlformat
dune build @fmt
dune promote
git diff --exit-code
Dependencies (5)
- ocamlformat
-
core
>= "v0.12.4" & < "v0.15"
-
otoml
>= "0.9.3"
-
dune
>= "2.8"
-
ocaml
>= "4.08"
Dev Dependencies
None
Used by
None
Conflicts
None