diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3abd6445..d6fba0c5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -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 }} @@ -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 diff --git a/src/App/Commands/Options/Types.hs b/src/App/Commands/Options/Types.hs index 8a650378..7458d61d 100644 --- a/src/App/Commands/Options/Types.hs +++ b/src/App/Commands/Options/Types.hs @@ -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 @@ -21,6 +22,7 @@ data SyncToArchiveOptions = SyncToArchiveOptions data SyncFromArchiveOptions = SyncFromArchiveOptions { region :: Region , archiveUris :: [Location] + , buildPath :: FilePath , storePath :: FilePath , storePathHash :: Maybe String , threads :: Int diff --git a/src/App/Commands/SyncFromArchive.hs b/src/App/Commands/SyncFromArchive.hs index 1f250b2c..53402e8d 100644 --- a/src/App/Commands/SyncFromArchive.hs +++ b/src/App/Commands/SyncFromArchive.hs @@ -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) @@ -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 @@ -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 @@ -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 diff --git a/src/App/Commands/SyncToArchive.hs b/src/App/Commands/SyncToArchive.hs index 3e5def21..00bd3e6a 100644 --- a/src/App/Commands/SyncToArchive.hs +++ b/src/App/Commands/SyncToArchive.hs @@ -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) @@ -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 @@ -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 @@ -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 diff --git a/src/App/Static.hs b/src/App/Static.hs index 201d7429..35f936f3 100644 --- a/src/App/Static.hs +++ b/src/App/Static.hs @@ -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" diff --git a/src/HaskellWorks/CabalCache/Core.hs b/src/HaskellWorks/CabalCache/Core.hs index db351bfd..6cc79a45 100644 --- a/src/HaskellWorks/CabalCache/Core.hs +++ b/src/HaskellWorks/CabalCache/Core.hs @@ -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