Skip to content

Commit

Permalink
Text file, newlines at end of files (backport #9804) (#10007)
Browse files Browse the repository at this point in the history
* Add back whitespace workflow

(cherry picked from commit 265f149)

* Whitespace conventions in contributing

(cherry picked from commit 7c9346b)

* Fix whitespace in workflows

(cherry picked from commit c31ca12)

# Conflicts:
#	.github/workflows/validate.yml

* Fix whitespace in docs

(cherry picked from commit 2ea012e)

* Fix whitespace in *.hs sources

(cherry picked from commit e420bf2)

* Add missing line at EOF for cabal-testsuite/**/*.hs

- Fix whitespace in cabal-testsuite + other tests

(cherry picked from commit e386a13)

* Fix whitespace in fourmolu configuration

(cherry picked from commit b790751)

* Configure fix-whitespace to include *.project

Needed for POSIX compliance for text files

(cherry picked from commit ed4c36a)

* Fix whitespace in *.project

(cherry picked from commit 38eb1e8)

* Ignore generated doc/buildinfo-fields-reference.rst

(cherry picked from commit b414faf)

* Reduce double space between prose words

Co-authored-by: brandon s allbery kf8nh <allbery.b@gmail.com>
(cherry picked from commit 834e1ed)

* Use fix-whitespace-action

(cherry picked from commit eb87ffd)

* Fix merge conflict

---------

Co-authored-by: Phil de Joux <philderbeast@gmail.com>
Co-authored-by: Hécate <Kleidukos@users.noreply.github.com>
  • Loading branch information
3 people committed May 13, 2024
1 parent d7ce36f commit ea05e10
Show file tree
Hide file tree
Showing 71 changed files with 105 additions and 86 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/bootstrap.skip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ name: Bootstrap Skip
# to the docs, since these jobs take a long time to complete without providing any benefit.
# We therefore use path-filtering in the workflow triggers for the bootstrap jobs, namely
# "paths-ignore: doc/**". But the "Bootstrap post job" is a required job, therefore a PR cannot
# be merged unless the "Bootstrap post job" completes succesfully, which it doesn't do if we
# be merged unless the "Bootstrap post job" completes succesfully, which it doesn't do if we
# filter it out.
#
# The solution: We use a second job with the same name which always returns the exit code 0.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/validate.skip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ name: Validate Skip
# to the docs, since these jobs take a long time to complete without providing any benefit.
# We therefore use path-filtering in the workflow triggers for the validate jobs, namely
# "paths-ignore: doc/**". But the "Validate post job" is a required job, therefore a PR cannot
# be merged unless the "Validate post job" completes succesfully, which it doesn't do if we
# be merged unless the "Validate post job" completes succesfully, which it doesn't do if we
# filter it out.
#
# The solution: We use a second job with the same name which always returns the exit code 0.
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,8 @@ jobs:

build-alpine:
name: Build statically linked using alpine
runs-on: ubuntu-latest
container: 'alpine:3.19'
runs-on: "ubuntu-latest"
container: "alpine:3.19"
steps:
- name: Install extra dependencies
shell: sh
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/whitespace.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Whitespace

on:
pull_request:
push:
branches: ["master"]

jobs:
whitespace:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: andreasabel/fix-whitespace-action@v1
9 changes: 7 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ and should be written in the body of the ticket or PR under their own heading, l
For instance:

> \#\# QA Notes
>
>
> Calling `cabal haddock-project` should produce documentation for the whole cabal project with the following defaults enabled:
> * Documentation lives in ./haddocks
> * The file `./haddocks/index.html` should exist
Expand All @@ -163,7 +163,12 @@ the code base.
* `make style-modified` - Format files modified in the current tree.
* `make style-commit COMMIT=<ref>` - Format files modified between HEAD and the given reference.

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

We use automated whitespace convention checking. Violations can be fixed by
running [fix-whitespace](https://hackage.haskell.org/package/fix-whitespace). If
you push a fix of a whitespace violation, please do so in a _separate commit_.

Other Conventions
-----------------
Expand Down Expand Up @@ -386,7 +391,7 @@ Running workflow manually as discussed above requires you to supply two inputs:
Going via an example, imagine that Cabal only allows `tar` or version less then
or equal to 0.6, and you want to bump it to 0.6. Then, to show that Validate
succeeds with `tar` 0.6, you should input
succeeds with `tar` 0.6, you should input

- `tar` to the "allow-newer line"
- `tar ==0.6` to the "constraints line"
Expand Down
2 changes: 1 addition & 1 deletion Cabal-described/src/Distribution/Described.hs
Original file line number Diff line number Diff line change
Expand Up @@ -591,4 +591,4 @@ instance Described CompatLicenseFile where
describe _ = describe ([] :: [Token])

instance Described CompatFilePath where
describe _ = describe ([] :: [Token])
describe _ = describe ([] :: [Token])
2 changes: 1 addition & 1 deletion Cabal-described/src/Distribution/Utils/CharSet.hs
Original file line number Diff line number Diff line change
Expand Up @@ -244,4 +244,4 @@ upper = foldl' (flip insert) empty [ c | c <- [ minBound .. maxBound ], isUpper
-- $setup
-- Use -XOverloadedStrings to avoid the error: Couldn't match type ‘[Char]’ with ‘CharSet’
-- >>> :set -XOverloadedStrings
-- >>> import Prelude (length)
-- >>> import Prelude (length)
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ tests = testGroup "Distribution.Simple.Program.GHC"
, compilerCompat = []
, compilerLanguages = []
, compilerExtensions = []
, compilerProperties = Map.singleton "Support parallel --make" "YES"
, compilerProperties = Map.singleton "Support parallel --make" "YES"
})
(Platform X86_64 Linux)
(mempty { ghcOptNumJobs = Flag (NumJobs (Just 4)) })
assertListEquals flags ["-j4", "-clear-package-db"]
]
]
]

assertListEquals :: (Eq a, Show a) => [a] -> [a] -> Assertion
Expand Down Expand Up @@ -190,4 +190,4 @@ options_9_0_all =
options_9_0_affects :: [String]
options_9_0_affects =
[ "-fcmm-static-pred"
]
]
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ Currently, we only provide binaries for `x86_64` platforms.
```

Replace "Linux" with "Windows" or "macOS" as appropriate.

The default Linux build is dynamically linked against `zlib`, `gmp` and `glibc`.
You will need to have appropriate versions of these libraries installed to use it.
Alternatively a statically linked "Linux-static" binary is also provided.

You might need to add the following to your `cabal.project` file
if your build fails because of an out-of-date `Cabal` library:
```
allow-newer:
allow-newer:
*:Cabal,
*:Cabal-syntax
Expand Down
2 changes: 1 addition & 1 deletion bootstrap/src/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ main2 meta plan = do
case P.uPkgSrc unit of
Just (P.RepoTarballPackage (P.RepoSecure _uri)) ->
return Hackage
Just (P.LocalUnpackedPackage _path) ->
Just (P.LocalUnpackedPackage _path) ->
return Local
pkgsrc ->
die $ "package source not supported: " ++ show pkgsrc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,4 +360,4 @@ showConflictingDep (ConflictingDep dr (PkgComponent qpn comp) ci) =
-- >>> let v0 = POption (I (mkVersion [0]) InRepo) Nothing
-- >>> let v1 = POption (I (mkVersion [1]) InRepo) Nothing
-- >>> let i0 = POption (I (mkVersion [0]) (Inst $ mkUnitId "foo-bar-0-inplace")) Nothing
-- >>> let i1 = POption (I (mkVersion [1]) (Inst $ mkUnitId "foo-bar-1-inplace")) Nothing
-- >>> let i1 = POption (I (mkVersion [1]) (Inst $ mkUnitId "foo-bar-1-inplace")) Nothing
2 changes: 1 addition & 1 deletion cabal-install/tests/IntegrationTests2/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
config/default-config
config/default-config
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
packages: .

coverage: true
coverage: true
2 changes: 1 addition & 1 deletion cabal-install/tests/fixtures/configure/cabal.project
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ignore-project: False
optimization: 2
optimization: 2
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ main = setupTest $ do
skipUnlessGhcVersion ">= 8.1"
ghc <- isGhcVersion "== 9.0.2 || == 9.2.* || == 9.4.* || == 9.6.*"
expectBrokenIf ghc 7987 $
withPackageDb $
withPackageDb $
withDirectory "Includes2" $ do
let setup_install' args = setup_install_with_docs args
setup_install' ["mylib", "--cid", "mylib-0.1.0.0"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,3 @@ executable demo
else
cmm-options: -ddump-cmm


Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ main = setupTest $ do
res <- fails $ withDirectory "custom" $ setup' "aaaa" []
assertOutputContains "unrecognised command" res


2 changes: 1 addition & 1 deletion cabal-testsuite/PackageTests/ExtraProgPath/cabal.project
Original file line number Diff line number Diff line change
@@ -1 +1 @@
packages: *.cabal
packages: *.cabal
2 changes: 1 addition & 1 deletion cabal-testsuite/PackageTests/HaddockArgs/cabal.project
Original file line number Diff line number Diff line change
@@ -1 +1 @@
packages: .
packages: .
2 changes: 1 addition & 1 deletion cabal-testsuite/PackageTests/HaddockWarn/cabal.project
Original file line number Diff line number Diff line change
@@ -1 +1 @@
packages: .
packages: .
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ import qualified Distribution.Simple as DS
import Distribution.Simple.Setup

main :: IO ()
main = DS.defaultMainWithHooks DS.simpleUserHooks
main = DS.defaultMainWithHooks DS.simpleUserHooks
Original file line number Diff line number Diff line change
@@ -1 +1 @@
packages: .
packages: .
Original file line number Diff line number Diff line change
@@ -1 +1 @@
packages: .
packages: .
Original file line number Diff line number Diff line change
@@ -1 +1 @@
packages: .
packages: .
Original file line number Diff line number Diff line change
@@ -1 +1 @@
packages: .
packages: .
2 changes: 1 addition & 1 deletion cabal-testsuite/PackageTests/PkgConfigParse/cabal.project
Original file line number Diff line number Diff line change
@@ -1 +1 @@
packages: *.cabal
packages: *.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ packages: .

package cabal-gh5213
coverage: True
optimization: False
optimization: False
Original file line number Diff line number Diff line change
@@ -1 +1 @@
packages: issue5782
packages: issue5782
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ import: ./dep/cabal.project
packages:
main.cabal
dep/dep.cabal
dep2/dep2.cabal
dep2/dep2.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ import Test.Cabal.Prelude
-- TODO: Fix this behaviour and apply the patch cabal.dot-uv.patch to update the
-- expected output to what we'd expect if "cabal sdist" respected the project.
main = cabalTest . withProjectFile "cabal.dot-uv.project" $ do
cabal "sdist" ["all"]
cabal "sdist" ["all"]
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ import Test.Cabal.Prelude
-- cabal.dot-uv.project has "packages: .". That package is uv.cabal and "cabal
-- v2-sdist" writes sdist/uv-0.1.tar.gz. This is correct.
main = cabalTest . withProjectFile "cabal.dot-uv.project" $ do
cabal "v2-sdist" ["all"]
cabal "v2-sdist" ["all"]
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ import Test.Cabal.Prelude

-- This test correctly writes sdist/uv-0.1.tar.gz for the uv.cabal package.
main = cabalTest $ do
cabal "sdist" ["all", "--ignore-project"]
cabal "sdist" ["all", "--ignore-project"]
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ import Test.Cabal.Prelude
-- and wrote sdist/p-0.1.tar.gz. That is incorrect. It didn't ignore the
-- project.
main = cabalTest $ do
cabal "v2-sdist" ["all", "--ignore-project"]
cabal "v2-sdist" ["all", "--ignore-project"]
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ import Test.Cabal.Prelude
-- project probing would not occur and "cabal sdist" would work on the local
-- uv.cabal package.
main = cabalTest $ do
cabal "sdist" ["all"]
cabal "sdist" ["all"]
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ import Test.Cabal.Prelude
-- seen) is that project probing would not occur and "cabal v2-sdist" would work
-- on the local uv.cabal package.
main = cabalTest $ do
cabal "v2-sdist" ["all"]
cabal "v2-sdist" ["all"]
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ import Test.Cabal.Prelude
-- TODO: Fix this behaviour and apply the patch cabal.sub-pq.patch to update the
-- expected output to what we'd expect if "cabal sdist" respected the project.
main = cabalTest . withProjectFile "cabal.sub-pq.project" $ do
cabal "sdist" ["all"]
cabal "sdist" ["all"]
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ import Test.Cabal.Prelude
-- cabal.sub-pq.project has "packages: p/ q/" and "cabal v2-sdist" writes
-- sdist/p-0.1.tar.gz and sdist/q-0.1.tar.gz. This is correct.
main = cabalTest . withProjectFile "cabal.sub-pq.project" $ do
cabal "v2-sdist" ["all"]
cabal "v2-sdist" ["all"]
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ import Test.Cabal.Prelude
-- TODO: Fix this behaviour and apply the patch cabal.sub-rs.patch to update the
-- expected output to what we'd expect if "cabal sdist" respected the project.
main = cabalTest . withProjectFile "cabal.sub-rs.project" $ do
cabal "sdist" ["all"]
cabal "sdist" ["all"]
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ import Test.Cabal.Prelude
-- cabal.sub-rs.project has "packages: r/ s/" and "cabal v2-sdist" writes
-- sdist/r-0.1.tar.gz and sdist/s-0.1.tar.gz. This is correct.
main = cabalTest . withProjectFile "cabal.sub-rs.project" $ do
cabal "v2-sdist" ["all"]
cabal "v2-sdist" ["all"]
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ import Test.Cabal.Prelude
-- TODO: Fix this behaviour and apply the patch cabal.dot-uv.patch to update the
-- expected output to what we'd expect if "cabal sdist" respected the project.
main = cabalTest . withProjectFile "cabal.dot-uv.project" $ do
cabal "sdist" ["all"]
cabal "sdist" ["all"]
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ import Test.Cabal.Prelude
-- cabal.dot-uv.project has "packages: .". That package is uv.cabal and "cabal
-- v2-sdist" writes sdist/p-0.1.tar.gz and sdist/q-0.1.tar.gz. That is correct.
main = cabalTest . withProjectFile "cabal.dot-uv.project" $ do
cabal "v2-sdist" ["all"]
cabal "v2-sdist" ["all"]
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ import Test.Cabal.Prelude

-- This test correctly writes sdist/uv-0.1.tar.gz for the uv.cabal package.
main = cabalTest $ do
cabal "sdist" ["all", "--ignore-project"]
cabal "sdist" ["all", "--ignore-project"]
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ import Test.Cabal.Prelude
-- sdist/uv-0.1.tar.gz for the uv.cabal package but instead it wrote
-- sdist/p-0.1.tar.gz and sdist/q-0.1.tar.gz.
main = cabalTest $ do
cabal "v2-sdist" ["all", "--ignore-project"]
cabal "v2-sdist" ["all", "--ignore-project"]
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ import Test.Cabal.Prelude
-- TODO: Check that the code is behaving the same as it would have if
-- "--project-file=cabal.project" was given or if it is using project probing.
main = cabalTest $ do
cabal "sdist" ["all"]
cabal "sdist" ["all"]
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ import Test.Cabal.Prelude
-- has "packages: p/ q/" and writes sdist/p-0.1.tar.gz and sdist/q-0.1.tar.gz.
-- This is correct.
main = cabalTest $ do
cabal "v2-sdist" ["all"]
cabal "v2-sdist" ["all"]
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ import Test.Cabal.Prelude
-- sdist/p-0.1.tar.gz and sdist/q-0.1.tar.gz. This is correct but likely
-- accidental as the default cabal.project has the same packages.
main = cabalTest . withProjectFile "cabal.project" $ do
cabal "sdist" ["all"]
cabal "sdist" ["all"]
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ import Test.Cabal.Prelude
-- The given cabal.project has has "packages: p/ q/" and "cabal v2-sdist" writes
-- sdist/p-0.1.tar.gz and sdist/q-0.1.tar.gz. This is correct.
main = cabalTest . withProjectFile "cabal.project" $ do
cabal "v2-sdist" ["all"]
cabal "v2-sdist" ["all"]
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ import Test.Cabal.Prelude
-- cabal.sub-pq.project has "packages: p/ q/" and "cabal sdist" writes
-- sdist/p-0.1.tar.gz and sdist/q-0.1.tar.gz. This is correct.
main = cabalTest . withProjectFile "cabal.sub-pq.project" $ do
cabal "sdist" ["all"]
cabal "sdist" ["all"]
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ import Test.Cabal.Prelude
-- cabal.sub-pq.project has "packages: p/ q/" and "cabal v2-sdist" writes
-- sdist/p-0.1.tar.gz and sdist/q-0.1.tar.gz. This is correct.
main = cabalTest . withProjectFile "cabal.sub-pq.project" $ do
cabal "v2-sdist" ["all"]
cabal "v2-sdist" ["all"]
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ import Test.Cabal.Prelude
-- TODO: Fix this behaviour and apply the patch cabal.sub-rs.patch to update the
-- expected output to what we'd expect if "cabal sdist" respected the project.
main = cabalTest . withProjectFile "cabal.sub-rs.project" $ do
cabal "sdist" ["all"]
cabal "sdist" ["all"]
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ import Test.Cabal.Prelude
-- cabal.sub-rs.project has "packages: r/ s/" and "cabal v2-sdist" writes
-- sdist/r-0.1.tar.gz and sdist/s-0.1.tar.gz. That is correct.
main = cabalTest . withProjectFile "cabal.sub-rs.project" $ do
cabal "v2-sdist" ["all"]
cabal "v2-sdist" ["all"]
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ with these tests.
`cabal.project` instead; either the one one in the current directory or the
one from the parent directory, one level up. I think this behaviour is wrong
and the supplied `--project-file` option should be respected.

Before I'd put a project there, one level up, the project probing had gone
all the way up to Cabal's own `cabal.project` as can be seen by this diff
after that change:
Expand Down

0 comments on commit ea05e10

Please sign in to comment.