Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for check_run event. #109

Merged
merged 1 commit into from
Mar 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions github-tools.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ library
GitHub.Types.Base.Branch
GitHub.Types.Base.Change
GitHub.Types.Base.Changes
GitHub.Types.Base.CheckApp
GitHub.Types.Base.CheckCommit
GitHub.Types.Base.CheckOutput
GitHub.Types.Base.CheckRun
GitHub.Types.Base.CheckSuite
GitHub.Types.Base.Commit
GitHub.Types.Base.CommitComment
GitHub.Types.Base.CommitDetails
Expand All @@ -48,6 +53,7 @@ library
GitHub.Types.Base.Organization
GitHub.Types.Base.PageBuild
GitHub.Types.Base.PageBuildError
GitHub.Types.Base.Permissions
GitHub.Types.Base.PullRequest
GitHub.Types.Base.PullRequestLinks
GitHub.Types.Base.PullRequestRef
Expand All @@ -68,6 +74,8 @@ library
GitHub.Types.Base.Verification
GitHub.Types.Event
GitHub.Types.Events
GitHub.Types.Events.CheckRunEvent
GitHub.Types.Events.CheckSuiteEvent
GitHub.Types.Events.CommitCommentEvent
GitHub.Types.Events.CreateEvent
GitHub.Types.Events.DeleteEvent
Expand All @@ -90,6 +98,7 @@ library
GitHub.Types.Events.PushEvent
GitHub.Types.Events.ReleaseEvent
GitHub.Types.Events.RepositoryEvent
GitHub.Types.Events.StarEvent
GitHub.Types.Events.StatusEvent
GitHub.Types.Events.WatchEvent
GitHub.Types.PayloadParser
Expand Down Expand Up @@ -168,23 +177,22 @@ executable webservice
-Wall
build-depends:
base >= 4 && < 5
, Diff
, github-tools
, aeson >= 0.8.1.0
, aeson-pretty
, bytestring
, case-insensitive
, expiring-cache-map
, github == 0.25
, http-media
, http-types
, mtl
, pretty
, servant >= 0.5
, servant-server >= 0.5
, text
, time
, transformers
, unordered-containers
, uuid
, vector
, wai
, wai-cors
, wai-extra
Expand Down
5 changes: 5 additions & 0 deletions src/GitHub/Types/Base.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ import GitHub.Types.Base.Author as X
import GitHub.Types.Base.Branch as X
import GitHub.Types.Base.Change as X
import GitHub.Types.Base.Changes as X
import GitHub.Types.Base.CheckApp as X
import GitHub.Types.Base.CheckCommit as X
import GitHub.Types.Base.CheckOutput as X
import GitHub.Types.Base.CheckRun as X
import GitHub.Types.Base.CheckSuite as X
import GitHub.Types.Base.Commit as X
import GitHub.Types.Base.CommitComment as X
import GitHub.Types.Base.CommitDetails as X
Expand Down
12 changes: 8 additions & 4 deletions src/GitHub/Types/Base/Branch.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,31 @@ import GitHub.Types.Base.CommitRef
-- Branch

data Branch = Branch
{ branchName :: Text
, branchCommit :: CommitRef
{ branchName :: Text
, branchProtected :: Bool
, branchCommit :: CommitRef
} deriving (Eq, Show, Read)


instance FromJSON Branch where
parseJSON (Object x) = Branch
<$> x .: "name"
<*> x .: "protected"
<*> x .: "commit"

parseJSON _ = fail "Branch"


instance ToJSON Branch where
toJSON Branch{..} = object
[ "name" .= branchName
, "commit" .= branchCommit
[ "name" .= branchName
, "protected" .= branchProtected
, "commit" .= branchCommit
]


instance Arbitrary Branch where
arbitrary = Branch
<$> arbitrary
<*> arbitrary
<*> arbitrary
82 changes: 82 additions & 0 deletions src/GitHub/Types/Base/CheckApp.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
module GitHub.Types.Base.CheckApp where

import Control.Applicative ((<$>), (<*>))
import Data.Aeson (FromJSON (..), ToJSON (..),
object)
import Data.Aeson.Types (Value (..), (.:), (.=))
import Data.Text (Text)
import Test.QuickCheck.Arbitrary (Arbitrary (..))

import GitHub.Types.Base.Permissions
import GitHub.Types.Base.User

------------------------------------------------------------------------------
-- CheckApp

data CheckApp = CheckApp
{ checkAppCreatedAt :: Text
, checkAppDescription :: Text
, checkAppEvents :: [Text]
, checkAppExternalUrl :: Text
, checkAppHtmlUrl :: Text
, checkAppId :: Int
, checkAppName :: Text
, checkAppNodeId :: Text
, checkAppOwner :: User
, checkAppPermissions :: Permissions
, checkAppSlug :: Text
, checkAppUpdatedAt :: Text
} deriving (Eq, Show, Read)


instance FromJSON CheckApp where
parseJSON (Object x) = CheckApp
<$> x .: "created_at"
<*> x .: "description"
<*> x .: "events"
<*> x .: "external_url"
<*> x .: "html_url"
<*> x .: "id"
<*> x .: "name"
<*> x .: "node_id"
<*> x .: "owner"
<*> x .: "permissions"
<*> x .: "slug"
<*> x .: "updated_at"

parseJSON _ = fail "CheckApp"


instance ToJSON CheckApp where
toJSON CheckApp{..} = object
[ "created_at" .= checkAppCreatedAt
, "description" .= checkAppDescription
, "events" .= checkAppEvents
, "external_url" .= checkAppExternalUrl
, "html_url" .= checkAppHtmlUrl
, "id" .= checkAppId
, "name" .= checkAppName
, "node_id" .= checkAppNodeId
, "owner" .= checkAppOwner
, "permissions" .= checkAppPermissions
, "slug" .= checkAppSlug
, "updated_at" .= checkAppUpdatedAt
]


instance Arbitrary CheckApp where
arbitrary = CheckApp
<$> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
56 changes: 56 additions & 0 deletions src/GitHub/Types/Base/CheckCommit.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
module GitHub.Types.Base.CheckCommit where

import Control.Applicative ((<$>), (<*>))
import Data.Aeson (FromJSON (..), ToJSON (..), object)
import Data.Aeson.Types (Value (..), (.:), (.=))
import Data.Text (Text)
import Test.QuickCheck.Arbitrary (Arbitrary (..))

import GitHub.Types.Base.Author

------------------------------------------------------------------------------
-- CheckCommit

data CheckCommit = CheckCommit
{ checkCommitAuthor :: Author
, checkCommitCommitter :: Author
, checkCommitId :: Text
, checkCommitMessage :: Text
, checkCommitTimestamp :: Text
, checkCommitTreeId :: Text
} deriving (Eq, Show, Read)


instance FromJSON CheckCommit where
parseJSON (Object x) = CheckCommit
<$> x .: "author"
<*> x .: "committer"
<*> x .: "id"
<*> x .: "message"
<*> x .: "timestamp"
<*> x .: "tree_id"

parseJSON _ = fail "CheckCommit"


instance ToJSON CheckCommit where
toJSON CheckCommit{..} = object
[ "author" .= checkCommitAuthor
, "committer" .= checkCommitCommitter
, "id" .= checkCommitId
, "message" .= checkCommitMessage
, "timestamp" .= checkCommitTimestamp
, "tree_id" .= checkCommitTreeId
]


instance Arbitrary CheckCommit where
arbitrary = CheckCommit
<$> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
51 changes: 51 additions & 0 deletions src/GitHub/Types/Base/CheckOutput.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
module GitHub.Types.Base.CheckOutput where

import Control.Applicative ((<$>), (<*>))
import Data.Aeson (FromJSON (..), ToJSON (..), object)
import Data.Aeson.Types (Value (..), (.:), (.=))
import Data.Text (Text)
import Data.Text.Arbitrary ()
import Test.QuickCheck.Arbitrary (Arbitrary (..))

------------------------------------------------------------------------------
-- CheckOutput

data CheckOutput = CheckOutput
{ checkOutputAnnotationsCount :: Int
, checkOutputAnnotationsUrl :: Text
, checkOutputSummary :: Maybe Text
, checkOutputText :: Maybe Text
, checkOutputTitle :: Maybe Text
} deriving (Eq, Show, Read)


instance FromJSON CheckOutput where
parseJSON (Object x) = CheckOutput
<$> x .: "annotations_count"
<*> x .: "annotations_url"
<*> x .: "summary"
<*> x .: "text"
<*> x .: "title"

parseJSON _ = fail "CheckOutput"


instance ToJSON CheckOutput where
toJSON CheckOutput{..} = object
[ "annotations_count" .= checkOutputAnnotationsCount
, "annotations_url" .= checkOutputAnnotationsUrl
, "summary" .= checkOutputSummary
, "text" .= checkOutputText
, "title" .= checkOutputTitle
]


instance Arbitrary CheckOutput where
arbitrary = CheckOutput
<$> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
95 changes: 95 additions & 0 deletions src/GitHub/Types/Base/CheckRun.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
module GitHub.Types.Base.CheckRun where

import Control.Applicative ((<$>), (<*>))
import Data.Aeson (FromJSON (..), ToJSON (..),
object)
import Data.Aeson.Types (Value (..), (.:), (.=))
import Data.Text (Text)
import Test.QuickCheck.Arbitrary (Arbitrary (..))

import GitHub.Types.Base.CheckApp
import GitHub.Types.Base.CheckOutput
import GitHub.Types.Base.CheckSuite

------------------------------------------------------------------------------
-- CheckRun

data CheckRun = CheckRun
{ checkRunApp :: CheckApp
, checkRunCheckSuite :: CheckSuite
, checkRunCompletedAt :: Maybe Text
, checkRunConclusion :: Maybe Text
, checkRunDetailsUrl :: Text
, checkRunExternalId :: Text
, checkRunHeadSha :: Text
, checkRunHtmlUrl :: Text
, checkRunId :: Int
, checkRunName :: Text
, checkRunNodeId :: Text
, checkRunOutput :: CheckOutput
, checkRunStartedAt :: Text
, checkRunStatus :: Text
, checkRunUrl :: Text
} deriving (Eq, Show, Read)


instance FromJSON CheckRun where
parseJSON (Object x) = CheckRun
<$> x .: "app"
<*> x .: "check_suite"
<*> x .: "completed_at"
<*> x .: "conclusion"
<*> x .: "details_url"
<*> x .: "external_id"
<*> x .: "head_sha"
<*> x .: "html_url"
<*> x .: "id"
<*> x .: "name"
<*> x .: "node_id"
<*> x .: "output"
<*> x .: "started_at"
<*> x .: "status"
<*> x .: "url"

parseJSON _ = fail "CheckRun"


instance ToJSON CheckRun where
toJSON CheckRun{..} = object
[ "app" .= checkRunApp
, "check_suite" .= checkRunCheckSuite
, "completed_at" .= checkRunCompletedAt
, "conclusion" .= checkRunConclusion
, "details_url" .= checkRunDetailsUrl
, "external_id" .= checkRunExternalId
, "head_sha" .= checkRunHeadSha
, "html_url" .= checkRunHtmlUrl
, "id" .= checkRunId
, "name" .= checkRunName
, "node_id" .= checkRunNodeId
, "output" .= checkRunOutput
, "started_at" .= checkRunStartedAt
, "status" .= checkRunStatus
, "url" .= checkRunUrl
]


instance Arbitrary CheckRun where
arbitrary = CheckRun
<$> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
<*> arbitrary
Loading