Skip to content

Commit

Permalink
Use makefile targets again (#4029)
Browse files Browse the repository at this point in the history
* Revert "[chore] don't use treeefmt for hlint, readd the remove hlint rules (#4028)"

This reverts commit aef2f57.

* Revert "[WPB-8712] use treefmt for everything (#4000)"

This reverts commit 2d5073e.
  • Loading branch information
MangoIV authored Apr 30, 2024
1 parent 4c82fd6 commit 8cde3af
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 33 deletions.
43 changes: 20 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,9 @@ devtest:
.PHONY: sanitize-pr
sanitize-pr:
./hack/bin/generate-local-nix-packages.sh
make formatf
make hlint-inplace-pr
make format
make hlint-check-pr # sometimes inplace has been observed not to do its job very well.
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 @@ -154,7 +155,7 @@ ghcid:

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

.PHONY: hlint-check-all
hlint-check-all:
Expand All @@ -180,18 +181,6 @@ hlint-check:
hlint-inplace:
./tools/hlint.sh -f changeset -m inplace

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

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

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

regen-local-nix-derivations:
./hack/bin/generate-local-nix-packages.sh

Expand All @@ -203,27 +192,35 @@ check-local-nix-derivations: regen-local-nix-derivations
services: init install
$(MAKE) -C services/nginz

# 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.
# formats all Haskell files (which don't contain CPP)
.PHONY: format
format:
treefmt
./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

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

# 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.
# Check headroom is installed. If not, please run 'stack install headroom'
command -v headroom
headroom run
@echo ""
@echo "you might want to run 'make format' now to make sure ormolu is happy"
@echo "you might want to run 'make formatf' now to make sure ormolu is happy"

.PHONY: treefmt
treefmt:
Expand Down
15 changes: 5 additions & 10 deletions treefmt.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
[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/" ]

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

[formatter.shellcheck]
Expand Down

0 comments on commit 8cde3af

Please sign in to comment.