Skip to content

Commit

Permalink
Merge pull request #98 from brandonchinn178/ghc-9.12
Browse files Browse the repository at this point in the history
Support GHC 9.10 + 9.12
  • Loading branch information
brandonchinn178 authored Jan 19, 2025
2 parents ab1bcb9 + 36abc09 commit 94aa7e0
Show file tree
Hide file tree
Showing 20 changed files with 236 additions and 122 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
-
name: Convert coverage output
run: |
HPC_LCOV_VERSION=1.1.1
HPC_LCOV_VERSION=1.2.0
curl -fsSL \
"https://github.com/brandonchinn178/hpc-lcov/releases/download/v${HPC_LCOV_VERSION}/hpc-lcov-${HPC_LCOV_VERSION}-linux-x86_64" \
-o /usr/local/bin/hpc-lcov
Expand All @@ -42,11 +42,11 @@ jobs:
strategy:
matrix:
ghc_version:
- '9.4'
- '9.6'
- '9.8'
- '9.10'
- '9.12'
include:
- ghc_version: 9.4.1
- ghc_version: 9.8.1
oldest: true

name: ghc_compat_test (${{ matrix.ghc_version }})
Expand Down
30 changes: 28 additions & 2 deletions .github/workflows/ghc-compat-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ jobs:
-
id: setup
name: Set up GHC ${{ inputs.ghc_version }}
uses: brandonchinn178/haskell-actions-setup@3f2715436c49e3e1c7b19450d595348512bbe8eb
uses: haskell-actions/setup@v2
with:
ghc-version: ${{ inputs.ghc_version }}
ghcup-release-channels: https://ghc.gitlab.haskell.org/ghcup-metadata/ghcup-nightlies-0.0.7.yaml
cabal-version: '3.10'
ghcup-release-channel: https://ghc.gitlab.haskell.org/ghcup-metadata/ghcup-nightlies-0.0.7.yaml
-
name: Configure the build
run:
Expand All @@ -31,12 +32,37 @@ jobs:
--enable-bench
--test-options=--color=always
--test-show-details=streaming
-
# TODO: remove when packages are updated
name: Allow building deps with GHC 9.12
run:
cabal configure --enable-append
--allow-newer=aeson:ghc-prim
--allow-newer=aeson:template-haskell
--allow-newer=binary-orphans:base
--allow-newer=haskell-src-meta:template-haskell
--allow-newer=indexed-traversable-instances:base
--allow-newer=indexed-traversable:base
--allow-newer=integer-conversion:base
--allow-newer=microstache:base
--allow-newer=scientific:base
--allow-newer=scientific:template-haskell
--allow-newer=semialign:base
--allow-newer=text:deepseq
--allow-newer=these:base
--allow-newer=time-compat:base
--allow-newer=time-compat:time
--allow-newer=unordered-containers:template-haskell
--allow-newer=uuid-types:template-haskell
-
if: ${{ inputs.oldest }}
name: Use oldest dependencies
# https://github.com/pcapriotti/optparse-applicative/issues/497
run:
cabal configure --enable-append
--prefer-oldest
--constraint='prettyprinter-ansi-terminal >= 1.1.2'
--constraint='haskell-src-meta >= 0.8.13'
-
if: ${{ inputs.ghc_version == 'latest-nightly' }}
name: Add head.hackage
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Unreleased

# v1.4.3.0

* Drop support for GHC 9.4 + 9.6
* Add support for GHC 9.10 + 9.12

# v1.4.2.1

* Fix benchmarks for GHC 9.8
Expand Down
7 changes: 7 additions & 0 deletions DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ stack build

# with haddock
stack build --haddock

# with cabal
cabal build --ghc-options -Werror
```

## Lint
Expand All @@ -28,6 +31,10 @@ All tests must pass CI in order for your PR to be accepted.

```bash
stack test
# Note: use the global GHC; integration tests will not work with
# --with-compiler set differently
cabal exec -- cabal test
```

# Documentation
Expand Down
12 changes: 5 additions & 7 deletions aeson-schemas.cabal
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
cabal-version: >= 1.10

-- This file has been generated from package.yaml by hpack version 0.36.0.
-- This file has been generated from package.yaml by hpack version 0.37.0.
--
-- see: https://github.com/sol/hpack

name: aeson-schemas
version: 1.4.2.1
version: 1.4.3.0
synopsis: Easily consume JSON data on-demand with type-safety
description: Parse JSON data easily and safely without defining new data types. Useful
for deeply nested JSON data, which is difficult to parse using the default
Expand Down Expand Up @@ -39,10 +39,9 @@ extra-source-files:
test/goldens/getqq_no_operators.golden
test/goldens/getqq_ops_after_list.golden
test/goldens/getqq_ops_after_tuple.golden
test/goldens/ghc/9.4/getqq_missing_key.golden
test/goldens/ghc/9.6/getqq_missing_key.golden
test/goldens/ghc/9.10/getqq_missing_key.golden
test/goldens/ghc/9.12/getqq_missing_key.golden
test/goldens/ghc/9.8/getqq_missing_key.golden
test/goldens/ghc/9.9/getqq_missing_key.golden
test/goldens/README_Quickstart.golden
test/goldens/schemaqq_key_with_invalid_character.golden
test/goldens/schemaqq_key_with_trailing_escape.golden
Expand Down Expand Up @@ -84,7 +83,7 @@ library
, first-class-families <0.9
, hashable <1.6
, megaparsec <10
, template-haskell <2.22
, template-haskell <2.24
, text <2.2
, unordered-containers <0.3
default-language: Haskell2010
Expand Down Expand Up @@ -125,7 +124,6 @@ test-suite aeson-schemas-test
, base
, deepseq
, filepath
, hint
, interpolate
, process
, raw-strings-qq
Expand Down
18 changes: 5 additions & 13 deletions bench/Utils/DeepSeq.hs
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,14 @@ instance NFData Type
instance NFData TypeFamilyHead
instance NFData TyLit
instance NFData TySynEqn

#if MIN_VERSION_template_haskell(2,17,0)
instance NFData Specificity
#endif

#if MIN_VERSION_template_haskell(2,17,0)
instance NFData flag => NFData (TyVarBndr flag)
#else
instance NFData TyVarBndr
#endif

#if MIN_VERSION_template_haskell(2,21,0)
instance (NFData flag) => NFData (TyVarBndr flag)
instance NFData BndrVis
#endif

instance NFData Bytes

#if MIN_VERSION_template_haskell(2,22,0)
instance NFData NamespaceSpecifier
#endif

instance NFData (ForeignPtr a) where
rnf = rwhnf
5 changes: 2 additions & 3 deletions package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: aeson-schemas
version: 1.4.2.1
version: 1.4.3.0
verbatim:
cabal-version: '>= 1.10'
license: BSD3
Expand Down Expand Up @@ -47,7 +47,7 @@ library:
- first-class-families < 0.9
- hashable < 1.6
- megaparsec < 10
- template-haskell < 2.22
- template-haskell < 2.24
- text < 2.2
- unordered-containers < 0.3

Expand All @@ -62,7 +62,6 @@ tests:
- base
- deepseq
- filepath
- hint
- interpolate
- process
- QuickCheck
Expand Down
5 changes: 0 additions & 5 deletions src/Data/Aeson/Schema/TH/Utils.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE LambdaCase #-}
Expand Down Expand Up @@ -197,10 +196,8 @@ stripKinds ty =
AppT ty1 ty2 -> AppT (stripKinds ty1) (stripKinds ty2)
InfixT ty1 name ty2 -> InfixT (stripKinds ty1) name (stripKinds ty2)
UInfixT ty1 name ty2 -> UInfixT (stripKinds ty1) name (stripKinds ty2)
#if MIN_VERSION_template_haskell(2,19,0)
PromotedInfixT ty1 name ty2 -> PromotedInfixT (stripKinds ty1) name (stripKinds ty2)
PromotedUInfixT ty1 name ty2 -> PromotedUInfixT (stripKinds ty1) name (stripKinds ty2)
#endif
ParensT ty1 -> ParensT (stripKinds ty1)
ImplicitParamT str ty1 -> ImplicitParamT str (stripKinds ty1)

Expand All @@ -212,9 +209,7 @@ stripKinds ty =
UnboxedTupleT _ -> ty
UnboxedSumT _ -> ty
ArrowT -> ty
#if MIN_VERSION_template_haskell(2,17,0)
MulArrowT -> ty
#endif
EqualityT -> ty
ListT -> ty
PromotedTupleT _ -> ty
Expand Down
3 changes: 3 additions & 0 deletions src/Data/Aeson/Schema/Utils/Compat.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ module Data.Aeson.Schema.Utils.Compat (
unions,
) where

#if !MIN_VERSION_base(4,20,0)
import Data.List (foldl')
#endif

import Data.Text (Text)
import Prelude hiding (lookup)

Expand Down
5 changes: 4 additions & 1 deletion stack.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
resolver: lts-22.28
resolver: nightly-2024-12-20

extra-deps:
- th-test-utils-1.2.2
17 changes: 12 additions & 5 deletions stack.yaml.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,17 @@
# For more information, please see the documentation at:
# https://docs.haskellstack.org/en/stable/lock_files

packages: []
packages:
- completed:
hackage: th-test-utils-1.2.2@sha256:d7b02eb9d2613e5e624298826ba03d4c11e18fa2fb8d4e378569224ae687fc4e,2193
pantry-tree:
sha256: eacb82118c7a96fc0e4ee9a45e3283155987b13fa21b8f65954acb1a55cdf50f
size: 620
original:
hackage: th-test-utils-1.2.2
snapshots:
- completed:
sha256: 87da71cb0ae9ee1ea1bf51a8eb9812f39f779be76abc0a3c926defd8afda05d1
size: 719139
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/22/28.yaml
original: lts-22.28
sha256: 2413f1dbf803da9cab3b6970d868cf7cd4c013b8776dee3cebd8b8ecbf85514c
size: 619614
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/nightly/2024/12/20.yaml
original: nightly-2024-12-20
14 changes: 7 additions & 7 deletions test/TestUtils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module TestUtils (
testGoldenIO,
testParseError,
ghcGoldenDir,
ghcVersion,
) where

import Data.Aeson (FromJSON (..), Value, eitherDecode)
Expand All @@ -34,6 +35,7 @@ import qualified Data.Text.IO as Text
import qualified Data.Text.Lazy as TextL
import qualified Data.Text.Lazy.Encoding as TextL
import Data.Typeable (Typeable, typeRep)
import Data.Version (Version, makeVersion, showVersion, versionBranch)
import Language.Haskell.TH (ExpQ)
import Language.Haskell.TH.Quote (QuasiQuoter (..))
import System.FilePath ((</>))
Expand Down Expand Up @@ -111,11 +113,9 @@ testParseError name fp s = goldenTest name getExpected getActual cmp update

-- | The directory to put GHC version-specific golden files.
ghcGoldenDir :: FilePath
ghcGoldenDir = "ghc" </> ghcVersion
ghcGoldenDir = "ghc" </> showVersion ghcMinorVersion
where
ghcVersion =
Text.unpack
. Text.intercalate "."
. take 2
. Text.splitOn "."
$ __GLASGOW_HASKELL_FULL_VERSION__
ghcMinorVersion = makeVersion . take 2 . versionBranch $ ghcVersion

ghcVersion :: Version
ghcVersion = makeVersion . map (read . Text.unpack) $ Text.splitOn "." __GLASGOW_HASKELL_FULL_VERSION__
18 changes: 5 additions & 13 deletions test/TestUtils/DeepSeq.hs
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,14 @@ instance NFData Type
instance NFData TypeFamilyHead
instance NFData TyLit
instance NFData TySynEqn

#if MIN_VERSION_template_haskell(2,17,0)
instance NFData Specificity
#endif

#if MIN_VERSION_template_haskell(2,17,0)
instance NFData flag => NFData (TyVarBndr flag)
#else
instance NFData TyVarBndr
#endif

#if MIN_VERSION_template_haskell(2,20,0) && __GLASGOW_HASKELL__ >= 907
instance (NFData flag) => NFData (TyVarBndr flag)
instance NFData BndrVis
#endif

instance NFData Bytes

#if MIN_VERSION_template_haskell(2,22,0)
instance NFData NamespaceSpecifier
#endif

instance NFData (ForeignPtr a) where
rnf = rwhnf
31 changes: 23 additions & 8 deletions test/Tests/GetQQ.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
Expand All @@ -13,21 +12,23 @@
module Tests.GetQQ where

import Control.DeepSeq (deepseq)
import Control.Exception (SomeException, displayException, try)
import Control.Exception (SomeException, try)
import Data.Aeson (FromJSON (..), ToJSON (..), withText)
import Data.Aeson.QQ (aesonQQ)
import Data.Text (Text)
import qualified Data.Text as Text
import qualified Language.Haskell.Interpreter as Hint
import Data.Version (makeVersion)
import System.Exit (ExitCode (..))
import System.FilePath ((</>))
import System.Process (readProcessWithExitCode)
import Test.Tasty
import Test.Tasty.HUnit
import Test.Tasty.QuickCheck

import Data.Aeson.Schema (Object, schema)
import Data.Aeson.Schema.TH (mkEnum)
import Data.Aeson.Schema.Utils.Sum (SumType (..))
import TestUtils (ghcGoldenDir, parseObject, testGoldenIO, testParseError)
import TestUtils (ghcGoldenDir, ghcVersion, parseObject, testGoldenIO, testParseError)
import Tests.GetQQ.TH

mkEnum "Greeting" ["HELLO", "GOODBYE"]
Expand Down Expand Up @@ -401,10 +402,24 @@ testCompileTimeErrors =
]
where
testDir = "test/wont-compile/"
getCompileError fp =
Hint.runInterpreter (Hint.loadModules [fp]) >>= \case
Left e -> pure $ displayException e
Right _ -> error "Compilation unexpectedly succeeded"
getCompileError fp = do
let args =
concat
[ [fp]
, -- https://gitlab.haskell.org/ghc/ghc/-/issues/25602
if ghcVersion < makeVersion [9, 10]
then []
else ["-package", "ghc-internal"]
]
(code, stdout, stderr) <- readProcessWithExitCode "ghc" args ""
case code of
ExitFailure _ -> pure stderr
ExitSuccess ->
error . unlines $
[ "Unexpectedly succeeded:"
, stdout
, stderr
]

{- Helpers -}

Expand Down
Loading

0 comments on commit 94aa7e0

Please sign in to comment.