-
Notifications
You must be signed in to change notification settings - Fork 196
Expand file tree
/
Copy pathWorkflowJobs.hs
More file actions
100 lines (89 loc) · 3.1 KB
/
WorkflowJobs.hs
File metadata and controls
100 lines (89 loc) · 3.1 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE KindSignatures #-}
module GitHub.Data.Actions.WorkflowJobs (
JobStep(..),
Job(..),
) where
import Prelude ()
import GitHub.Internal.Prelude
(Applicative ((<*>)), Data, Eq, FromJSON (parseJSON), Generic, Integer,
Ord, Show, Text, UTCTime, Vector, withObject, ($), (.:),
(<$>))
import GitHub.Data.Id (Id)
import GitHub.Data.Name (Name)
import GitHub.Data.URL (URL)
import GitHub.Data.Actions.Common (WithTotalCount (WithTotalCount))
import GitHub.Data.Actions.WorkflowRuns (WorkflowRun)
-------------------------------------------------------------------------------
-- Workflow jobs
-------------------------------------------------------------------------------
data JobStep = JobStep
{ jobStepName :: !(Name JobStep)
, jobStepStatus :: !Text
, jobStepConclusion :: !Text
, jobStepNumber :: !Integer
, jobStepStartedAt :: !UTCTime
, jobStepCompletedAt :: !UTCTime
}
deriving (Show, Data, Eq, Ord, Generic)
data Job = Job
{ jobId :: !(Id Job)
, jobRunId :: !(Id WorkflowRun)
, jobRunUrl :: !URL
, jobRunAttempt :: !Integer
, jobNodeId :: !Text
, jobHeadSha :: !Text
, jobUrl :: !URL
, jobHtmlUrl :: !URL
, jobStatus :: !Text
, jobConclusion :: !Text
, jobStartedAt :: !UTCTime
, jobCompletedAt :: !UTCTime
, jobName :: !(Name Job)
, jobSteps :: !(Vector JobStep)
, jobRunCheckUrl :: !URL
, jobLabels :: !(Vector Text)
, jobRunnerId :: !Integer
, jobRunnerName :: !Text
, jobRunnerGroupId :: !Integer
, jobRunnerGroupName :: !Text
}
deriving (Show, Data, Eq, Ord, Generic)
-------------------------------------------------------------------------------
-- JSON instances
-------------------------------------------------------------------------------
instance FromJSON JobStep where
parseJSON = withObject "JobStep" $ \o -> JobStep
<$> o .: "name"
<*> o .: "status"
<*> o .: "conclusion"
<*> o .: "number"
<*> o .: "started_at"
<*> o .: "completed_at"
instance FromJSON Job where
parseJSON = withObject "Job" $ \o -> Job
<$> o .: "id"
<*> o .: "run_id"
<*> o .: "run_url"
<*> o .: "run_attempt"
<*> o .: "node_id"
<*> o .: "head_sha"
<*> o .: "url"
<*> o .: "html_url"
<*> o .: "status"
<*> o .: "conclusion"
<*> o .: "started_at"
<*> o .: "completed_at"
<*> o .: "name"
<*> o .: "steps"
<*> o .: "check_run_url"
<*> o .: "labels"
<*> o .: "runner_id"
<*> o .: "runner_name"
<*> o .: "runner_group_id"
<*> o .: "runner_group_name"
instance FromJSON (WithTotalCount Job) where
parseJSON = withObject "JobList" $ \o -> WithTotalCount
<$> o .: "jobs"
<*> o .: "total_count"