Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --build-path #137

Merged
merged 1 commit into from
Sep 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,7 @@ jobs:
run: echo '::set-env name=EXE_EXT::.exe'

- name: Configure project
run: cabal configure --enable-tests --enable-benchmarks

- name: Variables
run: env

- name: Temp directory
env:
CLI_TEMP: ${{runner.temp}}
run: echo "$CLI_TEMP"
run: cabal configure --enable-tests --enable-benchmarks --write-ghc-environment-files=ghc8.4.4+

- name: Restore cabal cache
uses: haskell-works/cabal-cache-action@v1
Expand All @@ -66,16 +58,23 @@ jobs:
sync-from-archive \
--threads "$BINARY_CACHE_THREADS" \
--archive-uri "$BINARY_CACHE_URI" \
--region "$BINARY_CACHE_REGION"
--region "$BINARY_CACHE_REGION" \
--store-path "${{ steps.setup-haskell.outputs.cabal-store }}"

- name: Build
# Try building it twice in case of flakey builds on Windows
run: |
cabal build --enable-tests --enable-benchmarks --write-ghc-environment-files=ghc8.4.4+ || \
cabal build --enable-tests --enable-benchmarks --write-ghc-environment-files=ghc8.4.4+ -j1
cabal build all --enable-tests --enable-benchmarks --write-ghc-environment-files=ghc8.4.4+ || \
cabal build all --enable-tests --enable-benchmarks --write-ghc-environment-files=ghc8.4.4+ -j1

- name: Test
# Try building it twice in case of flakey builds on Windows
run: |
cabal test all --enable-tests --enable-benchmarks --write-ghc-environment-files=ghc8.4.4+

- name: Save cabal cache
uses: haskell-works/cabal-cache-action@v1
if: ${{ always() }}
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
Expand All @@ -87,7 +86,8 @@ jobs:
sync-to-archive \
--threads "$BINARY_CACHE_THREADS" \
--archive-uri "$BINARY_CACHE_URI" \
--region "$BINARY_CACHE_REGION"
--region "$BINARY_CACHE_REGION" \
--store-path "${{ steps.setup-haskell.outputs.cabal-store }}"

- name: Compress Binary
id: compress_binary
Expand Down
2 changes: 2 additions & 0 deletions src/App/Commands/Options/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import qualified Antiope.Env as AWS
data SyncToArchiveOptions = SyncToArchiveOptions
{ region :: Region
, archiveUri :: Location
, buildPath :: FilePath
, storePath :: FilePath
, storePathHash :: Maybe String
, threads :: Int
Expand All @@ -21,6 +22,7 @@ data SyncToArchiveOptions = SyncToArchiveOptions
data SyncFromArchiveOptions = SyncFromArchiveOptions
{ region :: Region
, archiveUris :: [Location]
, buildPath :: FilePath
, storePath :: FilePath
, storePathHash :: Maybe String
, threads :: Int
Expand Down
14 changes: 10 additions & 4 deletions src/App/Commands/SyncFromArchive.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import Antiope.Env (mkEnv)
import Antiope.Options.Applicative
import App.Commands.Options.Parser (text)
import App.Commands.Options.Types (SyncFromArchiveOptions (SyncFromArchiveOptions))
import App.Static (cabalDirectory)
import Control.Applicative
import Control.Lens hiding ((<.>))
import Control.Monad (unless, void, when)
Expand All @@ -34,6 +33,7 @@ import Options.Applicative hiding (columns)
import System.Directory (createDirectoryIfMissing, doesDirectoryExist)

import qualified App.Commands.Options.Types as Z
import qualified App.Static as AS
import qualified Control.Concurrent.STM as STM
import qualified Data.ByteString.Char8 as C8
import qualified Data.ByteString.Lazy as LBS
Expand Down Expand Up @@ -81,7 +81,7 @@ runSyncFromArchive opts = do
CIO.putStrLn $ "Threads: " <> tshow threads
CIO.putStrLn $ "AWS Log level: " <> tshow awsLogLevel

mbPlan <- Z.loadPlan
mbPlan <- Z.loadPlan $ opts ^. the @"buildPath"

case mbPlan of
Right planJson -> do
Expand Down Expand Up @@ -213,11 +213,17 @@ optsSyncFromArchive = SyncFromArchiveOptions
<> metavar "S3_URI"
)
)
<*> strOption
( long "build-path"
<> help ("Path to cabal build directory. Defaults to " <> show AS.buildPath)
<> metavar "DIRECTORY"
<> value AS.buildPath
)
<*> strOption
( long "store-path"
<> help "Path to cabal store"
<> help ("Path to cabal store. Defaults to " <> show AS.cabalDirectory)
<> metavar "DIRECTORY"
<> value (cabalDirectory </> "store")
<> value (AS.cabalDirectory </> "store")
)
<*> optional
( strOption
Expand Down
15 changes: 11 additions & 4 deletions src/App/Commands/SyncToArchive.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import Antiope.Env (mkEnv)
import Antiope.Options.Applicative
import App.Commands.Options.Parser (text)
import App.Commands.Options.Types (SyncToArchiveOptions (SyncToArchiveOptions))
import App.Static (cabalDirectory)
import Control.Applicative
import Control.Lens hiding ((<.>))
import Control.Monad (filterM, unless, when)
Expand All @@ -33,6 +32,7 @@ import Options.Applicative hiding (columns)
import System.Directory (doesDirectoryExist)

import qualified App.Commands.Options.Types as Z
import qualified App.Static as AS
import qualified Control.Concurrent.STM as STM
import qualified Data.ByteString.Lazy as LBS
import qualified Data.ByteString.Lazy.Char8 as LC8
Expand Down Expand Up @@ -76,7 +76,8 @@ runSyncToArchive opts = do

tEarlyExit <- STM.newTVarIO False

mbPlan <- Z.loadPlan
mbPlan <- Z.loadPlan $ opts ^. the @"buildPath"

case mbPlan of
Right planJson -> do
compilerContextResult <- runExceptT $ Z.mkCompilerContext planJson
Expand Down Expand Up @@ -172,13 +173,19 @@ optsSyncToArchive = SyncToArchiveOptions
( long "archive-uri"
<> help "Archive URI to sync to"
<> metavar "S3_URI"
<> value (Local $ cabalDirectory </> "archive")
<> value (Local $ AS.cabalDirectory </> "archive")
)
<*> strOption
( long "build-path"
<> help ("Path to cabal build directory. Defaults to " <> show AS.buildPath)
<> metavar "DIRECTORY"
<> value AS.buildPath
)
<*> strOption
( long "store-path"
<> help "Path to cabal store"
<> metavar "DIRECTORY"
<> value (cabalDirectory </> "store")
<> value (AS.cabalDirectory </> "store")
)
<*> optional
( strOption
Expand Down
3 changes: 3 additions & 0 deletions src/App/Static.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ import qualified App.Static.Windows as W

cabalDirectory :: FilePath
cabalDirectory = if S.isPosix then P.cabalDirectory else W.cabalDirectory

buildPath :: FilePath
buildPath = "dist-newstyle"
4 changes: 2 additions & 2 deletions src/HaskellWorks/CabalCache/Core.hs
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ getPackages basePath planJson = forM packages (mkPackageInfo basePath compilerId
packages :: [Z.Package]
packages = planJson ^. the @"installPlan"

loadPlan :: IO (Either AppError Z.PlanJson)
loadPlan = (first fromString . eitherDecode) <$> LBS.readFile ("dist-newstyle" </> "cache" </> "plan.json")
loadPlan :: FilePath -> IO (Either AppError Z.PlanJson)
loadPlan buildPath = (first fromString . eitherDecode) <$> LBS.readFile (buildPath </> "cache" </> "plan.json")

-------------------------------------------------------------------------------
mkPackageInfo :: FilePath -> Z.CompilerId -> Z.Package -> IO PackageInfo
Expand Down