@@ -14,7 +14,7 @@ import Control.Applicative
1414import Control.Concurrent.Async (Concurrently (.. ), async )
1515import Control.Concurrent.STM
1616import Control.Exception
17- import Control.Monad (join )
17+ import Control.Monad (join , unless )
1818import Data.Foldable (sequenceA_ )
1919import Data.Set (Set )
2020import qualified Data.Set as Set
@@ -45,6 +45,7 @@ data ExecuteState = ExecuteState
4545 , esExceptions :: TVar [SomeException ]
4646 , esInAction :: TVar (Set ActionId )
4747 , esCompleted :: TVar Int
48+ , esKeepGoing :: Bool
4849 }
4950
5051data ExecuteException
@@ -57,15 +58,17 @@ instance Show ExecuteException where
5758 " Inconsistent dependencies were discovered while executing your build plan. This should never happen, please report it as a bug to the stack team."
5859
5960runActions :: Int -- ^ threads
61+ -> Bool -- ^ keep going after one task has failed
6062 -> [Action ]
6163 -> (TVar Int -> IO () ) -- ^ progress updated
6264 -> IO [SomeException ]
63- runActions threads actions0 withProgress = do
65+ runActions threads keepGoing actions0 withProgress = do
6466 es <- ExecuteState
6567 <$> newTVarIO actions0
6668 <*> newTVarIO []
6769 <*> newTVarIO Set. empty
6870 <*> newTVarIO 0
71+ <*> pure keepGoing
6972 _ <- async $ withProgress $ esCompleted es
7073 if threads <= 1
7174 then runActions' es
@@ -78,7 +81,7 @@ runActions' ExecuteState {..} =
7881 where
7982 breakOnErrs inner = do
8083 errs <- readTVar esExceptions
81- if null errs
84+ if null errs || esKeepGoing
8285 then inner
8386 else return $ return ()
8487 withActions inner = do
@@ -92,7 +95,8 @@ runActions' ExecuteState {..} =
9295 inAction <- readTVar esInAction
9396 if Set. null inAction
9497 then do
95- modifyTVar esExceptions (toException InconsistentDependencies : )
98+ unless esKeepGoing $
99+ modifyTVar esExceptions (toException InconsistentDependencies : )
96100 return $ return ()
97101 else retry
98102 (xs, action: ys) -> do
@@ -107,15 +111,12 @@ runActions' ExecuteState {..} =
107111 eres <- try $ restore $ actionDo action ActionContext
108112 { acRemaining = remaining
109113 }
110- case eres of
111- Left err -> atomically $ do
112- modifyTVar esExceptions (err: )
113- modifyTVar esInAction (Set. delete $ actionId action)
114- modifyTVar esCompleted (+ 1 )
115- Right () -> do
116- atomically $ do
117- modifyTVar esInAction (Set. delete $ actionId action)
118- modifyTVar esCompleted (+ 1 )
114+ atomically $ do
115+ modifyTVar esInAction (Set. delete $ actionId action)
116+ modifyTVar esCompleted (+ 1 )
117+ case eres of
118+ Left err -> modifyTVar esExceptions (err: )
119+ Right () ->
119120 let dropDep a = a { actionDeps = Set. delete (actionId action) $ actionDeps a }
120- modifyTVar esActions $ map dropDep
121- restore loop
121+ in modifyTVar esActions $ map dropDep
122+ restore loop
0 commit comments