File tree 28 files changed +59
-37
lines changed
cabal-install/src/Distribution/Client
cabal-testsuite/PackageTests/Check
GHCOptions/GHCSharedOptions
28 files changed +59
-37
lines changed Original file line number Diff line number Diff line change
1
+ {-# LANGUAGE LambdaCase #-}
2
+
1
3
-----------------------------------------------------------------------------
2
4
-- |
3
5
-- Module : Distribution.PackageDescription.Check
@@ -28,6 +30,7 @@ module Distribution.PackageDescription.Check (
28
30
checkConfiguredPackage ,
29
31
wrapParseWarning ,
30
32
ppPackageCheck ,
33
+ isHackageDistError ,
31
34
32
35
-- ** Checking package contents
33
36
checkPackageFiles ,
@@ -846,6 +849,15 @@ data PackageCheck =
846
849
| PackageDistInexcusable { explanation :: CheckExplanation }
847
850
deriving (Eq , Ord )
848
851
852
+ -- | Would Hackage refuse a package because of this error?
853
+ isHackageDistError :: PackageCheck -> Bool
854
+ isHackageDistError = \ case
855
+ (PackageBuildImpossible {}) -> True
856
+ (PackageBuildWarning {}) -> True
857
+ (PackageDistInexcusable {}) -> True
858
+ (PackageDistSuspicious {}) -> False
859
+ (PackageDistSuspiciousWarn {}) -> False
860
+
849
861
-- | Pretty printing 'PackageCheck'.
850
862
--
851
863
ppPackageCheck :: PackageCheck -> String
Original file line number Diff line number Diff line change @@ -501,10 +501,7 @@ printPackageProblems :: Verbosity -> PackageDescription -> IO ()
501
501
printPackageProblems verbosity pkg_descr = do
502
502
ioChecks <- checkPackageFiles verbosity pkg_descr " ."
503
503
let pureChecks = checkConfiguredPackage pkg_descr
504
- isDistError (PackageDistSuspicious _) = False
505
- isDistError (PackageDistSuspiciousWarn _) = False
506
- isDistError _ = True
507
- (errors, warnings) = partition isDistError (pureChecks ++ ioChecks)
504
+ (errors, warnings) = partition isHackageDistError (pureChecks ++ ioChecks)
508
505
unless (null errors) $
509
506
notice verbosity $ " Distribution quality errors:\n "
510
507
++ unlines (map ppPackageCheck errors)
Original file line number Diff line number Diff line change @@ -48,7 +48,9 @@ readGenericPackageDescriptionCheck verbosity fpath = do
48
48
die' verbosity " parse error"
49
49
Right x -> return (warnings, x)
50
50
51
- -- | Note: must be called with the CWD set to the directory containing
51
+ -- | Checks a packge for common errors. Returns @True@ if the package
52
+ -- is fit to upload to Hackage, @False@ otherwise.
53
+ -- Note: must be called with the CWD set to the directory containing
52
54
-- the '.cabal' file.
53
55
check :: Verbosity -> IO Bool
54
56
check verbosity = do
@@ -94,20 +96,15 @@ check verbosity = do
94
96
warn verbosity " The following errors will cause portability problems on other environments:"
95
97
printCheckMessages distInexusable
96
98
97
- let isDistError (PackageDistSuspicious {}) = False
98
- isDistError (PackageDistSuspiciousWarn {}) = False
99
- isDistError _ = True
100
- isCheckError (PackageDistSuspiciousWarn {}) = False
101
- isCheckError _ = True
102
- errors = filter isDistError packageChecks
99
+ let errors = filter isHackageDistError packageChecks
103
100
104
101
unless (null errors) $
105
102
warn verbosity " Hackage would reject this package."
106
103
107
104
when (null packageChecks) $
108
105
notice verbosity " No errors or warnings could be found in the package."
109
106
110
- return (not . any isCheckError $ packageChecks )
107
+ return (null errors )
111
108
112
109
where
113
110
printCheckMessages :: [PackageCheck ] -> IO ()
Original file line number Diff line number Diff line change @@ -1201,8 +1201,9 @@ checkCommand = CommandUI {
1201
1201
" Expects a .cabal package file in the current directory.\n "
1202
1202
++ " \n "
1203
1203
++ " The checks correspond to the requirements to packages on Hackage. "
1204
- ++ " If no errors and warnings are reported, Hackage will accept this "
1205
- ++ " package.\n " ,
1204
+ ++ " If no errors and warnings are reported, Hackage should accept the "
1205
+ ++ " package. If errors are present, `check` exits with 1 and Hackage "
1206
+ ++ " will refuse the package.\n " ,
1206
1207
commandNotes = Nothing ,
1207
1208
commandUsage = usageFlags " check" ,
1208
1209
commandDefaultFlags = toFlag normal,
Original file line number Diff line number Diff line change @@ -2,4 +2,4 @@ import Test.Cabal.Prelude
2
2
3
3
-- `cxx-options`, do not use `-O1`.
4
4
main = cabalTest $
5
- fails $ cabal " check" []
5
+ cabal " check" []
Original file line number Diff line number Diff line change @@ -2,4 +2,4 @@ import Test.Cabal.Prelude
2
2
3
3
-- `default-extensions` need ≥1.10.
4
4
main = cabalTest $
5
- fails $ cabal " check" []
5
+ cabal " check" []
Original file line number Diff line number Diff line change @@ -2,4 +2,4 @@ import Test.Cabal.Prelude
2
2
3
3
-- `default-language` need ≥1.10.
4
4
main = cabalTest $
5
- fails $ cabal " check" []
5
+ cabal " check" []
Original file line number Diff line number Diff line change @@ -2,4 +2,4 @@ import Test.Cabal.Prelude
2
2
3
3
-- `extra-dynamic-library-flavour` need ≥3.0.
4
4
main = cabalTest $
5
- fails $ cabal " check" []
5
+ cabal " check" []
Original file line number Diff line number Diff line change @@ -2,4 +2,4 @@ import Test.Cabal.Prelude
2
2
3
3
-- `mixins` need ≥2.0.
4
4
main = cabalTest $
5
- fails $ cabal " check" []
5
+ cabal " check" []
Original file line number Diff line number Diff line change @@ -2,4 +2,4 @@ import Test.Cabal.Prelude
2
2
3
3
-- `cmm-sources` and friends need ≥3.0.
4
4
main = cabalTest $
5
- fails $ cabal " check" []
5
+ cabal " check" []
Original file line number Diff line number Diff line change @@ -2,4 +2,4 @@ import Test.Cabal.Prelude
2
2
3
3
-- `virtual-modules` need ≥2.2.
4
4
main = cabalTest $
5
- fails $ cabal " check" []
5
+ cabal " check" []
Original file line number Diff line number Diff line change @@ -2,4 +2,4 @@ import Test.Cabal.Prelude
2
2
3
3
-- Deprecated extension.
4
4
main = cabalTest $
5
- fails $ cabal " check" []
5
+ cabal " check" []
Original file line number Diff line number Diff line change @@ -2,4 +2,4 @@ import Test.Cabal.Prelude
2
2
3
3
-- No category.
4
4
main = cabalTest $
5
- fails $ cabal " check" []
5
+ cabal " check" []
Original file line number Diff line number Diff line change @@ -2,4 +2,4 @@ import Test.Cabal.Prelude
2
2
3
3
-- No description.
4
4
main = cabalTest $
5
- fails $ cabal " check" []
5
+ cabal " check" []
Original file line number Diff line number Diff line change @@ -2,4 +2,4 @@ import Test.Cabal.Prelude
2
2
3
3
-- No maintainer.
4
4
main = cabalTest $
5
- fails $ cabal " check" []
5
+ cabal " check" []
Original file line number Diff line number Diff line change @@ -2,4 +2,4 @@ import Test.Cabal.Prelude
2
2
3
3
-- No synopsis.
4
4
main = cabalTest $
5
- fails $ cabal " check" []
5
+ cabal " check" []
Original file line number Diff line number Diff line change @@ -2,4 +2,4 @@ import Test.Cabal.Prelude
2
2
3
3
-- Description should be longer than synopsis.
4
4
main = cabalTest $
5
- fails $ cabal " check" []
5
+ cabal " check" []
Original file line number Diff line number Diff line change @@ -2,4 +2,4 @@ import Test.Cabal.Prelude
2
2
3
3
-- Tricky option in `ghc-shared-options`.
4
4
main = cabalTest $
5
- fails $ cabal " check" []
5
+ cabal " check" []
Original file line number Diff line number Diff line change @@ -2,4 +2,4 @@ import Test.Cabal.Prelude
2
2
3
3
-- `licence-file` missing.
4
4
main = cabalTest $
5
- fails $ cabal " check" []
5
+ cabal " check" []
Original file line number Diff line number Diff line change @@ -2,4 +2,4 @@ import Test.Cabal.Prelude
2
2
3
3
-- Suspicious license BSD4.
4
4
main = cabalTest $
5
- fails $ cabal " check" []
5
+ cabal " check" []
Original file line number Diff line number Diff line change @@ -2,4 +2,4 @@ import Test.Cabal.Prelude
2
2
3
3
-- Suspicious license version.
4
4
main = cabalTest $
5
- fails $ cabal " check" []
5
+ cabal " check" []
Original file line number Diff line number Diff line change @@ -2,4 +2,4 @@ import Test.Cabal.Prelude
2
2
3
3
-- Dubious AllRightsReserved.
4
4
main = cabalTest $
5
- fails $ cabal " check" []
5
+ cabal " check" []
Original file line number Diff line number Diff line change @@ -2,4 +2,4 @@ import Test.Cabal.Prelude
2
2
3
3
-- `signatures` field used with cabal-version < 2.0
4
4
main = cabalTest $
5
- fails $ cabal " check" []
5
+ cabal " check" []
Original file line number Diff line number Diff line change @@ -2,4 +2,4 @@ import Test.Cabal.Prelude
2
2
3
3
-- Profiling flags unsuited for distribution.
4
4
main = cabalTest $
5
- fails $ cabal " check" []
5
+ cabal " check" []
Original file line number Diff line number Diff line change @@ -2,4 +2,4 @@ import Test.Cabal.Prelude
2
2
3
3
-- Unused flag.
4
4
main = cabalTest $
5
- fails $ cabal " check" []
5
+ cabal " check" []
Original file line number Diff line number Diff line change @@ -2,4 +2,4 @@ import Test.Cabal.Prelude
2
2
3
3
-- Missing VCS info.
4
4
main = cabalTest $
5
- fails $ cabal " check" []
5
+ cabal " check" []
Original file line number Diff line number Diff line change
1
+ synopsis: Make check comply with Hackage requirements
2
+ packages: Cabal cabal-install
3
+ prs: #8897
4
+
5
+ description: {
6
+
7
+ - `cabal check` will only return exitcode 1 when the package is not fit
8
+ for Hackage. E.g. it will not error anymore when your `synopsis:` is
9
+ larger than `description:`, just emit a warning.
10
+ - Cabal: Distribution.Client.Check now exports `isHackageDistError`, for
11
+ third-party tools to know if a specific error will preclude a package
12
+ from being uploaded to Hacakge.
13
+
14
+ }
Original file line number Diff line number Diff line change @@ -977,7 +977,8 @@ Run ``cabal check`` in the folder where your ``.cabal`` package file is.
977
977
Set verbosity level (0–3, default is 1).
978
978
979
979
``cabal check `` mimics Hackage's requirements: if no error or warning
980
- is reported, Hackage should accept your package.
980
+ is reported, Hackage should accept your package. If errors are present
981
+ ``cabal check `` exits with ``1 `` and Hackage will refuse the package.
981
982
982
983
cabal sdist
983
984
^^^^^^^^^^^
You can’t perform that action at this time.
0 commit comments