diff --git a/.gitignore b/.gitignore index 82f3a88..fa3c009 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,5 @@ cabal.project.local cabal.project.local~ .HTF/ .ghc.environment.* +*.yaml.lock +!stack.yaml.lock diff --git a/.travis.yml b/.travis.yml index 3045b42..2fa0fe9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ matrix: include: # Previous lts releases - os: linux - env: STACK_YAML=stack-ghc-7.8.yaml STACK_PKG_URL=https://www.stackage.org/stack/linux-x86_64 + env: STACK_YAML=stack-ghc-7.8.yaml STACK_PKG_URL=https://github.com/commercialhaskell/stack/releases/download/v1.9.3/stack-1.9.3-linux-x86_64-static.tar.gz - os: linux env: STACK_YAML=stack-ghc-7.10.yaml STACK_PKG_URL=https://www.stackage.org/stack/linux-x86_64 - os: linux @@ -23,9 +23,6 @@ matrix: env: STACK_YAML=stack-nightly.yaml STACK_PKG_URL=https://www.stackage.org/stack/linux-x86_64 allow_failures: # These are not stable yet - - env: STACK_YAML=stack-ghc-7.8.yaml STACK_PKG_URL=https://www.stackage.org/stack/linux-x86_64 - - env: STACK_YAML=stack-ghc-7.10.yaml STACK_PKG_URL=https://www.stackage.org/stack/linux-x86_64 - - env: STACK_YAML=stack-ghc-8.0.yaml STACK_PKG_URL=https://www.stackage.org/stack/linux-x86_64 - env: STACK_YAML=stack-nightly.yaml STACK_PKG_URL=https://www.stackage.org/stack/linux-x86_64 cache: @@ -41,10 +38,3 @@ script: - source .ci-scripts/travis/run-hlint.sh - travis_wait 45 stack --no-terminal --skip-ghc-check test --flag github-webhooks:ci --haddock --no-haddock-deps - source .ci-scripts/travis/run-weeder.sh - - # Build the integration examples - - travis_wait 45 stack --no-terminal --skip-ghc-check build - github-webhooks-scotty-example - github-webhooks-servant-simple-example - github-webhooks-servant-example - diff --git a/github-webhooks.cabal b/github-webhooks.cabal index 1ea2145..40c4288 100644 --- a/github-webhooks.cabal +++ b/github-webhooks.cabal @@ -1,10 +1,11 @@ --- This file has been generated from package.yaml by hpack version 0.21.2. +cabal-version: 1.12 + +-- This file has been generated from package.yaml by hpack version 0.31.2. -- -- see: https://github.com/sol/hpack -- --- hash: 53e392c223a6c9b9667f45cd1fdac1ee1588fb5b1b31d7789bd9d10de1151de6 +-- hash: 1a0d06526485495c6980a45d68f584ba73282c28be0394d5530961bd0e0f0de2 -cabal-version: >= 1.10 name: github-webhooks version: 0.11.0 synopsis: Aeson instances for GitHub Webhook payloads. @@ -22,8 +23,14 @@ copyright: (c) 2017-2019 ONROCK license: MIT license-file: LICENSE build-type: Simple - extra-source-files: + package.yaml + stack.yaml + stack-examples.yaml + stack-ghc-7.10.yaml + stack-ghc-7.8.yaml + stack-ghc-8.0.yaml + stack-nightly.yaml CHANGELOG.md fixtures/commit-comment-event.json fixtures/create-event.json @@ -58,12 +65,6 @@ extra-source-files: fixtures/team-add-event.json fixtures/team-event.json fixtures/watch-event.json - package.yaml - stack-ghc-7.10.yaml - stack-ghc-7.8.yaml - stack-ghc-8.0.yaml - stack-nightly.yaml - stack.yaml source-repository head type: git @@ -91,7 +92,7 @@ library , time , vector if flag(ci) - ghc-options: -Wall -Werror -fwarn-incomplete-uni-patterns -fwarn-incomplete-record-updates -ddump-to-file -ddump-hi + ghc-options: -Wall -fwarn-incomplete-uni-patterns -fwarn-incomplete-record-updates -ddump-to-file -ddump-hi exposed-modules: GitHub.Data.Webhooks.Events GitHub.Data.Webhooks.Payload @@ -115,7 +116,7 @@ test-suite spec , text , vector if flag(ci) - ghc-options: -Wall -Werror -fwarn-incomplete-uni-patterns -fwarn-incomplete-record-updates -ddump-to-file -ddump-hi + ghc-options: -Wall -fwarn-incomplete-uni-patterns -fwarn-incomplete-record-updates -ddump-to-file -ddump-hi other-modules: DecodeEventsSpec Paths_github_webhooks diff --git a/package.yaml b/package.yaml index 8a05d70..dfb1b6d 100644 --- a/package.yaml +++ b/package.yaml @@ -31,7 +31,7 @@ flags: when: - condition: flag(ci) - ghc-options: -Wall -Werror -fwarn-incomplete-uni-patterns -fwarn-incomplete-record-updates -ddump-to-file -ddump-hi + ghc-options: -Wall -fwarn-incomplete-uni-patterns -fwarn-incomplete-record-updates -ddump-to-file -ddump-hi default-extensions: - DeriveDataTypeable diff --git a/src/GitHub/Data/Webhooks/Events.hs b/src/GitHub/Data/Webhooks/Events.hs index 987a3ef..f076b07 100644 --- a/src/GitHub/Data/Webhooks/Events.hs +++ b/src/GitHub/Data/Webhooks/Events.hs @@ -103,9 +103,12 @@ module GitHub.Data.Webhooks.Events ) where import Data.Aeson (FromJSON(..), withObject, withText, (.:), (.:?), (.!=)) +import Control.Applicative ((<*>), pure) import Control.DeepSeq (NFData(..)) import Control.DeepSeq.Generics (genericRnf) import Data.Data (Data, Typeable) +import Data.Functor ((<$>)) +import Data.Monoid (mempty) import Data.Time (UTCTime) import Data.Text (Text) import Data.Vector (Vector) diff --git a/src/GitHub/Data/Webhooks/Payload.hs b/src/GitHub/Data/Webhooks/Payload.hs index c342ce6..2545e64 100644 --- a/src/GitHub/Data/Webhooks/Payload.hs +++ b/src/GitHub/Data/Webhooks/Payload.hs @@ -47,8 +47,9 @@ module GitHub.Data.Webhooks.Payload import Data.Aeson (FromJSON(..), withObject, withText, (.!=), (.:), (.:?)) import Control.DeepSeq (NFData (..)) import Control.DeepSeq.Generics (genericRnf) -import Control.Applicative ((<|>)) +import Control.Applicative ((<|>), (<*>), pure) import Data.Data (Data, Typeable) +import Data.Functor ((<$>)) import Data.Time (UTCTime) import Data.Time.Clock.POSIX (posixSecondsToUTCTime) import Data.Text (Text) @@ -723,9 +724,9 @@ instance FromJSON HookRepository where <*> o .: "labels_url" <*> o .: "releases_url" -- FIXME: Wrap optional number/stringified UTCTime in a helper function? See PushEvent fixture - <*> ((o .: "created_at") <|> (posixSecondsToUTCTime <$> o .: "created_at")) - <*> ((o .: "updated_at") <|> (posixSecondsToUTCTime <$> o .: "updated_at")) - <*> ((o .: "pushed_at") <|> (posixSecondsToUTCTime <$> o .: "pushed_at")) + <*> ((o .: "created_at") <|> (posixSecondsToUTCTime . fromInteger <$> o .: "created_at")) + <*> ((o .: "updated_at") <|> (posixSecondsToUTCTime . fromInteger <$> o .: "updated_at")) + <*> ((o .: "pushed_at") <|> (posixSecondsToUTCTime . fromInteger <$> o .: "pushed_at")) <*> o .: "git_url" <*> o .: "ssh_url" <*> o .: "clone_url" diff --git a/src/GitHub/Data/Webhooks/Secure.hs b/src/GitHub/Data/Webhooks/Secure.hs index 42b6bcc..fc89b30 100644 --- a/src/GitHub/Data/Webhooks/Secure.hs +++ b/src/GitHub/Data/Webhooks/Secure.hs @@ -12,7 +12,9 @@ import Crypto.MAC.HMAC (HMAC(..), hmac) import Control.Monad (unless) import Control.Exception (Exception, throwIO) import Data.ByteArray (convert, constEq) +import Data.Data (Typeable) import Data.Monoid ((<>)) +import Data.Functor ((<$>)) import Data.ByteString (ByteString) import Data.Text (Text) import qualified Data.ByteString.Base16 as B16 @@ -38,6 +40,7 @@ isSecurePayload secret shaOpt payload = maybe False (constEq ourSig) theirSig -- | An exception indicating that the given payload is not secure. data PayloadNotSecure = PayloadNotSecure + deriving (Typeable) instance Exception PayloadNotSecure diff --git a/stack-examples.yaml b/stack-examples.yaml new file mode 100644 index 0000000..b0ccc76 --- /dev/null +++ b/stack-examples.yaml @@ -0,0 +1,9 @@ +resolver: lts-11.5 +packages: +- . +- examples/scotty +- examples/servant +- examples/servant-simple +extra-deps: +# Needed for servant examples +- servant-github-webhook-0.4.1.0 diff --git a/stack-ghc-7.10.yaml b/stack-ghc-7.10.yaml index 681142b..d442bb9 100644 --- a/stack-ghc-7.10.yaml +++ b/stack-ghc-7.10.yaml @@ -1,8 +1 @@ resolver: lts-6.35 -extra-deps: -# Needed for servant examples -- servant-github-webhook-0.4.1.0 -# Examples -- ./examples/servant-simple -- ./examples/servant -- ./examples/scotty diff --git a/stack-ghc-7.8.yaml b/stack-ghc-7.8.yaml index c0714a5..c6c2481 100644 --- a/stack-ghc-7.8.yaml +++ b/stack-ghc-7.8.yaml @@ -1,8 +1,3 @@ resolver: lts-2.22 extra-deps: -# Needed for servant examples -- servant-github-webhook-0.4.1.0 -# Examples -- ./examples/servant-simple -- ./examples/servant -- ./examples/scotty +- cryptonite-0.6 diff --git a/stack-ghc-8.0.yaml b/stack-ghc-8.0.yaml index 8e2393b..338e9f4 100644 --- a/stack-ghc-8.0.yaml +++ b/stack-ghc-8.0.yaml @@ -1,8 +1 @@ resolver: lts-7.24 -extra-deps: -# Needed for servant examples -- servant-github-webhook-0.4.1.0 -# Examples -- ./examples/servant-simple -- ./examples/servant -- ./examples/scotty diff --git a/stack-nightly.yaml b/stack-nightly.yaml index 4d465aa..f22f1e2 100644 --- a/stack-nightly.yaml +++ b/stack-nightly.yaml @@ -1,8 +1 @@ -resolver: nightly -extra-deps: -# Needed for servant examples -- servant-github-webhook-0.4.1.0 -# Examples -- ./examples/servant-simple -- ./examples/servant -- ./examples/scotty +resolver: nightly-2019-10-15 # Overriden by --resolver nightly on CI matrix diff --git a/stack.yaml b/stack.yaml index a19eab1..1cdeab2 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1,8 +1 @@ resolver: lts-11.5 -extra-deps: -# Needed for servant examples -- servant-github-webhook-0.4.1.0 -# Examples -- ./examples/servant-simple -- ./examples/servant -- ./examples/scotty diff --git a/stack.yaml.lock b/stack.yaml.lock index 7d6f6d2..3824427 100644 --- a/stack.yaml.lock +++ b/stack.yaml.lock @@ -3,14 +3,7 @@ # For more information, please see the documentation at: # https://docs.haskellstack.org/en/stable/lock_files -packages: -- completed: - hackage: servant-github-webhook-0.4.1.0@sha256:6ac456ccc6a2a96b30a7b80cd91b121f1b7e9bd33635641a6afbd6137700a753,2754 - pantry-tree: - size: 576 - sha256: f00112fb96ffe1caa7076a466868af0b47eed0ffea92792b3cde5a5e369a7005 - original: - hackage: servant-github-webhook-0.4.1.0 +packages: [] snapshots: - completed: size: 507344