-
Notifications
You must be signed in to change notification settings - Fork 196
Expand file tree
/
Copy pathWorkflowRuns.hs
More file actions
91 lines (79 loc) · 2.76 KB
/
WorkflowRuns.hs
File metadata and controls
91 lines (79 loc) · 2.76 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
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE KindSignatures #-}
module GitHub.Data.Actions.WorkflowRuns (
WorkflowRun(..),
RunAttempt(..),
ReviewHistory(..),
) where
import GitHub.Data.Actions.Common (WithTotalCount (WithTotalCount))
import GitHub.Data.Definitions
import GitHub.Data.URL (URL)
import GitHub.Internal.Prelude
import Prelude ()
import GitHub.Data.Id (Id)
import GitHub.Data.Name (Name)
-------------------------------------------------------------------------------
-- Workflow runs
-------------------------------------------------------------------------------
data WorkflowRun = WorkflowRun
{ workflowRunWorkflowRunId :: !(Id WorkflowRun)
, workflowRunName :: !(Name WorkflowRun)
, workflowRunHeadBranch :: !Text
, workflowRunHeadSha :: !Text
, workflowRunPath :: !Text
, workflowRunDisplayTitle :: !Text
, workflowRunRunNumber :: !Integer
, workflowRunEvent :: !Text
, workflowRunStatus :: !Text
, workflowRunConclusion :: !(Maybe Text)
, workflowRunWorkflowId :: !Integer
, workflowRunUrl :: !URL
, workflowRunHtmlUrl :: !URL
, workflowRunCreatedAt :: !UTCTime
, workflowRunUpdatedAt :: !UTCTime
, workflowRunActor :: !SimpleUser
, workflowRunAttempt :: !Integer
, workflowRunStartedAt :: !UTCTime
}
deriving (Show, Data, Eq, Ord, Generic)
data RunAttempt = RunAttempt
deriving (Show, Data, Eq, Ord, Generic)
data ReviewHistory = ReviewHistory
{ reviewHistoryState :: !Text
, reviewHistoryComment :: !Text
, reviewHistoryUser :: !SimpleUser
}
deriving (Show, Data, Eq, Ord, Generic)
-------------------------------------------------------------------------------
-- JSON instances
-------------------------------------------------------------------------------
instance FromJSON WorkflowRun where
parseJSON = withObject "WorkflowRun" $ \o -> WorkflowRun
<$> o .: "id"
<*> o .: "name"
<*> o .: "head_branch"
<*> o .: "head_sha"
<*> o .: "path"
<*> o .: "display_title"
<*> o .: "run_number"
<*> o .: "event"
<*> o .: "status"
<*> o .: "conclusion"
<*> o .: "workflow_id"
<*> o .: "url"
<*> o .: "html_url"
<*> o .: "created_at"
<*> o .: "updated_at"
<*> o .: "actor"
<*> o .: "run_attempt"
<*> o .: "run_started_at"
instance FromJSON (WithTotalCount WorkflowRun) where
parseJSON = withObject "WorkflowRunList" $ \o -> WithTotalCount
<$> o .: "workflow_runs"
<*> o .: "total_count"
instance FromJSON ReviewHistory where
parseJSON = withObject "ReviewHistory" $ \o -> ReviewHistory
<$> o .: "state"
<*> o .: "comment"
<*> o .: "user"