summaryrefslogtreecommitdiff
path: root/src/Job.hs
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2025-01-09 19:39:52 +0100
committerRoman Smrž <roman.smrz@seznam.cz>2025-01-10 20:17:54 +0100
commitded067166901805bba63a35b37fe83ebfc4e6aa8 (patch)
tree6ef85e05f4caa49662fabfa2a0b91cdf83e03fe6 /src/Job.hs
parent03c781c1a60759622e772ac7fb6a167111ed0bea (diff)
Run jobs based on configuration in associated commit
Changelog: Run jobs based on configuration in associated commit
Diffstat (limited to 'src/Job.hs')
-rw-r--r--src/Job.hs25
1 files changed, 4 insertions, 21 deletions
diff --git a/src/Job.hs b/src/Job.hs
index ccb8611..068a076 100644
--- a/src/Job.hs
+++ b/src/Job.hs
@@ -1,5 +1,6 @@
module Job (
Job(..),
+ JobSet(..), jobsetJobs,
JobOutput(..),
JobName(..), stringJobName, textJobName,
ArtifactName(..),
@@ -27,34 +28,16 @@ import System.FilePath
import System.IO
import System.Process
+import Job.Types
import Repo
-data Job = Job
- { jobName :: JobName
- , jobRecipe :: [CreateProcess]
- , jobArtifacts :: [(ArtifactName, CreateProcess)]
- , jobUses :: [(JobName, ArtifactName)]
- }
-
data JobOutput = JobOutput
{ outName :: JobName
, outArtifacts :: [ArtifactOutput]
}
deriving (Eq)
-data JobName = JobName Text
- deriving (Eq, Ord, Show)
-
-stringJobName :: JobName -> String
-stringJobName (JobName name) = T.unpack name
-
-textJobName :: JobName -> Text
-textJobName (JobName name) = name
-
-data ArtifactName = ArtifactName Text
- deriving (Eq, Ord, Show)
-
data ArtifactOutput = ArtifactOutput
{ aoutName :: ArtifactName
, aoutWorkPath :: FilePath
@@ -96,7 +79,7 @@ textJobStatus = \case
JobDone _ -> "done"
-runJobs :: FilePath -> Commit -> [Job] -> IO [TVar (JobStatus JobOutput)]
+runJobs :: FilePath -> Commit -> [Job] -> IO [ ( Job, TVar (JobStatus JobOutput) ) ]
runJobs dir commit jobs = do
results <- forM jobs $ \job -> (job,) <$> newTVarIO JobQueued
forM_ results $ \(job, outVar) -> void $ forkIO $ do
@@ -112,7 +95,7 @@ runJobs dir commit jobs = do
_ -> return ()
atomically $ writeTVar outVar $ either id JobDone res
- return $ map snd results
+ return results
waitForUsedArtifacts :: (MonadIO m, MonadError (JobStatus JobOutput) m) =>
Job -> [(Job, TVar (JobStatus JobOutput))] -> TVar (JobStatus JobOutput) -> m [ArtifactOutput]