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

[WPB-8712] use treefmt for everything #4000

Merged
merged 6 commits into from
Apr 22, 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
43 changes: 11 additions & 32 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,8 @@ devtest:
.PHONY: sanitize-pr
sanitize-pr:
./hack/bin/generate-local-nix-packages.sh
make formatf
make hlint-inplace-pr
make hlint-check-pr # sometimes inplace has been observed not to do its job very well.
make format
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
make format
make format
make formatc # (at some point in the past, this has caught ormolu screwing up with inplace)

this might be fixed now with the --check-inplace argument, but can we be certain?

but if you prefer, we can remove this and see if it happens again.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--check-idempotence? i have removed formatc, i think...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i was hoping that ormolu by now is idempotent or at least the idempotency check works reliably 👀

make git-add-cassandra-schema
@git diff-files --quiet -- || ( echo "There are unstaged changes, please take a look, consider committing them, and try again."; exit 1 )
@git diff-index --quiet --cached HEAD -- || ( echo "There are staged changes, please take a look, consider committing them, and try again."; exit 1 )
Expand All @@ -155,28 +154,16 @@ ghcid:

# Used by CI
.PHONY: lint-all
lint-all: formatc hlint-check-all check-local-nix-derivations treefmt-check

.PHONY: hlint-check-all
hlint-check-all:
./tools/hlint.sh -f all -m check
lint-all: treefmt-check check-local-nix-derivations

.PHONY: hlint-inplace-all
hlint-inplace-all:
./tools/hlint.sh -f all -m inplace

.PHONY: hlint-check-pr
hlint-check-pr:
./tools/hlint.sh -f pr -m check

.PHONY: hlint-inplace-pr
hlint-inplace-pr:
./tools/hlint.sh -f pr -m inplace

.PHONY: hlint-check
hlint-check:
./tools/hlint.sh -f changeset -m check

.PHONY: hlint-inplace
hlint-inplace:
./tools/hlint.sh -f changeset -m inplace
Expand All @@ -192,35 +179,27 @@ check-local-nix-derivations: regen-local-nix-derivations
services: init install
$(MAKE) -C services/nginz

# formats all Haskell files (which don't contain CPP)
# formats everything according to treefmt rules
# this may take a while (5 minutes) on first run but should be instant on
# any subsequent run except after you have changed files.
.PHONY: format
format:
./tools/ormolu.sh

# formats all Haskell files changed in this PR, even if local changes are not committed to git
.PHONY: formatf
formatf:
./tools/ormolu.sh -f pr

# formats all Haskell files even if local changes are not committed to git
.PHONY: formatf-all
formatf-all:
./tools/ormolu.sh -f all
treefmt

# checks that all Haskell files are formatted; fail if a `make format` run is needed.
# checks the format
.PHONY: formatc
formatc:
./tools/ormolu.sh -c
formatc:
treefmt-check

# For any Haskell or Rust file, update or add a license header if necessary.
# Headers should be added according to Ormolu's formatting rules, but please check just in case.
.PHONY: add-license
add-license:
# Check headroom is installed. If not, please run 'stack install headroom'
# Check headroom is installed.
command -v headroom
headroom run
@echo ""
@echo "you might want to run 'make formatf' now to make sure ormolu is happy"
@echo "you might want to run 'make format' now to make sure ormolu is happy"

.PHONY: treefmt
treefmt:
Expand Down
1 change: 1 addition & 0 deletions changelog.d/5-internal/WPB-8712
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
move formatting and linting of haskell files to treefmt, remove some of the now unneeded rules
20 changes: 15 additions & 5 deletions treefmt.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
[formatter.nix]
command = "nixpkgs-fmt"
includes = ["*.nix"]
excludes = [
"nix/sources.nix" # managed by niv.
]
excludes = [ "nix/sources.nix"] # managed by niv.

[formatter.cabal-fmt]
command = "cabal-fmt"
options = [ "--inplace" ]
includes = [ "*.cabal" ]
excludes = [
"dist-newstyle/"
excludes = [ "dist-newstyle/" ]

[formatter.ormolu]
command = "ormolu"
includes = ["*.hs"]
excludes = [ "dist*" ]
options = [
"--mode", "inplace",
"--check-idempotence",
]

[formatter.hlint]
command = "hlint"
includes = ["*.hs"]
excludes = [ "dist*" ]

[formatter.shellcheck]
command = "shellcheck"
includes = ["*.sh"]
Expand Down
Loading