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

Fix #8316: run fix-whitespace --check as CI workflow #8320

Merged
merged 3 commits into from
Jul 28, 2022
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
47 changes: 47 additions & 0 deletions .github/workflows/whitespace.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Whitespace

on:
push:
branches:
- master
pull_request:
release:
types:
- created
jobs:
check:
runs-on: ubuntu-latest

env:
fix-whitespace-ver: '0.0.8'

steps:
- uses: actions/checkout@v3
name: Checkout sources

- name: Create directory for binary
run: |
mkdir -p $HOME/.local/bin

- uses: actions/cache@v3
name: Cache the binary
id: cache
with:
path: "~/.local/bin"
key: fix-whitespace-${{ env.fix-whitespace-ver }}

- uses: haskell/actions/setup@v1
if: ${{ !steps.cache.outputs.cache-hit }}
with:
ghc-version: '9.2'
cabal-version: latest

- name: Install fix-whitespace
if: ${{ !steps.cache.outputs.cache-hit }}
run: |
cabal install --ignore-project --install-method=copy --installdir=$HOME/.local/bin fix-whitespace-${{ env.fix-whitespace-ver }}
strip $HOME/.local/bin/fix-whitespace

- name: Check the whitespace issue
run: |
$HOME/.local/bin/fix-whitespace --check
44 changes: 22 additions & 22 deletions .gitlab/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ export GHCUP_INSTALL_BASE_PREFIX="$CI_PROJECT_DIR/toolchain"
export CABAL_DIR="$CI_PROJECT_DIR/cabal"

case "$(uname)" in
MSYS_*|MINGW*)
export CABAL_DIR="$(cygpath -w "$CABAL_DIR")"
GHCUP_BINDIR="${GHCUP_INSTALL_BASE_PREFIX}/ghcup/bin"
EXE_EXT=".exe"
;;
*)
GHCUP_BINDIR="${GHCUP_INSTALL_BASE_PREFIX}/.ghcup/bin"
EXE_EXT=""
;;
MSYS_*|MINGW*)
export CABAL_DIR="$(cygpath -w "$CABAL_DIR")"
GHCUP_BINDIR="${GHCUP_INSTALL_BASE_PREFIX}/ghcup/bin"
EXE_EXT=".exe"
;;
*)
GHCUP_BINDIR="${GHCUP_INSTALL_BASE_PREFIX}/.ghcup/bin"
EXE_EXT=""
;;
esac

mkdir -p "$CABAL_DIR"
Expand All @@ -32,19 +32,19 @@ export BOOTSTRAP_HASKELL_ADJUST_CABAL_CONFIG=yes
# for some reason the subshell doesn't pick up the arm64 environment on darwin
# and starts installing x86_64 GHC
case "$(uname -s)" in
"Darwin"|"darwin")
case "$(/usr/bin/arch)" in
aarch64|arm64|armv8l)
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | arch -arm64 /bin/bash
;;
*)
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh
;;
esac
;;
*)
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh
;;
"Darwin"|"darwin")
case "$(/usr/bin/arch)" in
aarch64|arm64|armv8l)
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | arch -arm64 /bin/bash
;;
*)
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh
;;
esac
;;
*)
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh
;;
esac

# https://github.com/haskell/cabal/issues/7313#issuecomment-811851884
Expand Down
30 changes: 27 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,34 @@ names. When running `cabal-install` test suites, one need only use `cabal test`
`cabal run <test-target>` in order to test locally.


Conventions
-----------
Whitespace Conventions
----------------------

* Spaces, not tabs.
* No tab characters allowed.
* No trailing whitespace allowed.
* File needs to be terminated by a newline character.

These conventions are enforced by the
[fix-whitespace](https://hackage.haskell.org/package/fix-whitespace)
tool. Install it from hackage as usual (`cabal install fix-whitespace`)
and run it in the project root to fix whitespace violations.

The files included in the automatic whitespace check are specified in
`fix-whitespace.yaml`. Please add to this file if you add textfiles
to this repository that are not included by the rules given there.
Note that files that make essential use of tab characters (like `Makefile`)
should _not_ be included in the automatic check.

Whitespace conventions are enforced by
[CI](https://github.com/haskell/cabal/actions/workflows/whitespace.yml).
If you push a fix of a whitespace violation, please do so in a
_separate commit_.




Other Conventions
-----------------

* Try to follow style conventions of a file you are modifying, and
avoid gratuitous reformatting (it makes merges harder!)
Expand Down
2 changes: 1 addition & 1 deletion Cabal-syntax/src/Distribution/Backpack.hs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ data OpenUnitId
-- TODO: cache holes?

instance Binary OpenUnitId
instance Structured OpenUnitId
instance Structured OpenUnitId
instance NFData OpenUnitId where
rnf (IndefFullUnitId cid subst) = rnf cid `seq` rnf subst
rnf (DefiniteUnitId uid) = rnf uid
Expand Down
4 changes: 2 additions & 2 deletions Cabal-syntax/src/Distribution/Fields/Pretty.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import qualified Distribution.Fields.Parser as P
import qualified Data.ByteString as BS
import qualified Text.PrettyPrint as PP

-- | This type is used to discern when a comment block should go
-- | This type is used to discern when a comment block should go
-- before or after a cabal-like file field, otherwise it would
-- be hardcoded to a single position. It is often used in
-- conjunction with @PrettyField@.
Expand Down Expand Up @@ -153,7 +153,7 @@ renderField (Opts rann indent post) fw (PrettyField ann name doc) =
narrowStyle = PP.style { PP.lineLength = PP.lineLength PP.style - fw }

renderField opts@(Opts rann indent post) _ (PrettySection ann name args fields) = Block Margin Margin $

attachComments
(post ann [ PP.render $ PP.hsep $ PP.text (fromUTF8BS name) : args ])
++
Expand Down
2 changes: 1 addition & 1 deletion Cabal-syntax/src/Distribution/SPDX/LicenseExceptionId.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import qualified Text.PrettyPrint as Disp
-- LicenseExceptionId
-------------------------------------------------------------------------------

-- | SPDX License Exceptions identifiers list v3.16
-- | SPDX License Exceptions identifiers list v3.16
data LicenseExceptionId
= DS389_exception -- ^ @389-exception@, 389 Directory Server Exception
| Autoconf_exception_2_0 -- ^ @Autoconf-exception-2.0@, Autoconf exception 2.0
Expand Down
2 changes: 1 addition & 1 deletion Cabal-syntax/src/Distribution/SPDX/LicenseId.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import qualified Text.PrettyPrint as Disp
-- LicenseId
-------------------------------------------------------------------------------

-- | SPDX License identifiers list v3.16
-- | SPDX License identifiers list v3.16
data LicenseId
= NullBSD -- ^ @0BSD@, BSD Zero Clause License
| AAL -- ^ @AAL@, Attribution Assurance License
Expand Down
2 changes: 1 addition & 1 deletion Cabal-syntax/src/Distribution/Types/CondTree.hs
Original file line number Diff line number Diff line change
Expand Up @@ -198,4 +198,4 @@ foldCondTree e u mergeInclusive mergeExclusive = goTree
goTree :: CondTree v c a -> b
goTree (CondNode a c ifs) = u (c, a) `mergeInclusive` foldl goBranch e ifs
goBranch :: b -> CondBranch v c a -> b
goBranch acc (CondBranch _ t mt) = mergeInclusive acc (maybe (goTree t) (mergeExclusive (goTree t) . goTree) mt)
goBranch acc (CondBranch _ t mt) = mergeInclusive acc (maybe (goTree t) (mergeExclusive (goTree t) . goTree) mt)
2 changes: 1 addition & 1 deletion Cabal-syntax/src/Distribution/Types/ExeDependency.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ instance Pretty ExeDependency where
pver | isAnyVersion ver = PP.empty
| otherwise = pretty ver

-- |
-- |
--
-- Examples
--
Expand Down
2 changes: 1 addition & 1 deletion Cabal-syntax/src/Distribution/Types/LibraryName.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ instance NFData LibraryName where rnf = genericRnf
--
-- /Note:/ there are no 'Pretty' or 'Parsec' instances,
-- as there's other way to represent 'LibraryName', namely as bare
-- 'UnqualComponentName'.
-- 'UnqualComponentName'.
prettyLibraryNameComponent :: LibraryName -> Disp.Doc
prettyLibraryNameComponent LMainLibName = Disp.text "lib"
prettyLibraryNameComponent (LSubLibName str) = Disp.text "lib:" <<>> pretty str
Expand Down
2 changes: 1 addition & 1 deletion Cabal-syntax/src/Distribution/Types/Mixin.hs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ versionGuardMultilibs = do
]

-- | Smart constructor of 'Mixin', enforces invariant.
--
--
-- @since 3.4.0.0
mkMixin :: PackageName -> LibraryName -> IncludeRenaming -> Mixin
mkMixin pn (LSubLibName uqn) incl
Expand Down
1 change: 0 additions & 1 deletion Cabal-syntax/src/Distribution/Types/PkgconfigVersion.hs
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,3 @@ isDigit8 w = 0x30 <= w && w <= 0x39
isAlpha8 :: Word8 -> Bool
isAlpha8 w = (0x41 <= w && w <= 0x5A) || (0x61 <= w && w <= 0x7A)


2 changes: 1 addition & 1 deletion Cabal-syntax/src/Distribution/Utils/Generic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ validateUTF8 = go 0 where
Just (cn, bs') | cn .&. 0xC0 == 0x80 ->
moreBytes (off + 1) (byteCount-1) overlong bs' ((acc `shiftL` 6) .|. fromIntegral cn .&. 0x3F)
_ -> Just off


-- | Ignore a Unicode byte order mark (BOM) at the beginning of the input
--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ library
default-language: Haskell2010
exposed-modules:
LeadingComma, MixedComma NoComma


build-depends: base, containers

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ maintainer: [email protected]
name: cxx-options-with-optimization
synopsis: test a build check
version: 1

library
build-depends: base >= 4.9 && <4.10
cc-options: -O2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ maintainer: [email protected]
name: cxx-options-with-optimization
synopsis: test a build check
version: 1

library
build-depends: base >= 4.9 && <4.10
cxx-options: -O2
Expand Down
Loading