Code Monkey home page Code Monkey logo

fromager's Introduction

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 with version=0.18.0 as content
  • create 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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.