summaryrefslogtreecommitdiff
path: root/src/Job/Types.hs
blob: 50a6b433d716ba73bdcede4babef2757069ee845 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
module Job.Types where

import Data.Text (Text)
import Data.Text qualified as T

import System.Process

import Repo


data Job = Job
    { jobName :: JobName
    , jobRecipe :: [ CreateProcess ]
    , jobArtifacts :: [ ( ArtifactName, CreateProcess ) ]
    , jobUses :: [ ( JobName, ArtifactName ) ]
    }

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 JobSet = JobSet
    { jobsetCommit :: Commit
    , jobsetJobsEither :: Either String [ Job ]
    }

jobsetJobs :: JobSet -> [ Job ]
jobsetJobs = either (const []) id . jobsetJobsEither


newtype JobId = JobId [ JobIdPart ]
    deriving (Eq, Ord)

data JobIdPart
    = JobIdName JobName
    | JobIdCommit CommitId
    | JobIdTree TreeId
    deriving (Eq, Ord)