From 8cde3afa17023985a64fbc27ef6db2079e1ffba5 Mon Sep 17 00:00:00 2001 From: Mango The Fourth <40720523+MangoIV@users.noreply.github.com> Date: Tue, 30 Apr 2024 12:49:04 +0200 Subject: [PATCH] Use makefile targets again (#4029) * Revert "[chore] don't use treeefmt for hlint, readd the remove hlint rules (#4028)" This reverts commit aef2f57b2e611a9c192c3418059321c563adf72e. * Revert "[WPB-8712] use treefmt for everything (#4000)" This reverts commit 2d5073eb1ed15567b0abb2e6e6fd6f6e01dde207. --- Makefile | 43 ++++++++++++++++++++----------------------- treefmt.toml | 15 +++++---------- 2 files changed, 25 insertions(+), 33 deletions(-) diff --git a/Makefile b/Makefile index 5791fd46ac6..0ffa86792f2 100644 --- a/Makefile +++ b/Makefile @@ -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 ) @@ -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: @@ -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 @@ -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: diff --git a/treefmt.toml b/treefmt.toml index dce24e184d6..6d5723fc9ef 100644 --- a/treefmt.toml +++ b/treefmt.toml @@ -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]