Skip to content

Commit c7c7d61

Browse files
Nick Tchaykanomeata
Nick Tchayka
andauthored
fix: Upgrade to LTS-19.18 (#124)
* Support aeson-2.0 fixes #120 * Fix some stuff for publishing * Fix ci * Remove GHC constraint * Use maintained action --------- Co-authored-by: Joachim Breitner <[email protected]>
1 parent 0031c3e commit c7c7d61

File tree

8 files changed

+110
-50
lines changed

8 files changed

+110
-50
lines changed

.github/workflows/ci.yml

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,43 @@
1-
name: CI
1+
name: Build & test
22

33
on:
44
pull_request:
5-
push:
6-
branches: [master]
5+
branches:
6+
- main
77

88
jobs:
99
build:
1010
runs-on: ubuntu-latest
11+
1112
steps:
12-
13-
# Needed for the add-path command
14-
- name: ACTIONS_ALLOW_UNSECURE_COMMANDS
15-
id: ACTIONS_ALLOW_UNSECURE_COMMANDS
16-
run: echo 'ACTIONS_ALLOW_UNSECURE_COMMANDS=true' >> $GITHUB_ENV
17-
18-
- uses: actions/checkout@v1
19-
20-
- uses: mstksg/setup-stack@v1
21-
22-
- uses: actions/cache@v1
23-
name: Cache ~/.stack
24-
with:
25-
path: ~/.stack
26-
key: ${{ runner.os }}-stack-${{ hashFiles('stack.yaml') }}
27-
restore-keys: |
28-
${{ runner.os }}-stack-
13+
- name: Checkout code
14+
uses: actions/checkout@v2
15+
16+
- uses: haskell/actions/setup@v2
17+
with:
18+
ghc-version: "9.0.2" # Exact version of ghc to use
19+
# cabal-version: 'latest'. Omitted, but defaults to 'latest'
20+
enable-stack: true
21+
stack-version: "2.9.3"
22+
23+
# Attempt to load cached dependencies
24+
- name: Cache Stack dependencies
25+
uses: actions/cache@v2
26+
with:
27+
path: |
28+
~/.stack
29+
.stack-work
30+
key: ${{ runner.os }}-stack-${{ hashFiles('stack.yaml') }}
31+
32+
- name: Build and test
33+
run: |
34+
stack build --test --no-run-tests --bench --no-run-benchmarks --haddock --no-haddock-deps --no-haddock-hyperlink-source --fast
2935
30-
- uses: actions/cache@v1
31-
name: Cache .stack-work
32-
with:
33-
path: .stack-work
34-
key: ${{ runner.os }}-stack-work-${{ hashFiles('stack.yaml') }}-${{ hashFiles('**/*.hs') }}
35-
restore-keys: |
36-
${{ runner.os }}-stack-work-
37-
38-
- name: Compile with Stack
39-
run: stack test --fast
36+
# Save cached dependencies
37+
- name: Cache Stack dependencies
38+
uses: actions/cache@v2
39+
with:
40+
path: |
41+
~/.stack
42+
.stack-work
43+
key: ${{ runner.os }}-stack-${{ hashFiles('stack.yaml') }}

.github/workflows/publish.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Publish Package
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
env:
9+
HACKAGE_USERNAME: ${{ secrets.HACKAGE_USERNAME }}
10+
HACKAGE_PASSWORD: ${{ secrets.HACKAGE_PASSWORD }}
11+
12+
jobs:
13+
publish:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v2
19+
20+
- name: Setup Stack
21+
uses: actions/setup-haskell@v1
22+
with:
23+
ghc-version: 8.10.2
24+
stack-version: 2.5.1
25+
26+
- name: Bump version field
27+
run: |
28+
if grep -q "feat" <<< "$GITHUB_REF"; then
29+
echo "feat: bumping minor version"
30+
stack exec bump-version minor package.yaml
31+
elif grep -q "fix" <<< "$GITHUB_REF"; then
32+
echo "fix: bumping patch version"
33+
stack exec bump-version patch package.yaml
34+
elif grep -q "breaking" <<< "$GITHUB_REF"; then
35+
echo "breaking: bumping major version"
36+
stack exec bump-version major package.yaml
37+
else
38+
echo "no version bump required"
39+
fi
40+
41+
- name: Publish to Hackage
42+
run: |
43+
echo "publishing to hackage"
44+
echo "username: $HACKAGE_USERNAME"
45+
echo "password: $HACKAGE_PASSWORD"
46+
echo "$HACKAGE_PASSWORD" | stack publish --username "$HACKAGE_USERNAME" --password-stdin
47+
48+
- name: Push changes
49+
uses: ad-m/github-push-action@master
50+
with:
51+
branch: main
52+
force: true
53+
env:
54+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

aws-lambda-haskell-runtime.cabal

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cabal-version: 1.12
22

3-
-- This file has been generated from package.yaml by hpack version 0.34.4.
3+
-- This file has been generated from package.yaml by hpack version 0.35.1.
44
--
55
-- see: https://github.com/sol/hpack
66

@@ -13,7 +13,7 @@ homepage: https://github.com/theam/aws-lambda-haskell-runtime#readme
1313
bug-reports: https://github.com/theam/aws-lambda-haskell-runtime/issues
1414
author: Nikita Tchayka
1515
maintainer: [email protected]
16-
copyright: 2021 The Agile Monkeys SL
16+
copyright: 2023 The Agile Monkeys SL
1717
license: Apache-2.0
1818
license-file: LICENSE
1919
build-type: Simple
@@ -58,7 +58,7 @@ library
5858
QuasiQuotes
5959
ghc-options: -Wall -optP-Wno-nonportable-include-path -Wincomplete-uni-patterns -Wincomplete-record-updates -Wcompat -Widentities -Wredundant-constraints -Wmissing-export-lists -Wpartial-fields -fhide-source-paths -freverse-errors
6060
build-depends:
61-
aeson
61+
aeson >2
6262
, base >=4.7 && <5
6363
, bytestring
6464
, case-insensitive

package.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ github: "theam/aws-lambda-haskell-runtime"
44
license: Apache-2.0
55
author: Nikita Tchayka
66
maintainer: [email protected]
7-
copyright: 2021 The Agile Monkeys SL
7+
copyright: 2023 The Agile Monkeys SL
88

99
extra-source-files:
1010
- README.md
@@ -18,7 +18,7 @@ dependencies:
1818

1919
library:
2020
dependencies:
21-
- aeson
21+
- aeson > 2
2222
- bytestring
2323
- http-client
2424
- http-types

src/Aws/Lambda/Runtime/ALB/Types.hs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import Data.Aeson
2727
)
2828
import Data.Aeson.Types (Parser)
2929
import qualified Data.Aeson.Types as T
30+
import qualified Data.Aeson.Key as K
3031
import qualified Data.CaseInsensitive as CI
3132
import Data.HashMap.Strict (HashMap)
3233
import Data.Text (Text)
@@ -59,7 +60,7 @@ instance FromJSON body => FromJSON (ALBRequest body) where
5960
parseJSON = parseALBRequest parseObjectFromStringField
6061

6162
-- We need this because API Gateway is going to send us the payload as a JSON string
62-
parseObjectFromStringField :: FromJSON a => Object -> Text -> Parser (Maybe a)
63+
parseObjectFromStringField :: FromJSON a => Object -> T.Key -> Parser (Maybe a)
6364
parseObjectFromStringField obj fieldName = do
6465
fieldContents <- obj .: fieldName
6566
case fieldContents of
@@ -70,7 +71,7 @@ parseObjectFromStringField obj fieldName = do
7071
Null -> pure Nothing
7172
other -> T.typeMismatch "String or Null" other
7273

73-
parseALBRequest :: (Object -> Text -> Parser (Maybe body)) -> Value -> Parser (ALBRequest body)
74+
parseALBRequest :: (Object -> T.Key -> Parser (Maybe body)) -> Value -> Parser (ALBRequest body)
7475
parseALBRequest bodyParser (Object v) =
7576
ALBRequest
7677
<$> v .: "path"
@@ -167,5 +168,5 @@ mkALBResponse code headers payload =
167168
headerToPair :: Header -> T.Pair
168169
headerToPair (cibyte, bstr) = k .= v
169170
where
170-
k = (T.decodeUtf8 . CI.original) cibyte
171+
k = (K.fromText . T.decodeUtf8 . CI.original) cibyte
171172
v = T.decodeUtf8 bstr

src/Aws/Lambda/Runtime/APIGateway/Types.hs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import Data.Aeson
2929
(.:?)
3030
)
3131
import Data.Aeson.Types (Parser)
32+
import qualified Data.Aeson.Key as K
3233
import qualified Data.Aeson.Types as T
3334
import qualified Data.CaseInsensitive as CI
3435
import Data.HashMap.Strict (HashMap)
@@ -70,7 +71,7 @@ instance FromJSON body => FromJSON (ApiGatewayRequest body) where
7071
parseJSON = parseApiGatewayRequest parseObjectFromStringField
7172

7273
-- We need this because API Gateway is going to send us the payload as a JSON string
73-
parseObjectFromStringField :: FromJSON a => Object -> Text -> Parser (Maybe a)
74+
parseObjectFromStringField :: FromJSON a => Object -> T.Key -> Parser (Maybe a)
7475
parseObjectFromStringField obj fieldName = do
7576
fieldContents <- obj .: fieldName
7677
case fieldContents of
@@ -81,7 +82,7 @@ parseObjectFromStringField obj fieldName = do
8182
Null -> pure Nothing
8283
other -> T.typeMismatch "String or Null" other
8384

84-
parseApiGatewayRequest :: (Object -> Text -> Parser (Maybe body)) -> Value -> Parser (ApiGatewayRequest body)
85+
parseApiGatewayRequest :: (Object -> T.Key -> Parser (Maybe body)) -> Value -> Parser (ApiGatewayRequest body)
8586
parseApiGatewayRequest bodyParser (Object v) =
8687
ApiGatewayRequest
8788
<$> v .: "resource"
@@ -215,5 +216,5 @@ mkApiGatewayResponse code headers payload =
215216
headerToPair :: Header -> T.Pair
216217
headerToPair (cibyte, bstr) = k .= v
217218
where
218-
k = (T.decodeUtf8 . CI.original) cibyte
219+
k = (K.fromText . T.decodeUtf8 . CI.original) cibyte
219220
v = T.decodeUtf8 bstr

stack.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#
1818
# resolver: ./custom-snapshot.yaml
1919
# resolver: https://example.com/snapshots/2018-01-01.yaml
20-
resolver: lts-16.12
20+
resolver: lts-19.18
2121

2222
# User packages to be built.
2323
# Various formats can be used as shown in the example below.

stack.yaml.lock

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,34 @@ packages:
77
- completed:
88
hackage: require-0.4.2@sha256:f28dc58dd927e98a709dd926ace92704c09db34dd33a278e1d5aa22cac133984,3625
99
pantry-tree:
10-
size: 718
1110
sha256: 1fe2c5947db887175c819c3a0a55d9dcbb5823d28d0a5f588ea1db2d370bd1e1
11+
size: 718
1212
original:
1313
hackage: require-0.4.2
1414
- completed:
1515
hackage: cheapskate-0.1.1.2@sha256:b8ae3cbb826610ea45e6840b7fde0af2c2ea6690cb311edfe9683f61c0a50d96,3072
1616
pantry-tree:
17-
size: 866
1817
sha256: f3d8b45723bf9851163e50b900b5397e22dca07af70c2c6145a5aea34e3a0e49
18+
size: 866
1919
original:
2020
hackage: cheapskate-0.1.1.2@sha256:b8ae3cbb826610ea45e6840b7fde0af2c2ea6690cb311edfe9683f61c0a50d96,3072
2121
- completed:
2222
hackage: inliterate-0.1.0@sha256:61b17ab3cef803512c264e27e463390b47af59d7d2b3a2a89bea2eac0cf84266,1853
2323
pantry-tree:
24-
size: 618
2524
sha256: 2cea999a63449b913f6186c3b8b276050e7a1a7195f5e94ac94fa4007da36558
25+
size: 618
2626
original:
2727
hackage: inliterate-0.1.0@sha256:61b17ab3cef803512c264e27e463390b47af59d7d2b3a2a89bea2eac0cf84266,1853
2828
- completed:
2929
hackage: megaparsec-7.0.5@sha256:45e1f1348fab2783646fdb4d9e6097568981a740951c7356d36d794e2baba305,3902
3030
pantry-tree:
31-
size: 1428
3231
sha256: 1f8baf6e07326f8c8a2dd31de6b2860427f158b0892c52ba5fe9ffeb6cd3bf7f
32+
size: 1428
3333
original:
3434
hackage: megaparsec-7.0.5@sha256:45e1f1348fab2783646fdb4d9e6097568981a740951c7356d36d794e2baba305,3902
3535
snapshots:
3636
- completed:
37-
size: 532377
38-
url: https://github.com/raw/commercialhaskell/stackage-snapshots/master/lts/16/12.yaml
39-
sha256: f914cfa23fef85bdf895e300a8234d9d0edc2dbec67f4bc9c53f85867c50eab6
40-
original: lts-16.12
37+
sha256: 65b9809265860e085b4f61d4eb00d5d73e41190693620385a69cc9d9df7a901d
38+
size: 619164
39+
url: https://github.com/raw/commercialhaskell/stackage-snapshots/master/lts/19/18.yaml
40+
original: lts-19.18

0 commit comments

Comments
 (0)