neil 0.9 → 0.10
raw patch · 3 files changed
+38/−28 lines, 3 files
Files
- neil.cabal +3/−3
- src/Cabal.hs +29/−21
- src/Git.hs +6/−4
neil.cabal view
@@ -1,7 +1,7 @@ cabal-version: >= 1.6 build-type: Simple name: neil-version: 0.9+version: 0.10 license: BSD3 license-file: LICENSE category: Development@@ -14,8 +14,8 @@ them in the Git repo. homepage: http://community.haskell.org/~ndm/ bug-reports: https://github.com/ndmitchell/neil/issues-tested-with: GHC==7.10.1, GHC==7.8.3, GHC==7.6.3, GHC==7.4.2, GHC==7.2.2-extra-source-files:+tested-with: GHC==7.10.1, GHC==7.8.4, GHC==7.6.3, GHC==7.4.2, GHC==7.2.2+extra-doc-files: CHANGES.txt README.md
src/Cabal.hs view
@@ -12,8 +12,9 @@ import System.FilePath import System.Process.Extra import Arguments+import Prelude -defAllow = ["7.2.2","7.4.2","7.6.3","7.8.3","7.10.1"]+defAllow = ["7.2.2","7.4.2","7.6.3","7.8.4","7.10.1"] ---------------------------------------------------------------------@@ -40,11 +41,10 @@ checkGhci :: IO () checkGhci = do- src <- readFile' ".ghci"- let require = words "-fwarn-unused-binds -fwarn-unused-imports"- let missing = require \\ words src- when (missing /= []) $- error $ "The .ghci file does not contain " ++ unwords missing+ let warns = words "-fwarn-unused-binds -fwarn-unused-imports"+ src <- words <$> readFile' ".ghci"+ unless ("-W" `elem` src || all (`elem` src) warns) $+ error $ "The .ghci file does not enough of " ++ unwords ("-W":warns) checkTravis :: IO ()@@ -58,7 +58,10 @@ ," - wget https://raw.github.com/ndmitchell/neil/master/travis.sh -O - --no-check-certificate --quiet | sh" ] src <- readFile' ".travis.yml"- let got = filter (not . null) $ map (trimEnd . takeWhile (/= '#')) $ lines src+ let got = filter (not . null) $ replace ["matrix:"," allow_failures:"," - env: GHCVER=head"] [] $+ map (trimEnd . takeWhile (/= '#')) $ lines src+ when ("allow_failures:" `isInfixOf` src) $ putStrLn $ "Warning: .travis.yml allows failures with GHC HEAD"+ got <- return $ take (length require - 1) got ++ [last got] -- drop everything between script/wget when (got /= require) $ error $ unlines $ [".travis.yml file mismatch","Wanted:"] ++ require ++@@ -68,6 +71,7 @@ -- | Run some commands in a temporary directory with the unpacked cabal withSDist :: IO a -> IO a withSDist run = withTempDir $ \tdir -> do+ system_ "git diff --stat --exit-code" system_ $ "cabal configure --builddir=" ++ tdir system_ $ "cabal sdist --builddir=" ++ tdir files <- getDirectoryContents tdir@@ -89,13 +93,15 @@ withSDist $ do system_ "cabal install --only-dependencies" system_ $ "cabal configure --enable-tests --disable-library-profiling " +++ "--ghc-option=-rtsopts " ++ "--ghc-option=-fwarn-unused-binds --ghc-option=-fwarn-unused-imports " ++ "--ghc-option=-fwarn-tabs " ++ (if no_warnings then "" else "--ghc-option=-Werror") system_ "cabal build" system_ "cabal test --show-details=always"- when install $- system_ "cabal install --force-reinstalls"+ when install $ do+ system_ "cabal copy"+ system_ "cabal register" run Check = Just cabalCheck @@ -117,7 +123,7 @@ src <- readCabal let ver = extractCabal "version" src let name = extractCabal "name" src- system_ $ "cabal haddock --hoogle --hyperlink-source " +++ system_ $ "cabal haddock --hoogle --html --hyperlink-source " ++ "--contents-location=/package/" ++ name withTempDir $ \dir -> do system_ $ "cp -R dist/doc/html/" ++ name ++ " \"" ++ dir ++ "/" ++ name ++ "-" ++ ver ++ "-docs\""@@ -168,13 +174,13 @@ checkReadme :: IO () checkReadme = do project <- takeBaseName . fromMaybe (error "Couldn't find cabal file") <$> findCabal+ src <- fmap lines $ readFile "README.md" let want = "[]" ++ "(https://hackage.haskell.org/package/" ++ project ++ ") " ++- "[]" ++- "(https://travis-ci.org/" ++ qualify project ++ ")"- src <- readFile "README.md"- let line1 = head $ lines src ++ [""]+ "[]" +++ "(https://travis-ci.org/" ++ qualify src project ++ ")"+ let line1 = head $ src ++ [""] when (not $ want `isSuffixOf` line1) $ error $ "Expected first line of README.md to end with:\n" ++ want ++ "\nBut got:\n" ++ line1 @@ -194,22 +200,24 @@ ["2015 is not in the copyright year" | not $ "2015" `isInfixOf` concat (grab "copyright")] ++ ["copyright string is not at the start of the license" | not $ (concat (grab "copyright") `isInfixOf` concat (take 1 $ lines license)) || grab "license" == ["GPL"]] ++ ["No correct source-repository link"- | let want = "source-repository head type: git location: https://github.com/" ++ qualify project ++ ".git"+ | let want = "source-repository head type: git location: https://github.com/" ++ qualify src project ++ ".git" , not $ want `isInfixOf` unwords (words $ unlines src)] ++- ["No bug-reports link" | grab "bug-reports" /= ["https://github.com/" ++ qualify project ++ "/issues"]] +++ ["No bug-reports link" | grab "bug-reports" /= ["https://github.com/" ++ qualify src project ++ "/issues"]] ++ ["Incorrect license " | grab "license" `notElem` [["BSD3"],["MIT"],["GPL"]]] ++ ["Invalid tested-with: " ++ show test | not $ validTests test] ++ ["Bad stabilty, should be missing" | grab "stability" /= []] ++- ["Missing CHANGES.txt in extra-source-files" | ["CHANGES.txt","changelog.md"] `disjoint` concatMap words (grab "extra-source-files")] ++- ["Missing README.md in extra-source-files" | "README.md" `notElem` concatMap words (grab "extra-source-files")]+ ["Missing CHANGES.txt in extra-doc-files" | ["CHANGES.txt","changelog.md"] `disjoint` concatMap words (grab "extra-doc-files")] +++ ["Missing README.md in extra-doc-files" | "README.md" `notElem` concatMap words (grab "extra-doc-files")] unless (null bad) $ error $ unlines bad validTests :: [String] -> Bool validTests xs = length xs > 1 && xs `isPrefixOf` reverse defAllow -qualify :: String -> String-qualify "filepath" = "haskell/filepath"-qualify x = "ndmitchell/" ++ x+qualify :: [String] -> String -> String+qualify src proj = user ++ "/" ++ proj+ where user1 = takeWhile (/= '/') $ drop 19 $ snd $ breakOn "https://github.com/" $ unlines src+ user2 = takeWhile (/= '/') $ drop 30 $ snd $ breakOn "https://img.shields.io/travis/" $ unlines src+ user = if user2 /= "" then user2 else if user1 /= "" then user1 else "ndmitchell" relines :: [String] -> [String] relines (x:xs) | ":" `isSuffixOf` x = unwords (x:a) : relines b
src/Git.hs view
@@ -4,6 +4,7 @@ import Control.Monad import Data.List.Extra+import Control.Exception.Extra import System.Directory.Extra import System.Exit import System.FilePath@@ -59,11 +60,12 @@ run Tag = Just $ do src <- readCabal+ let [name] = [trim $ drop 5 x | x <- lines src, "name:" `isPrefixOf` x] let [ver] = [trim $ drop 8 x | x <- lines src, "version:" `isPrefixOf` x]- putStrLn $ "Confirm to tag the release with version " ++ ver ++ "? Type 'yes':"+ putStrLn $ "Confirm to tag the release with '" ++ name ++ " " ++ ver ++ "'? Type 'yes':" "yes" <- getLine- system_ "git push"- system_ $ "git tag v" ++ ver- system_ "git push --tags"+ retry 2 $ system_ "git push"+ system_ $ "git tag -a -s -m \"" ++ name ++ " " ++ ver ++ "\" v" ++ ver+ retry 2 $ system_ "git push --tags" run _ = Nothing