git.iko.soy/typeable/minio-hs
on master help sign in
Build with GHC 8.8 (#137)

* Fix to build with GHC 8.8 and fix error handling bug To work with the addition of MonadFail constraint to parseTimeM in the time library, the underlying monad was changed from Either to Maybe as it has a MonadFail instance. * Update build to run tests against local minio server

commit410d342cd589829c7a428532e7bbf7de419af813 authorAditya Manthramurthy <donatello@users.noreply.github.com> dateMon 28 Oct 2019, 15:40 (7 years ago) parent1e6579b
6 files changed+30−16
.travis.yml+13−3 src/Network/Minio/Data.hs+2−3 src/Network/Minio/Utils.hs−1 src/Network/Minio/XmlParser.hs+4−4 stack.yaml+1−1 test/LiveServer.hs+10−4
.travis.yml+13−3
@@ -4,7 +4,7 @@ language: haskell
44git:
55 depth: 5
66
7−cabal: "2.4"
7+cabal: "3.0"
88
99cache:
1010 directories:
@@ -19,11 +19,21 @@ matrix:
1919 - ghc: 8.2.2
2020 - ghc: 8.4.4
2121 - ghc: 8.6.5
22+ - ghc: 8.8.1
2223
2324 # Stack
2425 - ghc: 8.6.5
2526 env: STACK_YAML="$TRAVIS_BUILD_DIR/stack.yaml"
2627
28+before_install:
29+ - sudo apt-get install devscripts
30+ - mkdir /tmp/minio /tmp/certs
31+ - (cd /tmp/minio; wget https://dl.min.io/server/minio/release/linux-amd64/minio; chmod +x ./minio)
32+ - (cd /tmp/certs; openssl req -newkey rsa:2048 -nodes -keyout private.key -x509 -days 36500 -out public.crt -subj "/C=US/ST=NRW/L=Earth/O=CompanyName/OU=IT/CN=localhost/emailAddress=email@example.com")
33+ - sudo cp /tmp/certs/public.crt /usr/local/share/ca-certificates/
34+ - sudo update-ca-certificates
35+ - MINIO_ACCESS_KEY=minio MINIO_SECRET_KEY=minio123 /tmp/minio/minio server --quiet --certs-dir /tmp/certs data 2>&1 > minio.log &
36+
2737install:
2838 - |
2939 if [ -z "$STACK_YAML" ]; then
@@ -43,9 +53,9 @@ install:
4353script:
4454 - |
4555 if [ -z "$STACK_YAML" ]; then
46− cabal new-test --enable-tests
56+ MINIO_LOCAL=1 MINIO_SECURE=1 cabal new-test --enable-tests
4757 else
48− stack test --system-ghc
58+ MINIO_LOCAL=1 MINIO_SECURE=1 stack test --system-ghc
4959 fi
5060
5161notifications:
src/Network/Minio/Data.hs+2−3
@@ -21,10 +21,9 @@
2121module Network.Minio.Data where
2222
2323import qualified Conduit as C
24−import Control.Concurrent.MVar (MVar)
2524import qualified Control.Concurrent.MVar as M
26−import Control.Monad.IO.Unlift (MonadUnliftIO, UnliftIO (..),
27− askUnliftIO, withUnliftIO)
25+import Control.Monad.IO.Unlift (UnliftIO (..), askUnliftIO,
26+ withUnliftIO)
2827import Control.Monad.Trans.Resource
2928import qualified Data.Aeson as A
3029import qualified Data.ByteArray as BA
src/Network/Minio/Utils.hs−1
@@ -26,7 +26,6 @@ import qualified Data.Conduit.Binary as CB
2626import qualified Data.HashMap.Strict as H
2727import qualified Data.List as List
2828import qualified Data.Text as T
29−import Data.Text.Encoding.Error (lenientDecode)
3029import Data.Text.Read (decimal)
3130import Data.Time (defaultTimeLocale, parseTimeM,
3231 rfc822DateFormat)
src/Network/Minio/XmlParser.hs+4−4
@@ -56,10 +56,10 @@ uncurry6 :: (a -> b -> c -> d -> e -> f -> g) -> (a, b, c, d, e, f) -> g
5656uncurry6 f (a, b, c, d, e, g) = f a b c d e g
5757
5858-- | Parse time strings from XML
59−parseS3XMLTime :: (MonadIO m) => Text -> m UTCTime
60−parseS3XMLTime = either (throwIO . MErrVXmlParse) return
61− . parseTimeM True defaultTimeLocale s3TimeFormat
62− . T.unpack
59+parseS3XMLTime :: MonadIO m => Text -> m UTCTime
60+parseS3XMLTime t =
61+ maybe (throwIO $ MErrVXmlParse $ "timestamp parse failure: " <> t) return $
62+ parseTimeM True defaultTimeLocale s3TimeFormat $ T.unpack t
6363
6464parseDecimal :: (MonadIO m, Integral a) => Text -> m a
6565parseDecimal numStr = either (throwIO . MErrVXmlParse . show) return $
stack.yaml+1−1
@@ -15,7 +15,7 @@
1515# resolver:
1616# name: custom-snapshot
1717# location: "./custom-snapshot.yaml"
18−resolver: lts-13.1
18+resolver: lts-14.6
1919
2020# User packages to be built.
2121# Various formats can be used as shown in the example below.
test/LiveServer.hs+10−4
@@ -77,6 +77,15 @@ mkRandFile size = do
7777funTestBucketPrefix :: Text
7878funTestBucketPrefix = "miniohstest-"
7979
80+loadTestServer :: IO ConnectInfo
81+loadTestServer = do
82+ val <- lookupEnv "MINIO_LOCAL"
83+ isSecure <- lookupEnv "MINIO_SECURE"
84+ return $ case (val, isSecure) of
85+ (Just _, Just _) -> setCreds (Credentials "minio" "minio123") "https://localhost:9000"
86+ (Just _, Nothing) -> setCreds (Credentials "minio" "minio123") "http://localhost:9000"
87+ (Nothing, _) -> minioPlayCI
88+
8089funTestWithBucket :: TestName
8190 -> (([Char] -> Minio ()) -> Bucket -> Minio ()) -> TestTree
8291funTestWithBucket t minioTest = testCaseSteps t $ \step -> do
@@ -84,10 +93,7 @@ funTestWithBucket t minioTest = testCaseSteps t $ \step -> do
8493 bktSuffix <- liftIO $ generate $ Q.vectorOf 10 (Q.choose ('a', 'z'))
8594 let b = T.concat [funTestBucketPrefix, T.pack bktSuffix]
8695 liftStep = liftIO . step
87− connInfo <- ( bool minioPlayCI
88− ( setCreds (Credentials "minio" "minio123") "http://localhost:9000" )
89− . isJust
90− ) <$> lookupEnv "MINIO_LOCAL"
96+ connInfo <- loadTestServer
9197 ret <- runMinio connInfo $ do
9298 liftStep $ "Creating bucket for test - " ++ t
9399 foundBucket <- bucketExists b