Skip to content

Commit

Permalink
Allow stand alone local cache (#63)
Browse files Browse the repository at this point in the history
* Allow stand alone local cache, upload implemented

* Implement dSYM and Framework download from remote and local cache

* Implement version file download from remote and local cache

* Fix download from local caches, implement local cache listing

* Reducing code duplication in listArtifacts

* Reduce code duplication in remote download functions

* Fix dSYM name print when not found in local cache

* Add documentation to functions

* Delete Framework and dSYM before unzipping cached version

* Version bump

* Bump Version

* Update README.md

* Update .gititnore to ignore codex.tags
  • Loading branch information
tmspzz authored May 10, 2017
1 parent b41cf68 commit 8e67a7d
Show file tree
Hide file tree
Showing 7 changed files with 1,090 additions and 299 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ cabal.sandbox.config
*.eventlog
.stack-work/
cabal.project.local
codex.tags
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Rome

Rome is a tool that allows developers on Apple platforms to use Amazon's S3 as a
Rome is a tool that allows developers on Apple platforms to use Amazon's S3 or a local folder as a
shared cache for frameworks built with [Carthage](https://github.com/Carthage/Carthage).

## Get Rome
Expand All @@ -15,8 +15,8 @@ and I will gladly add you to the user list.

## Use Rome with fastlane

You can integrate rome into your [fastlane](https://github.com/fastlane/fastlane) automation with the
[fastlane plugin for rome](https://github.com/netbe/fastlane-plugin-rome).
You can integrate Rome into your [fastlane](https://github.com/fastlane/fastlane) automation with the
[fastlane plugin for Rome](https://github.com/netbe/fastlane-plugin-rome).

## The problem

Expand Down Expand Up @@ -134,8 +134,8 @@ A Romefile looks like this:
The Romefile is in the [INI format](https://en.wikipedia.org/wiki/INI_file)

#### Cache section
This section contains the name of:
- the S3 bucket you want Rome to use to upload/download. The key `S3-Bucket` is __required__.
This section must contain __at least one__ between:
- the name of the S3 Bucket to upload/download to/from. The key `S3-Bucket` is __optional__ since Rome `0.11.0.x`.
- the path to local directory to use as an additional cache. The key `local` is __optional__.

#### RepositoryMap
Expand Down Expand Up @@ -347,8 +347,8 @@ $ rome list --missing --platform ios | awk '{print $1}' | xargs carthage build -
```

Note: `list` __completely ignores dSYMs and Carthage version files__. If a dSYM
or [Carthage version file](https://github.com/Carthage/Carthage/blob/master/Documentation/VersionFile.md)
if present) is missing, the corresponding framework is still reported as present.
or a [Carthage version file](https://github.com/Carthage/Carthage/blob/master/Documentation/VersionFile.md)
is missing, __the corresponding framework is still reported as present__.

## Troubleshooting

Expand All @@ -375,3 +375,4 @@ import MapKit
Rome is released under MIT License

Logo courtesy of [TeddyBear[Picnic]](http://www.freedigitalphotos.net/images/view_photog.php?photogid=3407) at FreeDigitalPhotos.net

5 changes: 3 additions & 2 deletions Rome.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Rome
version: 0.10.2.24
version: 0.11.0.27
synopsis: An S3 cache for Carthage
description: Please see README.md
homepage: https://github.com/blender/Rome
Expand Down Expand Up @@ -32,6 +32,7 @@ library
build-depends: base >= 4.7 && < 5
, amazonka >= 1.4.1
, amazonka-s3 >= 1.4.1
, exceptions >= 0.8
, lens >= 4.13
, parsec >= 3.1.10
, mtl >= 2.2.1
Expand All @@ -53,6 +54,7 @@ library
, resourcet >= 1.1
, optparse-applicative >= 0.12
, aeson >= 0.11
, lens >= 4.13

ghc-options: -Wall -fno-warn-unused-do-bind

Expand All @@ -66,7 +68,6 @@ executable rome
ghc-options: -threaded -rtsopts -with-rtsopts=-N
build-depends: base >= 4.7 && < 5
, Rome
, amazonka >= 1.4.1
, mtl >= 2.2.1
, optparse-applicative >= 0.12

Expand Down
13 changes: 5 additions & 8 deletions app/Main.hs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
module Main where

import CommandParsers (parseRomeOptions)
import CommandParsers (parseRomeOptions)
import Control.Monad.Except
import Lib
import Network.AWS as AWS
import Options.Applicative as Opts
import System.Exit



romeVersion :: String
romeVersion = "0.10.2.24"
romeVersion = "0.11.0.27"



Expand All @@ -21,10 +21,7 @@ main = do
case cmd of
Nothing -> putStrLn $ romeVersion ++ " - Romam uno die non fuisse conditam."
Just romeOptions -> do
p <- runExceptT $ do
r <- discoverRegion
env <- AWS.newEnv r AWS.Discover
runRomeWithOptions env romeOptions
p <- runExceptT $ runRomeWithOptions romeOptions
case p of
Right _ -> return ()
Left e -> putStrLn e
Left e -> die e
49 changes: 38 additions & 11 deletions src/Data/Romefile.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,16 @@ module Data.Romefile
, GitRepoName (..)
, RomeFileParseResult (..)
, RomeCacheInfo (..)
, cacheInfo
, repositoryMapEntries
, ignoreMapEntries
, bucket
, localCacheDir
)
where

import Control.Monad.Except
import Control.Lens
import Data.HashMap.Strict as M
import Data.Ini as INI
import Data.Ini.Utils as INI
Expand All @@ -30,25 +36,46 @@ import System.Path.NameManip


newtype FrameworkName = FrameworkName { unFrameworkName :: String }
deriving (Eq, Show, Ord)
deriving (Eq, Show, Ord)

newtype GitRepoName = GitRepoName { unGitRepoName :: String }
deriving (Eq, Show, Ord)
deriving (Eq, Show, Ord)

data RomefileEntry = RomefileEntry { gitRepositoryName :: GitRepoName
, frameworkCommonNames :: [FrameworkName]
}
deriving (Show, Eq)

data RomeFileParseResult = RomeFileParseResult { cacheInfo :: RomeCacheInfo
, repositoryMapEntries :: [RomefileEntry]
, ignoreMapEntries :: [RomefileEntry]
data RomeFileParseResult = RomeFileParseResult { _cacheInfo :: RomeCacheInfo
, _repositoryMapEntries :: [RomefileEntry]
, _ignoreMapEntries :: [RomefileEntry]
}

data RomeCacheInfo = RomeCacheInfo { _bucket :: Text
cacheInfo :: Lens' RomeFileParseResult RomeCacheInfo
cacheInfo = lens _cacheInfo (\parseResult n -> parseResult { _cacheInfo = n })

repositoryMapEntries :: Lens' RomeFileParseResult [RomefileEntry]
repositoryMapEntries = lens _repositoryMapEntries (\parseResult n -> parseResult { _repositoryMapEntries = n })

ignoreMapEntries :: Lens' RomeFileParseResult [RomefileEntry]
ignoreMapEntries = lens _ignoreMapEntries (\parseResult n -> parseResult { _ignoreMapEntries = n })





data RomeCacheInfo = RomeCacheInfo { _bucket :: Maybe Text
, _localCacheDir :: Maybe FilePath
}

bucket :: Lens' RomeCacheInfo (Maybe Text)
bucket = lens _bucket (\cInfo n -> cInfo { _bucket = n })

localCacheDir :: Lens' RomeCacheInfo (Maybe FilePath)
localCacheDir = lens _localCacheDir (\cInfo n -> cInfo { _localCacheDir = n })



-- |The name of the Romefile
romefile :: String
romefile = "Romefile"
Expand Down Expand Up @@ -83,16 +110,16 @@ parseRomefile f = do
_bucket <- withExceptT toErrorMessage $ getBucket ini
maybeCacheDirAsText <- withExceptT toErrorMessage $ getLocalCacheDir ini
_localCacheDir <- liftIO $ mapM absolutize (unpack <$> maybeCacheDirAsText)
repositoryMapEntries <- getRepostiryMapEntries ini
ignoreMapEntries <- getIgnoreMapEntries ini
let cacheInfo = RomeCacheInfo {..}
_repositoryMapEntries <- getRepostiryMapEntries ini
_ignoreMapEntries <- getIgnoreMapEntries ini
let _cacheInfo = RomeCacheInfo {..}
return RomeFileParseResult { .. }
where
toErrorMessage :: Text -> String
toErrorMessage e = "Error while parsing " <> f <> ": " <> unpack e

getBucket :: MonadIO m => Ini -> ExceptT Text m Text
getBucket ini = requireKey s3BucketKey `inRequiredSection` cacheSectionDelimiter `fromIni''` ini
getBucket :: MonadIO m => Ini -> ExceptT Text m (Maybe Text)
getBucket ini = optionalKey s3BucketKey `inRequiredSection` cacheSectionDelimiter `fromIni''` ini

getLocalCacheDir :: MonadIO m => Ini -> ExceptT Text m (Maybe Text)
getLocalCacheDir ini = optionalKey localCacheDirKey `inRequiredSection` cacheSectionDelimiter `fromIni''` ini
Expand Down
Loading

0 comments on commit 8e67a7d

Please sign in to comment.