diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bad7f12..a11f5ad 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,39 +1,43 @@ -name: CI +name: Build & test on: pull_request: - push: - branches: [master] + branches: + - main jobs: build: runs-on: ubuntu-latest + steps: - - # Needed for the add-path command - - name: ACTIONS_ALLOW_UNSECURE_COMMANDS - id: ACTIONS_ALLOW_UNSECURE_COMMANDS - run: echo 'ACTIONS_ALLOW_UNSECURE_COMMANDS=true' >> $GITHUB_ENV - - - uses: actions/checkout@v1 - - - uses: mstksg/setup-stack@v1 - - - uses: actions/cache@v1 - name: Cache ~/.stack - with: - path: ~/.stack - key: ${{ runner.os }}-stack-${{ hashFiles('stack.yaml') }} - restore-keys: | - ${{ runner.os }}-stack- + - name: Checkout code + uses: actions/checkout@v2 + + - uses: haskell/actions/setup@v2 + with: + ghc-version: "9.0.2" # Exact version of ghc to use + # cabal-version: 'latest'. Omitted, but defaults to 'latest' + enable-stack: true + stack-version: "2.9.3" + + # Attempt to load cached dependencies + - name: Cache Stack dependencies + uses: actions/cache@v2 + with: + path: | + ~/.stack + .stack-work + key: ${{ runner.os }}-stack-${{ hashFiles('stack.yaml') }} + + - name: Build and test + run: | + stack build --test --no-run-tests --bench --no-run-benchmarks --haddock --no-haddock-deps --no-haddock-hyperlink-source --fast - - uses: actions/cache@v1 - name: Cache .stack-work - with: - path: .stack-work - key: ${{ runner.os }}-stack-work-${{ hashFiles('stack.yaml') }}-${{ hashFiles('**/*.hs') }} - restore-keys: | - ${{ runner.os }}-stack-work- - - - name: Compile with Stack - run: stack test --fast \ No newline at end of file + # Save cached dependencies + - name: Cache Stack dependencies + uses: actions/cache@v2 + with: + path: | + ~/.stack + .stack-work + key: ${{ runner.os }}-stack-${{ hashFiles('stack.yaml') }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..b8311ac --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,54 @@ +name: Publish Package + +on: + push: + branches: + - main + +env: + HACKAGE_USERNAME: ${{ secrets.HACKAGE_USERNAME }} + HACKAGE_PASSWORD: ${{ secrets.HACKAGE_PASSWORD }} + +jobs: + publish: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Setup Stack + uses: actions/setup-haskell@v1 + with: + ghc-version: 8.10.2 + stack-version: 2.5.1 + + - name: Bump version field + run: | + if grep -q "feat" <<< "$GITHUB_REF"; then + echo "feat: bumping minor version" + stack exec bump-version minor package.yaml + elif grep -q "fix" <<< "$GITHUB_REF"; then + echo "fix: bumping patch version" + stack exec bump-version patch package.yaml + elif grep -q "breaking" <<< "$GITHUB_REF"; then + echo "breaking: bumping major version" + stack exec bump-version major package.yaml + else + echo "no version bump required" + fi + + - name: Publish to Hackage + run: | + echo "publishing to hackage" + echo "username: $HACKAGE_USERNAME" + echo "password: $HACKAGE_PASSWORD" + echo "$HACKAGE_PASSWORD" | stack publish --username "$HACKAGE_USERNAME" --password-stdin + + - name: Push changes + uses: ad-m/github-push-action@master + with: + branch: main + force: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/aws-lambda-haskell-runtime.cabal b/aws-lambda-haskell-runtime.cabal index 7fd44db..ba3accb 100644 --- a/aws-lambda-haskell-runtime.cabal +++ b/aws-lambda-haskell-runtime.cabal @@ -1,6 +1,6 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.34.4. +-- This file has been generated from package.yaml by hpack version 0.35.1. -- -- see: https://github.com/sol/hpack @@ -13,7 +13,7 @@ homepage: https://github.com/theam/aws-lambda-haskell-runtime#readme bug-reports: https://github.com/theam/aws-lambda-haskell-runtime/issues author: Nikita Tchayka maintainer: hackers@theagilemonkeys.com -copyright: 2021 The Agile Monkeys SL +copyright: 2023 The Agile Monkeys SL license: Apache-2.0 license-file: LICENSE build-type: Simple @@ -58,7 +58,7 @@ library QuasiQuotes 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 build-depends: - aeson + aeson >2 , base >=4.7 && <5 , bytestring , case-insensitive diff --git a/package.yaml b/package.yaml index 1770d15..2b339a2 100644 --- a/package.yaml +++ b/package.yaml @@ -4,7 +4,7 @@ github: "theam/aws-lambda-haskell-runtime" license: Apache-2.0 author: Nikita Tchayka maintainer: hackers@theagilemonkeys.com -copyright: 2021 The Agile Monkeys SL +copyright: 2023 The Agile Monkeys SL extra-source-files: - README.md @@ -18,7 +18,7 @@ dependencies: library: dependencies: - - aeson + - aeson > 2 - bytestring - http-client - http-types diff --git a/src/Aws/Lambda/Runtime/ALB/Types.hs b/src/Aws/Lambda/Runtime/ALB/Types.hs index 16117e7..c97765d 100644 --- a/src/Aws/Lambda/Runtime/ALB/Types.hs +++ b/src/Aws/Lambda/Runtime/ALB/Types.hs @@ -27,6 +27,7 @@ import Data.Aeson ) import Data.Aeson.Types (Parser) import qualified Data.Aeson.Types as T +import qualified Data.Aeson.Key as K import qualified Data.CaseInsensitive as CI import Data.HashMap.Strict (HashMap) import Data.Text (Text) @@ -59,7 +60,7 @@ instance FromJSON body => FromJSON (ALBRequest body) where parseJSON = parseALBRequest parseObjectFromStringField -- We need this because API Gateway is going to send us the payload as a JSON string -parseObjectFromStringField :: FromJSON a => Object -> Text -> Parser (Maybe a) +parseObjectFromStringField :: FromJSON a => Object -> T.Key -> Parser (Maybe a) parseObjectFromStringField obj fieldName = do fieldContents <- obj .: fieldName case fieldContents of @@ -70,7 +71,7 @@ parseObjectFromStringField obj fieldName = do Null -> pure Nothing other -> T.typeMismatch "String or Null" other -parseALBRequest :: (Object -> Text -> Parser (Maybe body)) -> Value -> Parser (ALBRequest body) +parseALBRequest :: (Object -> T.Key -> Parser (Maybe body)) -> Value -> Parser (ALBRequest body) parseALBRequest bodyParser (Object v) = ALBRequest <$> v .: "path" @@ -167,5 +168,5 @@ mkALBResponse code headers payload = headerToPair :: Header -> T.Pair headerToPair (cibyte, bstr) = k .= v where - k = (T.decodeUtf8 . CI.original) cibyte + k = (K.fromText . T.decodeUtf8 . CI.original) cibyte v = T.decodeUtf8 bstr diff --git a/src/Aws/Lambda/Runtime/APIGateway/Types.hs b/src/Aws/Lambda/Runtime/APIGateway/Types.hs index 4c3acb9..d4e83ee 100644 --- a/src/Aws/Lambda/Runtime/APIGateway/Types.hs +++ b/src/Aws/Lambda/Runtime/APIGateway/Types.hs @@ -29,6 +29,7 @@ import Data.Aeson (.:?) ) import Data.Aeson.Types (Parser) +import qualified Data.Aeson.Key as K import qualified Data.Aeson.Types as T import qualified Data.CaseInsensitive as CI import Data.HashMap.Strict (HashMap) @@ -70,7 +71,7 @@ instance FromJSON body => FromJSON (ApiGatewayRequest body) where parseJSON = parseApiGatewayRequest parseObjectFromStringField -- We need this because API Gateway is going to send us the payload as a JSON string -parseObjectFromStringField :: FromJSON a => Object -> Text -> Parser (Maybe a) +parseObjectFromStringField :: FromJSON a => Object -> T.Key -> Parser (Maybe a) parseObjectFromStringField obj fieldName = do fieldContents <- obj .: fieldName case fieldContents of @@ -81,7 +82,7 @@ parseObjectFromStringField obj fieldName = do Null -> pure Nothing other -> T.typeMismatch "String or Null" other -parseApiGatewayRequest :: (Object -> Text -> Parser (Maybe body)) -> Value -> Parser (ApiGatewayRequest body) +parseApiGatewayRequest :: (Object -> T.Key -> Parser (Maybe body)) -> Value -> Parser (ApiGatewayRequest body) parseApiGatewayRequest bodyParser (Object v) = ApiGatewayRequest <$> v .: "resource" @@ -215,5 +216,5 @@ mkApiGatewayResponse code headers payload = headerToPair :: Header -> T.Pair headerToPair (cibyte, bstr) = k .= v where - k = (T.decodeUtf8 . CI.original) cibyte + k = (K.fromText . T.decodeUtf8 . CI.original) cibyte v = T.decodeUtf8 bstr diff --git a/stack.yaml b/stack.yaml index d7e3669..9c95253 100644 --- a/stack.yaml +++ b/stack.yaml @@ -17,7 +17,7 @@ # # resolver: ./custom-snapshot.yaml # resolver: https://example.com/snapshots/2018-01-01.yaml -resolver: lts-16.12 +resolver: lts-19.18 # User packages to be built. # Various formats can be used as shown in the example below. diff --git a/stack.yaml.lock b/stack.yaml.lock index f827d6a..31ecc5e 100644 --- a/stack.yaml.lock +++ b/stack.yaml.lock @@ -7,34 +7,34 @@ packages: - completed: hackage: require-0.4.2@sha256:f28dc58dd927e98a709dd926ace92704c09db34dd33a278e1d5aa22cac133984,3625 pantry-tree: - size: 718 sha256: 1fe2c5947db887175c819c3a0a55d9dcbb5823d28d0a5f588ea1db2d370bd1e1 + size: 718 original: hackage: require-0.4.2 - completed: hackage: cheapskate-0.1.1.2@sha256:b8ae3cbb826610ea45e6840b7fde0af2c2ea6690cb311edfe9683f61c0a50d96,3072 pantry-tree: - size: 866 sha256: f3d8b45723bf9851163e50b900b5397e22dca07af70c2c6145a5aea34e3a0e49 + size: 866 original: hackage: cheapskate-0.1.1.2@sha256:b8ae3cbb826610ea45e6840b7fde0af2c2ea6690cb311edfe9683f61c0a50d96,3072 - completed: hackage: inliterate-0.1.0@sha256:61b17ab3cef803512c264e27e463390b47af59d7d2b3a2a89bea2eac0cf84266,1853 pantry-tree: - size: 618 sha256: 2cea999a63449b913f6186c3b8b276050e7a1a7195f5e94ac94fa4007da36558 + size: 618 original: hackage: inliterate-0.1.0@sha256:61b17ab3cef803512c264e27e463390b47af59d7d2b3a2a89bea2eac0cf84266,1853 - completed: hackage: megaparsec-7.0.5@sha256:45e1f1348fab2783646fdb4d9e6097568981a740951c7356d36d794e2baba305,3902 pantry-tree: - size: 1428 sha256: 1f8baf6e07326f8c8a2dd31de6b2860427f158b0892c52ba5fe9ffeb6cd3bf7f + size: 1428 original: hackage: megaparsec-7.0.5@sha256:45e1f1348fab2783646fdb4d9e6097568981a740951c7356d36d794e2baba305,3902 snapshots: - completed: - size: 532377 - url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/16/12.yaml - sha256: f914cfa23fef85bdf895e300a8234d9d0edc2dbec67f4bc9c53f85867c50eab6 - original: lts-16.12 + sha256: 65b9809265860e085b4f61d4eb00d5d73e41190693620385a69cc9d9df7a901d + size: 619164 + url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/19/18.yaml + original: lts-19.18