Skip to content

Commit

Permalink
[#43]: Revamp the CI system (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
kvanbere authored Dec 5, 2021
1 parent dafa89e commit 6bb78fa
Show file tree
Hide file tree
Showing 20 changed files with 168 additions and 99 deletions.
1 change: 0 additions & 1 deletion .ci-scripts
Submodule .ci-scripts deleted from 4ec68f
20 changes: 20 additions & 0 deletions .github/workflows/scan-code.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
on: [push]
name: scan-code
jobs:
scan-hlint:
name: hlint
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: 'Setup hlint'
uses: rwe/actions-hlint-setup@v1
with:
version: '3.1.6'

- name: 'Run hlint and annotate results'
uses: rwe/actions-hlint-run@v2
with:
path: '["src/", "spec/", "examples/"]'
fail-on: warning
27 changes: 27 additions & 0 deletions .github/workflows/test-macos-latest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
on: [push]
name: test-macos-latest
jobs:
test-package:
name: Test
runs-on: macOS-latest

strategy:
matrix:
stack-yaml:
- stack.yaml
- stack-examples.yaml
stack-version:
- latest

steps:
- uses: actions/checkout@v2

- uses: haskell/actions/setup@v1
with:
enable-stack: true
stack-no-global: true
stack-version: ${{ matrix.stack-version }}

- env:
STACK_YAML: ${{matrix.stack-yaml }}
run: stack --skip-ghc-check test --flag github-webhooks:ci --haddock --no-haddock-deps
44 changes: 44 additions & 0 deletions .github/workflows/test-ubuntu-latest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
on: [push]
name: test-ubuntu-latest
jobs:
test-package:
name: Test
runs-on: ubuntu-latest # or macOS-latest, or windows-latest

strategy:
matrix:
stack-yaml:
- stack.yaml
- stack-nightly.yaml
- stack-examples.yaml
- stack-ghc-7.8.yaml
- stack-ghc-7.10.yaml
- stack-ghc-8.0.yaml
- stack-ghc-8.2.yaml
- stack-ghc-8.4.yaml
- stack-ghc-8.6.yaml
- stack-ghc-8.8.yaml
- stack-ghc-8.10.yaml
stack-version:
- latest

exclude:
- stack-yaml: stack-ghc-7.8.yaml
stack-version: latest
include:
# ghc-7.8 resolver requires older stack
- stack-yaml: stack-ghc-7.8.yaml
stack-version: 1.9

steps:
- uses: actions/checkout@v2

- uses: haskell/actions/setup@v1
with:
enable-stack: true
stack-no-global: true
stack-version: ${{ matrix.stack-version }}

- env:
STACK_YAML: ${{matrix.stack-yaml }}
run: stack --skip-ghc-check test --flag github-webhooks:ci --haddock --no-haddock-deps
27 changes: 27 additions & 0 deletions .github/workflows/test-windows-latest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
on: [push]
name: test-windows-latest
jobs:
test-package:
name: Test
runs-on: windows-latest

strategy:
matrix:
stack-yaml:
- stack.yaml
- stack-examples.yaml
stack-version:
- latest

steps:
- uses: actions/checkout@v2

- uses: haskell/actions/setup@v1
with:
enable-stack: true
stack-no-global: true
stack-version: ${{ matrix.stack-version }}

- env:
STACK_YAML: ${{matrix.stack-yaml }}
run: stack --skip-ghc-check test --flag github-webhooks:ci --haddock --no-haddock-deps
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

45 changes: 0 additions & 45 deletions .travis.yml

This file was deleted.

8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
github-webhooks
---------------

![GitHub release (latest by date)](https://img.shields.io/github/v/release/cuedo/github-webhooks?style=flat-square)
[![Hackage](https://img.shields.io/hackage/v/github-webhooks.svg?style=flat-square)](https://hackage.haskell.org/package/github-webhooks)
[![License](https://img.shields.io/github/license/onrock-eng/github-webhooks.svg?style=flat-square)](#license)

| | `release` | `master` |
| | `release` | `develop` |
|-------------|---------|----------|
| Linux & OSX | [![travis-linux](https://img.shields.io/travis/onrock-eng/github-webhooks/release.svg?style=flat-square)](https://travis-ci.org/onrock-eng/github-webhooks) | [![travis-linux](https://img.shields.io/travis/onrock-eng/github-webhooks.svg?style=flat-square)](https://travis-ci.org/onrock-eng/github-webhooks) |
| Windows | [![appveyor-windows](https://img.shields.io/appveyor/ci/OnRockEngineering/github-webhooks/release.svg?style=flat-square)](https://ci.appveyor.com/project/OnRockEngineering/github-webhooks) | [![appveyor-windows](https://img.shields.io/appveyor/ci/OnRockEngineering/github-webhooks/master.svg?style=flat-square)](https://ci.appveyor.com/project/OnRockEngineering/github-webhooks) |
| Ubuntu | ![GitHub Workflow Status (branch)](https://img.shields.io/github/workflow/status/cuedo/github-webhooks/test-ubuntu-latest/release?style=flat-square) | ![GitHub Workflow Status (branch)](https://img.shields.io/github/workflow/status/cuedo/github-webhooks/test-ubuntu-latest/develop?style=flat-square) |
| Mac OS | ![GitHub Workflow Status (branch)](https://img.shields.io/github/workflow/status/cuedo/github-webhooks/test-macos-latest/release?style=flat-square) | ![GitHub Workflow Status (branch)](https://img.shields.io/github/workflow/status/cuedo/github-webhooks/test-macos-latest/develop?style=flat-square) |
| Windows | ![GitHub Workflow Status (branch)](https://img.shields.io/github/workflow/status/cuedo/github-webhooks/test-windows-latest/release?style=flat-square) |![GitHub Workflow Status (branch)](https://img.shields.io/github/workflow/status/cuedo/github-webhooks/test-windows-latest/develop?style=flat-square) |

Complete Haskell types and instances for decoding GitHub API [Webhook] payloads.

Expand Down
22 changes: 0 additions & 22 deletions appveyor.yml

This file was deleted.

2 changes: 1 addition & 1 deletion examples/scotty/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ github-webhooks-scotty-example

1. From the **root directory of this repository**, run:
```
$ stack build github-webhooks-scotty-example
$ stack build github-webhooks-scotty-example --stack-yaml "stack-examples.yaml"
```

2. Then to start the server:
Expand Down
10 changes: 6 additions & 4 deletions examples/scotty/github-webhooks-scotty-example.cabal
Original file line number Diff line number Diff line change
@@ -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.34.4.
--
-- see: https://github.com/sol/hpack
--
-- hash: 05938c93633bfc6a6dc46b8492aec232e08d2d0cd35104ab17b4188b2d42357d
-- hash: d8428034201293b018c5837284fb6fada822e5cc703563bad60b8d17ba0a5ef9

cabal-version: >= 1.10
name: github-webhooks-scotty-example
version: 0.0.0
author: Kyle Van Berendonck <kyle.vanberendonck@cuedo.com.au>
Expand All @@ -19,7 +20,8 @@ executable github-webhooks-scotty-example
Paths_github_webhooks_scotty_example
hs-source-dirs:
src
default-extensions: OverloadedStrings
default-extensions:
OverloadedStrings
ghc-options: -Wall -fwarn-incomplete-uni-patterns -fwarn-incomplete-record-updates
build-depends:
base ==4.*
Expand Down
2 changes: 1 addition & 1 deletion examples/servant-simple/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ github-webhooks-servant-example

1. From the **root directory of this repository**, run:
```
$ stack build github-webhooks-servant-simple-example
$ stack build github-webhooks-servant-simple-example --stack-yaml "stack-examples.yaml"
```

2. Then to start the server:
Expand Down
Original file line number Diff line number Diff line change
@@ -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.34.4.
--
-- see: https://github.com/sol/hpack
--
-- hash: a995e3a50a7f087a88a196f99eb845fc9a70c51f73a879bc4256a6f7522ebbd8
-- hash: adf0ce828a20e78e793bb6ca83763a25d3e00c778e5eaf1d6dfc1e722bb699a9

cabal-version: >= 1.10
name: github-webhooks-servant-simple-example
version: 0.0.0
author: Kyle Van Berendonck <kyle.vanberendonck@cuedo.com.au>
Expand All @@ -19,7 +20,14 @@ executable github-webhooks-servant-example
Paths_github_webhooks_servant_simple_example
hs-source-dirs:
src
default-extensions: OverloadedStrings DataKinds TypeFamilies TypeOperators FlexibleInstances MultiParamTypeClasses RankNTypes
default-extensions:
OverloadedStrings
DataKinds
TypeFamilies
TypeOperators
FlexibleInstances
MultiParamTypeClasses
RankNTypes
ghc-options: -Wall -fwarn-incomplete-uni-patterns -fwarn-incomplete-record-updates
build-depends:
base ==4.*
Expand Down
2 changes: 1 addition & 1 deletion examples/servant/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ github-webhooks-servant-example

1. From the **root directory of this repository**, run:
```
$ stack build github-webhooks-servant-example
$ stack build github-webhooks-servant-example --stack-yaml "stack-examples.yaml"
```

2. Then to start the server:
Expand Down
16 changes: 12 additions & 4 deletions examples/servant/github-webhooks-servant-example.cabal
Original file line number Diff line number Diff line change
@@ -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.34.4.
--
-- see: https://github.com/sol/hpack
--
-- hash: f135d8842861c67778a51759adb2b9e5ec97bac79e2da1e9b019b9c0a71c5943
-- hash: 0f8ba64f2981c4f188157ff6f1d932983a6f9702a1d20beb163c0a1780fc6eed

cabal-version: >= 1.10
name: github-webhooks-servant-example
version: 0.0.0
author: Kyle Van Berendonck <kyle.vanberendonck@cuedo.com.au>
Expand All @@ -17,7 +18,14 @@ executable github-webhooks-servant-example
main-is: Main.hs
hs-source-dirs:
src
default-extensions: OverloadedStrings DataKinds TypeFamilies TypeOperators FlexibleInstances MultiParamTypeClasses RankNTypes
default-extensions:
OverloadedStrings
DataKinds
TypeFamilies
TypeOperators
FlexibleInstances
MultiParamTypeClasses
RankNTypes
ghc-options: -Wall -fwarn-incomplete-uni-patterns -fwarn-incomplete-record-updates
build-depends:
base ==4.*
Expand Down
4 changes: 2 additions & 2 deletions spec/DecodeEventsSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2178,7 +2178,7 @@ labelEventFixture = LabelEvent
marketplacePurchaseEventFixture :: MarketplacePurchaseEvent
marketplacePurchaseEventFixture = MarketplacePurchaseEvent
{ evMarketplacePurchaseAction = MarketplacePurchaseChangedAction
, evMarketplacePurchaseEffectiveDate = read "2017-10-25 00:00:00 UTC"
, evMarketplacePurchaseEffectiveDate = read "2017-10-25 00:00:00Z"
, evMarketplacePurchaseSender =
HookUser
{ whUserLogin = "username"
Expand Down Expand Up @@ -2214,7 +2214,7 @@ marketplacePurchaseEventFixture = MarketplacePurchaseEvent
, whMarketplacePurchaseUnitCount = 10
, whMarketplacePurchaseOnFreeTrial = False
, whMarketplacePurchaseFreeTrialEndsOn = Nothing
, whMarketplacePurchaseNextBillingDate = Just (read "2017-11-05 00:00:00 UTC")
, whMarketplacePurchaseNextBillingDate = Just (read "2017-11-05 00:00:00Z")
, whMarketplacePurchasePlan =
HookMarketplacePlan
{ whMarketplacePlanId = 435
Expand Down
3 changes: 2 additions & 1 deletion src/GitHub/Data/Webhooks/Events.hs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ import Data.Data (Data, Typeable)
import Data.Functor ((<$>))
import Data.Monoid (mempty)
import Data.Time (UTCTime)
import Data.Time.LocalTime (zonedTimeToUTC)
import Data.Text (Text)
import Data.Vector (Vector)
import GHC.Generics (Generic)
Expand Down Expand Up @@ -1447,7 +1448,7 @@ instance FromJSON LabelEvent where
instance FromJSON MarketplacePurchaseEvent where
parseJSON = withObject "MarketplacePurchaseEvent" $ \o -> MarketplacePurchaseEvent
<$> o .: "action"
<*> o .: "effective_date"
<*> (zonedTimeToUTC <$> o .: "effective_date")
<*> o .: "sender"
<*> o .: "marketplace_purchase"
<*> o .:? "previous_marketplace_purchase"
Expand Down
7 changes: 4 additions & 3 deletions src/GitHub/Data/Webhooks/Payload.hs
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@ module GitHub.Data.Webhooks.Payload
import Data.Aeson (FromJSON(..), withObject, withText, (.!=), (.:), (.:?))
import Control.DeepSeq (NFData (..))
import Control.DeepSeq.Generics (genericRnf)
import Control.Applicative ((<|>), (<*>), pure)
import Control.Applicative ((<|>), (<*>), pure, liftA)
import Data.Data (Data, Typeable)
import Data.Functor ((<$>))
import Data.Time (UTCTime)
import Data.Time.LocalTime (zonedTimeToUTC)
import Data.Time.Clock.POSIX (posixSecondsToUTCTime)
import Data.Text (Text)
import qualified Data.Text as T
Expand Down Expand Up @@ -1200,8 +1201,8 @@ instance FromJSON HookMarketplacePurchase where
<*> o .: "billing_cycle"
<*> o .: "unit_count"
<*> o .: "on_free_trial"
<*> o .: "free_trial_ends_on"
<*> o .:? "next_billing_date"
<*> (fmap zonedTimeToUTC <$> o .:? "free_trial_ends_on")
<*> (fmap zonedTimeToUTC <$> o .:? "next_billing_date")
<*> o .: "plan"

instance FromJSON HookMarketplaceAccount where
Expand Down
Loading

0 comments on commit 6bb78fa

Please sign in to comment.