diff --git a/.gitignore b/.gitignore index a6c0e8a..03c8522 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,4 @@ cabal.project.local codex.tags _Dangerfile.tmp hscope.out +TAGS \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index e7b1da1..7ec9289 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,8 +13,7 @@ addons: # The different configurations we want to test. You could also do things like # change flags or use --stack-yaml to point to a different file. env: -- ARGS="--resolver=lts-8" -- ARGS="--resolver=lts-9" +- ARGS="--resolver=lts-11.13" before_install: # Update ruby diff --git a/Rome.cabal b/Rome.cabal index 699dd37..b7948a6 100644 --- a/Rome.cabal +++ b/Rome.cabal @@ -1,5 +1,5 @@ name: Rome -version: 0.15.0.43 +version: 0.16.0.45 synopsis: An S3 cache for Carthage description: Please see README.md homepage: https://github.com/blender/Rome @@ -11,7 +11,7 @@ copyright: 2016, 2017, 2018 Tommaso Piazza category: Utility build-type: Simple -- extra-source-files: -cabal-version: >=1.10 +cabal-version: >=1.24 library hs-source-dirs: src @@ -39,8 +39,8 @@ library build-depends: base >= 4.7 && < 5 - , amazonka >= 1.4 - , amazonka-s3 >= 1.4 + , amazonka >= 1.6 + , amazonka-s3 >= 1.6 , exceptions >= 0.8 , lens >= 4.13 , parsec >= 3.1.10 diff --git a/app/Main.hs b/app/Main.hs index d7044b4..962fc8e 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -10,7 +10,7 @@ import System.Exit romeVersion :: RomeVersion -romeVersion = (0, 15, 0, 43) +romeVersion = (0, 16, 0, 45) diff --git a/src/Caches/Local/Downloading.hs b/src/Caches/Local/Downloading.hs index 3903114..79e037c 100644 --- a/src/Caches/Local/Downloading.hs +++ b/src/Caches/Local/Downloading.hs @@ -6,7 +6,7 @@ import Control.Monad.Except import Control.Monad.Trans.Resource (runResourceT) import qualified Data.ByteString.Lazy as LBS import Data.Carthage.TargetPlatform -import qualified Data.Conduit as C (($$)) +import qualified Data.Conduit as C (runConduit, (.|)) import qualified Data.Conduit.Binary as C (sinkLbs, sourceFile) import Data.Romefile import System.Directory @@ -37,7 +37,7 @@ getFrameworkFromLocalCache lCacheDir platform = do frameworkExistsInLocalCache <- liftIO . doesFileExist $ frameworkLocalCachePath prefix if frameworkExistsInLocalCache - then liftIO . runResourceT $ C.sourceFile (frameworkLocalCachePath prefix) C.$$ C.sinkLbs + then liftIO . runResourceT . C.runConduit $ C.sourceFile (frameworkLocalCachePath prefix) C..| C.sinkLbs else throwError $ "Error: could not find " <> fwn <> " in local cache at : " <> frameworkLocalCachePath prefix where frameworkLocalCachePath cPrefix = lCacheDir cPrefix remoteFrameworkUploadPath @@ -57,7 +57,7 @@ getVersionFileFromLocalCache lCacheDir versionFileExistsInLocalCache <- liftIO . doesFileExist $ versionFileLocalCachePath if versionFileExistsInLocalCache - then liftIO . runResourceT $ C.sourceFile versionFileLocalCachePath C.$$ C.sinkLbs + then liftIO . runResourceT . C.runConduit $ C.sourceFile versionFileLocalCachePath C..| C.sinkLbs else throwError $ "Error: could not find " <> versionFileName <> " in local cache at : " <> versionFileLocalCachePath where versionFileName = versionFileNameForGitRepoName $ fst gitRepoNameAndVersion @@ -84,7 +84,7 @@ getBcsymbolmapFromLocalCache lCacheDir let finalBcsymbolmapLocalPath = bcsymbolmapLocalCachePath prefix bcSymbolmapExistsInLocalCache <- liftIO . doesFileExist $ finalBcsymbolmapLocalPath if bcSymbolmapExistsInLocalCache - then liftIO . runResourceT $ C.sourceFile finalBcsymbolmapLocalPath C.$$ C.sinkLbs + then liftIO . runResourceT . C.runConduit $ C.sourceFile finalBcsymbolmapLocalPath C..| C.sinkLbs else throwError $ "Error: could not find " <> bcsymbolmapName <> " in local cache at : " <> finalBcsymbolmapLocalPath where remoteBcsymbolmapUploadPath = remoteBcsymbolmapPath dwarfUUID platform reverseRomeMap f version @@ -109,7 +109,7 @@ getDSYMFromLocalCache lCacheDir let finalDSYMLocalPath = dSYMLocalCachePath prefix dSYMExistsInLocalCache <- liftIO . doesFileExist $ finalDSYMLocalPath if dSYMExistsInLocalCache - then liftIO . runResourceT $ C.sourceFile finalDSYMLocalPath C.$$ C.sinkLbs + then liftIO . runResourceT . C.runConduit $ C.sourceFile finalDSYMLocalPath C..| C.sinkLbs else throwError $ "Error: could not find " <> dSYMName <> " in local cache at : " <> finalDSYMLocalPath where dSYMLocalCachePath cPrefix = lCacheDir cPrefix remotedSYMUploadPath @@ -295,7 +295,7 @@ getAndSaveVersionFileFromLocalCache lCacheDir gitRepoNameAndVersion = do let sayFunc = if verbose then sayLnWithTime else sayLn versionFileBinary <- getVersionFileFromLocalCache lCacheDir cachePrefix gitRepoNameAndVersion sayFunc $ "Found " <> versionFileName <> " in local cache at: " <> finalVersionFileLocalCachePath - saveBinaryToFile versionFileBinary versionFileLocalPath + liftIO $ saveBinaryToFile versionFileBinary versionFileLocalPath sayFunc $ "Copied " <> versionFileName <> " to: " <> versionFileLocalPath where diff --git a/src/Caches/S3/Downloading.hs b/src/Caches/S3/Downloading.hs index 2fa3820..2079dcf 100644 --- a/src/Caches/S3/Downloading.hs +++ b/src/Caches/S3/Downloading.hs @@ -2,15 +2,16 @@ module Caches.S3.Downloading where import Caches.Common import Configuration (carthageBuildDirectoryForPlatform) +import Control.Exception (try) import Control.Lens (view) import Control.Monad import Control.Monad.Except -import Control.Monad.Reader (ReaderT, ask, withReaderT) +import Control.Monad.Reader (runReaderT, ReaderT, ask, withReaderT) import qualified Data.ByteString as BS import qualified Data.ByteString.Lazy as LBS import Data.Carthage.TargetPlatform -import qualified Data.Conduit as C (Conduit, await, yield, - (=$=)) +import qualified Data.Conduit as C (ConduitT, await, yield, + (.|)) import qualified Data.Conduit.Binary as C (sinkLbs) import Data.Either (lefts) import Data.Maybe (fromMaybe) @@ -201,10 +202,11 @@ getArtifactFromS3 :: S3.BucketName -- ^ The cache definition -> ExceptT String (ReaderT (AWS.Env, Bool) IO) LBS.ByteString getArtifactFromS3 s3BucketName remotePath - name = do - eitherArtifact <- AWS.trying AWS._Error $ downloadBinary s3BucketName remotePath name + artifactName = do + env <- ask + eitherArtifact <- liftIO $ try $ runReaderT (downloadBinary s3BucketName remotePath artifactName) env case eitherArtifact of - Left e -> throwError $ "Error: could not download " <> name <> " : " <> awsErrorToString e + Left e -> throwError $ "Error: could not download " <> artifactName <> " : " <> awsErrorToString e Right artifactBinary -> return artifactBinary @@ -213,7 +215,7 @@ getArtifactFromS3 s3BucketName downloadBinary :: S3.BucketName -> FilePath -> FilePath - -> ExceptT String (ReaderT (AWS.Env, Bool) IO) LBS.ByteString + -> ReaderT (AWS.Env, Bool) IO LBS.ByteString downloadBinary s3BucketName objectRemotePath objectName = do (env, verbose) <- ask AWS.runResourceT . AWS.runAWS env $ do @@ -228,9 +230,9 @@ downloadBinary s3BucketName objectRemotePath objectName = do where objectKey = S3.ObjectKey . T.pack $ objectRemotePath - sink verbose totalLength = if verbose then printProgress objectName totalLength C.=$= C.sinkLbs else C.sinkLbs + sink verbose totalLength = if verbose then printProgress objectName totalLength C..| C.sinkLbs else C.sinkLbs - printProgress :: MonadIO m => String -> Int -> C.Conduit BS.ByteString m BS.ByteString + printProgress :: MonadIO m => String -> Int -> C.ConduitT BS.ByteString BS.ByteString m () printProgress objName totalLength = loop totalLength 0 0 where loop t consumedLen lastLen = C.await >>= maybe (return ()) (\bs -> do diff --git a/src/Lib.hs b/src/Lib.hs index e1e827d..40ae2c2 100644 --- a/src/Lib.hs +++ b/src/Lib.hs @@ -582,7 +582,7 @@ downloadVersionFileFromCaches s3BucketName (Just lCacheDir) gitRepoNameAndVersio e2 <- runExceptT $ do versionFileBinary <- getVersionFileFromS3 s3BucketName gitRepoNameAndVersion saveBinaryToLocalCache lCacheDir versionFileBinary (prefix versionFileRemotePath) versionFileName verbose - saveBinaryToFile versionFileBinary versionFileLocalPath + liftIO $ saveBinaryToFile versionFileBinary versionFileLocalPath sayFunc $ "Copied " <> versionFileName <> " to: " <> versionFileLocalPath whenLeft sayFunc e2 ) (env, cachePrefix, verbose) @@ -600,7 +600,7 @@ downloadVersionFileFromCaches s3BucketName Nothing gitRepoNameAndVersion = do eitherError <- liftIO $ runReaderT (runExceptT $ do versionFileBinary <- getVersionFileFromS3 s3BucketName gitRepoNameAndVersion - saveBinaryToFile versionFileBinary versionFileLocalPath + liftIO $ saveBinaryToFile versionFileBinary versionFileLocalPath sayFunc $ "Copied " <> versionFileName <> " to: " <> versionFileLocalPath ) (env, cachePrefix, verbose) diff --git a/src/Utils.hs b/src/Utils.hs index 29e19ce..df5a615 100644 --- a/src/Utils.hs +++ b/src/Utils.hs @@ -11,7 +11,7 @@ import Control.Arrow (left) import Control.Exception as E (try) import Control.Monad.Catch import Control.Monad.Except -import Control.Monad.Trans.Resource (runResourceT) +import Control.Monad.Trans.Resource (runResourceT, MonadUnliftIO) import Data.Aeson import Data.Aeson.Types import qualified Data.ByteString.Char8 as BS @@ -19,7 +19,7 @@ import qualified Data.ByteString.Lazy as LBS import Data.Carthage.Cartfile import Data.Carthage.TargetPlatform import Data.Char (isNumber) -import qualified Data.Conduit as C (($$)) +import qualified Data.Conduit as C (runConduit, (.|)) import qualified Data.Conduit.Binary as C (sinkFile, sourceLbs) import Data.Function (on) import Data.List @@ -510,13 +510,13 @@ unzipBinary objectBinary objectName objectZipName verbose = do -- | Saves a ByteString to file -saveBinaryToFile :: MonadIO m +saveBinaryToFile :: (MonadUnliftIO m, MonadIO m) => LBS.ByteString -- ^ The `ByteString` to save. -> FilePath -- ^ The destination path. -> m () saveBinaryToFile binaryArtifact destinationPath = do liftIO $ createDirectoryIfMissing True (dropFileName destinationPath) - liftIO . runResourceT $ C.sourceLbs binaryArtifact C.$$ C.sinkFile destinationPath + runResourceT $ C.runConduit $ C.sourceLbs binaryArtifact C..| C.sinkFile destinationPath diff --git a/stack.yaml b/stack.yaml index 7ff0e7f..079ef1c 100644 --- a/stack.yaml +++ b/stack.yaml @@ -15,7 +15,7 @@ # resolver: # name: custom-snapshot # location: "./custom-snapshot.yaml" -resolver: lts-9.0 +resolver: lts-11.13 # User packages to be built. # Various formats can be used as shown in the example below. @@ -37,10 +37,18 @@ resolver: lts-9.0 # will not be run. This is useful for tweaking upstream packages. packages: - '.' + - location: + git: https://github.com/brendanhay/amazonka + commit: c9d8a62118b2269fb54b1e89c4e92106e8243050 + subdirs: + - amazonka + - core + - amazonka-s3 + extra-dep: true # Dependency packages to be pulled from upstream that are not in the resolver # (e.g., acme-missiles-0.3) extra-deps: - - zip-archive-0.3.2.1 + - url-2.1.3 # Override default flag values for local packages and extra-deps flags: {}