Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable ocaml code formatting with dune fmt #207

Merged
merged 7 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# dune fmt ocaml code
d67590d2cd504ed931e225834746f9e13b3a27fa
12 changes: 12 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,15 @@ jobs:
system-features = nixos-test benchmark big-parallel kvm
- uses: DeterminateSystems/magic-nix-cache-action@v8
- run: cd controller && nix-shell --run 'bin/test --force --no-buffer'

ocaml-formatting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v18
with:
nix_path: nixpkgs=channel:nixos-unstable
extra_nix_config: |
system-features = nixos-test benchmark big-parallel kvm
- uses: DeterminateSystems/magic-nix-cache-action@v8
- run: cd controller && nix-shell --run 'dune build @fmt'
13 changes: 13 additions & 0 deletions controller/.ocamlformat
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version = 0.26.1

profile = ocamlformat

break-infix = wrap-or-vertical
doc-comments = before
field-space = loose
indicate-multiline-delimiters = closing-on-separate-line
space-around-arrays = true
space-around-lists = true
space-around-records = true
space-around-variants = true
type-decl = sparse
7 changes: 7 additions & 0 deletions controller/bin/watch-command
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
#!/usr/bin/env bash
set -euo pipefail

AUTO_FORMAT=${AUTO_FORMAT:-}

cd $(dirname "$0")/..

clear

if [ ! -z "$AUTO_FORMAT" ]; then
dune fmt || true
fi

if bin/build; then

bin/stop-server || true
Expand Down
Loading
Loading