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

Curator stackage build with stack #4582

Merged
merged 34 commits into from
Mar 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
b0ecdff
Use - instead of @ as the latter is a bad path character for Nix
qrilka Jan 31, 2019
a2f00a5
Using source hashmap with haddocks for doc roots
qrilka Dec 25, 2018
353dd32
hoogle command with proper options and enabled hadddocks for doc paths
qrilka Dec 26, 2018
b7bad04
Curator unpack and proper handling of expected test/haddock failures
qrilka Jan 3, 2019
ed5c0a9
Introduce test-suite-timeout parameter
qrilka Jan 9, 2019
960538f
Handle expected benchmark compilation failures
qrilka Jan 9, 2019
59acc7d
Forward hidden packages from constraints to Stackage stack.yaml
qrilka Jan 10, 2019
e1002a2
Fixes from hlint suggestions
qrilka Feb 5, 2019
5cf535b
Use 10 minute timeout for test suites in Stackage builds
qrilka Feb 5, 2019
6a6b3c8
Don't error out on missing latest revision while constructing a build…
qrilka Feb 6, 2019
b13486b
Disable all-in-one builds for curator packages with expected failures
qrilka Feb 8, 2019
36f99d9
Merge branch 'master' into curator-stackage-build-with-stack
qrilka Feb 8, 2019
abf530f
Test fixes
qrilka Feb 8, 2019
286a5f5
Give more details about timed out test suite
qrilka Feb 12, 2019
0a964c7
Proper log file handling on expected haddock failures
qrilka Feb 18, 2019
4c7cf82
Revert "Forward hidden packages from constraints to Stackage stack.yaml"
qrilka Feb 18, 2019
19ca481
Merge branch 'master' into curator-stackage-build-with-stack
qrilka Feb 18, 2019
1c01bb6
Fix building haddocks for packages with internal libraries
qrilka Feb 19, 2019
ec60c4a
Merge branch 'haddock-internal' into curator-stackage-build-with-stack
qrilka Feb 19, 2019
897e3e2
Remove superfluous 'otherwise'
qrilka Feb 20, 2019
5f3b449
Pass proper build haddocks flag
qrilka Feb 21, 2019
cd68816
More correct handlding of curator expectations
qrilka Feb 22, 2019
62d71bd
Removed InstalledCache as is should be guaranteed by implicit snapshots
qrilka Feb 22, 2019
2e075f4
Remove commented out parameter
qrilka Feb 25, 2019
c02a348
Proper all-in-one for expected test failures
qrilka Feb 25, 2019
e09f467
Better handling of test timeouts
qrilka Feb 25, 2019
455996d
Fix all-in-one for tasks with expected failures
qrilka Feb 25, 2019
b4d6ffd
Disable colored output when running Stackage builds
qrilka Feb 26, 2019
d1d9b5f
Extract smRelDir helper giving relative dir name for a source map
qrilka Feb 28, 2019
cc6acc9
Minor refactoring of hashSourceMapData
qrilka Feb 28, 2019
9f2ebc5
Add GHC options which are supposed to be applied to GHC boot libs
qrilka Feb 28, 2019
58c2cd7
Add source map hash into build cache path to allow proper switch
qrilka Feb 28, 2019
4b316b8
Mutable dependencies integration test
qrilka Feb 28, 2019
b6bb6b2
Hlint fixes
qrilka Feb 28, 2019
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
1 change: 0 additions & 1 deletion package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ library:
- Stack.Types.NamedComponent
- Stack.Types.Nix
- Stack.Types.Package
- Stack.Types.PackageDump
- Stack.Types.PackageName
- Stack.Types.Resolver
- Stack.Types.Runner
Expand Down
1 change: 1 addition & 0 deletions snapshot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ packages:
- unliftio-0.2.8.0@sha256:5a47f12ffcee837215c67b05abf35dffb792096564a6f81652d75a54668224cd,2250
- happy-1.19.9@sha256:f8c774230735a390c287b2980cfcd2703d24d8dde85a01ea721b7b4b4c82944f,4667
- fsnotify-0.3.0.1@rev:1
- process-1.6.3.0@sha256:fc77cfe75a9653b8c54ae455ead8c06cb8adc4d7a340984d84d8ca880b579919,2370 #because of https://github.com/haskell/process/pull/101

flags:
cabal-install:
Expand Down
11 changes: 1 addition & 10 deletions src/Stack/Build.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import Distribution.Version (mkVersion)
import Path (parent)
import Stack.Build.ConstructPlan
import Stack.Build.Execute
import Stack.Build.Haddock
import Stack.Build.Installed
import Stack.Build.Source
import Stack.Package
Expand Down Expand Up @@ -63,9 +62,6 @@ build msetLocalFiles mbuildLk = do
ghcVersion <- view $ actualCompilerVersionL.to getGhcVersion
fixCodePage mcp ghcVersion $ do
bopts <- view buildOptsL
let profiling = boptsLibProfile bopts || boptsExeProfile bopts
let symbols = not (boptsLibStrip bopts || boptsExeStrip bopts)

sourceMap <- view $ envConfigL.to envConfigSourceMap
locals <- projectLocalPackages
depsLocals <- localDependencies
Expand All @@ -82,12 +78,7 @@ build msetLocalFiles mbuildLk = do

installMap <- toInstallMap sourceMap
(installedMap, globalDumpPkgs, snapshotDumpPkgs, localDumpPkgs) <-
getInstalled
GetInstalledOpts
{ getInstalledProfiling = profiling
, getInstalledHaddock = shouldHaddockDeps bopts
, getInstalledSymbols = symbols }
installMap
getInstalled installMap

boptsCli <- view $ envConfigL.to envConfigBuildOptsCLI
baseConfigOpts <- mkBaseConfigOpts boptsCli
Expand Down
5 changes: 4 additions & 1 deletion src/Stack/Build/Cache.hs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import Stack.Types.Compiler
import Stack.Types.Config
import Stack.Types.GhcPkgId
import Stack.Types.NamedComponent
import Stack.Types.SourceMap (smRelDir)
import qualified System.FilePath as FP
import System.PosixCompat.Files (modificationTime, getFileStatus, setFileTimes)

Expand Down Expand Up @@ -108,14 +109,16 @@ buildCacheFile :: (HasEnvConfig env, MonadReader env m, MonadThrow m)
-> m (Path Abs File)
buildCacheFile dir component = do
cachesDir <- buildCachesDir dir
sm <- view $ envConfigL.to envConfigSourceMap
smDirName <- smRelDir sm
let nonLibComponent prefix name = prefix <> "-" <> T.unpack name
cacheFileName <- parseRelFile $ case component of
CLib -> "lib"
CInternalLib name -> nonLibComponent "internal-lib" name
CExe name -> nonLibComponent "exe" name
CTest name -> nonLibComponent "test" name
CBench name -> nonLibComponent "bench" name
return $ cachesDir </> cacheFileName
return $ cachesDir </> smDirName </> cacheFileName

-- | Try to read the dirtiness cache for the given package directory.
tryGetBuildCache :: HasEnvConfig env
Expand Down
34 changes: 25 additions & 9 deletions src/Stack/Build/ConstructPlan.hs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ data Ctx = Ctx
, callStack :: ![PackageName]
, wanted :: !(Set PackageName)
, localNames :: !(Set PackageName)
, mcurator :: !(Maybe Curator)
}

instance HasPlatform Ctx
Expand Down Expand Up @@ -166,7 +167,7 @@ instance HasEnvConfig Ctx where
-- some of its dependencies have changed.
constructPlan :: forall env. HasEnvConfig env
=> BaseConfigOpts
-> [DumpPackage () () ()] -- ^ locally registered
-> [DumpPackage] -- ^ locally registered
-> (PackageLocationImmutable -> Map FlagName Bool -> [Text] -> RIO EnvConfig Package) -- ^ load upstream package
-> SourceMap
-> InstalledMap
Expand All @@ -180,10 +181,11 @@ constructPlan baseConfigOpts0 localDumpPkgs loadPackage0 sourceMap installedMap

econfig <- view envConfigL
sources <- getSources
mcur <- view $ buildConfigL.to bcCurator

let onTarget = void . addDep
let inner = mapM_ onTarget $ Map.keys (smtTargets $ smTargets sourceMap)
let ctx = mkCtx econfig sources
let ctx = mkCtx econfig sources mcur
((), m, W efinals installExes dirtyReason warnings parents) <-
liftIO $ runRWST inner ctx M.empty
mapM_ (logWarn . RIO.display) (warnings [])
Expand Down Expand Up @@ -222,14 +224,15 @@ constructPlan baseConfigOpts0 localDumpPkgs loadPackage0 sourceMap installedMap
where
hasBaseInDeps = Map.member (mkPackageName "base") (smDeps sourceMap)

mkCtx econfig sources = Ctx
mkCtx econfig sources mcur = Ctx
{ baseConfigOpts = baseConfigOpts0
, loadPackage = \x y z -> runRIO econfig $ loadPackage0 x y z
, combinedMap = combineMap sources installedMap
, ctxEnvConfig = econfig
, callStack = []
, wanted = Map.keysSet (smtTargets $ smTargets sourceMap)
, localNames = Map.keysSet (smProject sourceMap)
, mcurator = mcur
}

prunedGlobalDeps = flip Map.mapMaybe (smGlobal sourceMap) $ \gp ->
Expand Down Expand Up @@ -261,7 +264,7 @@ constructPlan baseConfigOpts0 localDumpPkgs loadPackage0 sourceMap installedMap
-- to unregister.
data UnregisterState = UnregisterState
{ usToUnregister :: !(Map GhcPkgId (PackageIdentifier, Text))
, usKeep :: ![DumpPackage () () ()]
, usKeep :: ![DumpPackage]
, usAnyAdded :: !Bool
}

Expand All @@ -271,7 +274,7 @@ mkUnregisterLocal :: Map PackageName Task
-- ^ Tasks
-> Map PackageName Text
-- ^ Reasons why packages are dirty and must be rebuilt
-> [DumpPackage () () ()]
-> [DumpPackage]
-- ^ Local package database dump
-> Bool
-- ^ If true, we're doing a special initialBuildSteps
Expand Down Expand Up @@ -348,7 +351,7 @@ mkUnregisterLocal tasks dirtyReason localDumpPkgs initialBuildSteps =
-- step.
addFinal :: LocalPackage -> Package -> Bool -> Bool -> M ()
addFinal lp package isAllInOne buildHaddocks = do
depsRes <- addPackageDeps {-False-} package
depsRes <- addPackageDeps package
res <- case depsRes of
Left e -> return $ Left e
Right (missing, present, _minLoc) -> do
Expand Down Expand Up @@ -494,7 +497,7 @@ installPackage name ps minstalled = do
planDebug $ "installPackage: Doing all-in-one build for upstream package " ++ show name
package <- loadPackage ctx pkgLoc (cpFlags cp) (cpGhcOptions cp)
resolveDepsAndInstall True (cpHaddocks cp) ps package minstalled
PSFilePath lp ->
PSFilePath lp -> do
case lpTestBench lp of
Nothing -> do
planDebug $ "installPackage: No test / bench component for " ++ show name ++ " so doing an all-in-one build."
Expand All @@ -513,10 +516,18 @@ installPackage name ps minstalled = do
case res of
Right deps -> do
planDebug $ "installPackage: For " ++ show name ++ ", successfully added package deps"
adr <- installPackageGivenDeps True False ps tb minstalled deps
-- in curator builds we can't do all-in-one build as test/benchmark failure
-- could prevent library from being available to its dependencies
-- but when it's already available it's OK to do that
splitRequired <- expectedTestOrBenchFailures <$> asks mcurator
let isAllInOne = not splitRequired
adr <- installPackageGivenDeps isAllInOne (lpBuildHaddocks lp) ps tb minstalled deps
let finalAllInOne = case adr of
ADRToInstall _ | splitRequired -> False
_ -> True
-- FIXME: this redundantly adds the deps (but
-- they'll all just get looked up in the map)
addFinal lp tb True False
addFinal lp tb finalAllInOne False
return $ Right adr
Left _ -> do
-- Reset the state to how it was before
Expand All @@ -533,6 +544,11 @@ installPackage name ps minstalled = do
updateLibMap name res'
addFinal lp tb False False
return res'
where
expectedTestOrBenchFailures maybeCurator = fromMaybe False $ do
curator <- maybeCurator
pure $ Set.member name (curatorExpectTestFailure curator) ||
Set.member name (curatorExpectBenchmarkFailure curator)

resolveDepsAndInstall :: Bool
-> Bool
Expand Down
Loading