From 32a903bf5efee8b07837d8cd556d2c47acf48130 Mon Sep 17 00:00:00 2001 From: Anton Kesy Date: Mon, 4 Mar 2024 12:36:37 +0100 Subject: [PATCH] add ormolu formatter --- .pre-commit-config.yaml | 16 ++++++++++++++++ Dockerfile | 10 +++++++++- Setup.hs | 1 + src/Lib.hs | 5 +++-- 4 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..41f107a --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,16 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v2.3.0 + hooks: + - id: check-yaml + - id: end-of-file-fixer + - id: trailing-whitespace + - repo: local + hooks: + - id: ormolu-formatter + name: ormolu-formatter + entry: bash -c "stack install ormolu && ormolu --mode inplace $(find . -name '*.hs')" + language: system + types: [haskell] + pass_filenames: false + always_run: true diff --git a/Dockerfile b/Dockerfile index 06f30f8..99cb5b3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,9 +10,17 @@ RUN curl -sSL https://get.haskellstack.org/ | sh ENV PATH="/root/.local/bin:${PATH}" RUN stack --resolver ghc-9.6.4 setup +RUN stack install omolu + WORKDIR /peter-lang COPY . /peter-lang -RUN stack build +# cancel the build if there are formatting errors +RUN ormolu --mode check $(find . -name '*.hs') +# build project +RUN stack build RUN stack test +# pre-commit +RUN git init . && pre-commit install-hooks +RUN pre-commit run --all-files diff --git a/Setup.hs b/Setup.hs index 9a994af..e8ef27d 100644 --- a/Setup.hs +++ b/Setup.hs @@ -1,2 +1,3 @@ import Distribution.Simple + main = defaultMain diff --git a/src/Lib.hs b/src/Lib.hs index d36ff27..3424510 100644 --- a/src/Lib.hs +++ b/src/Lib.hs @@ -1,6 +1,7 @@ module Lib - ( someFunc - ) where + ( someFunc, + ) +where someFunc :: IO () someFunc = putStrLn "someFunc"