From 651f58f60ddd7bcb0861a5f960354d93f5176fdf Mon Sep 17 00:00:00 2001 From: Judah Jacobson Date: Sat, 25 Aug 2018 00:01:36 -0700 Subject: [PATCH] Fix warnings and improve CI. Turns out the Travis script wasn't robust enough and #195 let through some warnings. I fixed the script and confirmed it now catches such issues. Also bumped the tutorial and bootstrap scripts to the same LTS as the main build. --- .travis.yml | 7 +++++-- proto-lens-protoc/Changelog.md | 1 + .../src/Data/ProtoLens/Compiler/Definitions.hs | 5 ++++- proto-lens-protoc/src/Data/ProtoLens/Setup.hs | 16 +++++++++------- proto-lens-tutorial/stack.yaml | 2 +- stack-bootstrap.yaml | 2 +- 6 files changed, 21 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9c1172ec..cc45a782 100644 --- a/.travis.yml +++ b/.travis.yml @@ -56,11 +56,14 @@ install: script: # Separate stack's build and test commands, since build by itself hits some # edge cases around custom Setup.hs script dependencies. + # Also build the tutorial, with proto-lens-* as extra-deps. Note that + # since stack is not hermetic, the extra-deps for the tutorial reuse some + # build outputs from the regular build. - case "$BUILD" in stack) STACK_ARGS=(--haddock --no-haddock-deps --ghc-options="-Wall -Werror"); - cd proto-lens-tutorial && $STACK build "${STACK_ARGS[@]}" && cd .. - $STACK build --bench --no-run-benchmarks "${STACK_ARGS[@]}" && $STACK test "${STACK_ARGS[@]}";; + $STACK build --bench --no-run-benchmarks "${STACK_ARGS[@]}" && $STACK test "${STACK_ARGS[@]}"; + cd proto-lens-tutorial && $STACK build "${STACK_ARGS[@]}" && cd ..;; cabal) ./travis-cabal.sh;; esac diff --git a/proto-lens-protoc/Changelog.md b/proto-lens-protoc/Changelog.md index e9c5ea2f..ec640338 100644 --- a/proto-lens-protoc/Changelog.md +++ b/proto-lens-protoc/Changelog.md @@ -2,6 +2,7 @@ ## v0.3.1.2 - Bump the upper bound to `temporary-1.3`. +- Fix warnings. ## v0.3.1.1 - Fix management of generated files between Cabal components (#171). diff --git a/proto-lens-protoc/src/Data/ProtoLens/Compiler/Definitions.hs b/proto-lens-protoc/src/Data/ProtoLens/Compiler/Definitions.hs index cf8f4b33..9ca83d89 100644 --- a/proto-lens-protoc/src/Data/ProtoLens/Compiler/Definitions.hs +++ b/proto-lens-protoc/src/Data/ProtoLens/Compiler/Definitions.hs @@ -7,6 +7,7 @@ -- | This module takes care of collecting all the definitions in a .proto file -- and assigning Haskell names to all of the defined things (messages, enums -- and field names). +{-# LANGUAGE CPP #-} {-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE OverloadedStrings #-} @@ -39,7 +40,9 @@ import Data.Int (Int32) import Data.List (mapAccumL) import qualified Data.Map as Map import Data.Maybe (fromMaybe) -import Data.Monoid +#if !MIN_VERSION_base(4,11,0) +import Data.Monoid ((<>)) +#endif import qualified Data.Semigroup as Semigroup import qualified Data.Set as Set import Data.String (IsString(..)) diff --git a/proto-lens-protoc/src/Data/ProtoLens/Setup.hs b/proto-lens-protoc/src/Data/ProtoLens/Setup.hs index d71febb0..e29f397f 100644 --- a/proto-lens-protoc/src/Data/ProtoLens/Setup.hs +++ b/proto-lens-protoc/src/Data/ProtoLens/Setup.hs @@ -24,8 +24,7 @@ module Data.ProtoLens.Setup , generateProtos ) where -import Control.DeepSeq (force) -import Control.Monad (filterM, forM_, guard, when) +import Control.Monad (filterM, forM_, when) import qualified Data.ByteString as BS import qualified Data.Map as Map import Data.Maybe (maybeToList) @@ -42,7 +41,9 @@ import Distribution.PackageDescription , exeName , exposedModules , extraSrcFiles +#if !MIN_VERSION_Cabal(2,0,0) , hsSourceDirs +#endif , libBuildInfo , otherModules , testBuildInfo @@ -66,7 +67,6 @@ import qualified Distribution.Simple.PackageIndex as PackageIndex import Distribution.Simple.Setup (fromFlag, copyDest, copyVerbosity) import Distribution.Simple.Utils ( createDirectoryIfMissingVerbose - , getDirectoryContentsRecursive , installOrdinaryFile , matchFileGlob ) @@ -78,7 +78,6 @@ import Distribution.Simple import Distribution.Verbosity (Verbosity) import System.FilePath ( () - , (<.>) , equalFilePath , isRelative , makeRelative @@ -296,6 +295,7 @@ copyProtosToDataDir verb root destDir files = do protoLensImportsPrefix :: FilePath protoLensImportsPrefix = "proto-lens-imports" +#if !MIN_VERSION_Cabal(2,0,0) -- | Add the autogen directory to the hs-source-dirs of all the targets in the -- .cabal file. Used to fool 'sdist' by pointing it to the generated source -- files. @@ -326,6 +326,7 @@ fudgePackageDesc lbi p = p : hsSourceDirs bi } | otherwise = bi -- Could happen if a component isn't active; try -- anyway and see whether Cabal complains later on. +#endif -- | Returns whether the @root@ is a parent folder of @f@. isSubdirectoryOf :: FilePath -> FilePath -> Bool @@ -398,11 +399,12 @@ findExecutableOrDie name debugMsg = do -- (e.g., `stack test` vs `stack build`). collectActiveModules :: LocalBuildInfo -> [(ComponentLocalBuildInfo, [ModuleName])] -collectActiveModules l = map (\(n, l) -> (l, f n)) $ Map.toList $ allComponents l +collectActiveModules l = map (\(n, c) -> (c, f n)) $ Map.toList $ allComponents l where p = localPkgDescr l - f CLibName = maybeToList (library p) >>= \l -> exposedModules l - ++ otherModules (libBuildInfo l) + f CLibName = maybeToList (library p) >>= + \lib -> exposedModules lib + ++ otherModules (libBuildInfo lib) f (CExeName n) = otherModules . buildInfo $ exes Map.! n f (CTestName n) = otherModules . testBuildInfo $ tests Map.! n f (CBenchName n) = otherModules . benchmarkBuildInfo $ benchs Map.! n diff --git a/proto-lens-tutorial/stack.yaml b/proto-lens-tutorial/stack.yaml index de895efe..1457c16e 100644 --- a/proto-lens-tutorial/stack.yaml +++ b/proto-lens-tutorial/stack.yaml @@ -1,4 +1,4 @@ -resolver: lts-11.7 +resolver: lts-12.7 packages: - person - coffee-order diff --git a/stack-bootstrap.yaml b/stack-bootstrap.yaml index 59e065de..e5782715 100644 --- a/stack-bootstrap.yaml +++ b/stack-bootstrap.yaml @@ -1,4 +1,4 @@ -resolver: lts-9.21 +resolver: lts-12.7 packages: - proto-lens-protoc # Build the current HEAD proto-lens-protoc against older revisions of proto-lens