Skip to content

Commit

Permalink
Fix warnings and improve CI.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
judah committed Aug 25, 2018
1 parent 3cbb18c commit 651f58f
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 12 deletions.
7 changes: 5 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions proto-lens-protoc/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
5 changes: 4 additions & 1 deletion proto-lens-protoc/src/Data/ProtoLens/Compiler/Definitions.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 #-}
Expand Down Expand Up @@ -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(..))
Expand Down
16 changes: 9 additions & 7 deletions proto-lens-protoc/src/Data/ProtoLens/Setup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -42,7 +41,9 @@ import Distribution.PackageDescription
, exeName
, exposedModules
, extraSrcFiles
#if !MIN_VERSION_Cabal(2,0,0)
, hsSourceDirs
#endif
, libBuildInfo
, otherModules
, testBuildInfo
Expand All @@ -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
)
Expand All @@ -78,7 +78,6 @@ import Distribution.Simple
import Distribution.Verbosity (Verbosity)
import System.FilePath
( (</>)
, (<.>)
, equalFilePath
, isRelative
, makeRelative
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion proto-lens-tutorial/stack.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
resolver: lts-11.7
resolver: lts-12.7
packages:
- person
- coffee-order
Expand Down
2 changes: 1 addition & 1 deletion stack-bootstrap.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 651f58f

Please sign in to comment.