From 59ce1d3d6957142d01c379798a76572ccc5613ec Mon Sep 17 00:00:00 2001 From: John Ky Date: Wed, 10 Jan 2024 14:51:03 +1100 Subject: [PATCH] Update CI --- .github/workflows/haskell.yml | 26 +++++++------- .vscode/tasks.json | 4 +-- hw-xml.cabal | 22 ++++++------ src/HaskellWorks/Data/Xml/RawValue.hs | 49 +++++++++++++++++---------- 4 files changed, 59 insertions(+), 42 deletions(-) diff --git a/.github/workflows/haskell.yml b/.github/workflows/haskell.yml index c646fc3..2837190 100644 --- a/.github/workflows/haskell.yml +++ b/.github/workflows/haskell.yml @@ -17,24 +17,30 @@ jobs: strategy: fail-fast: false matrix: - ghc: ["9.2.2", "9.0.2", "8.10.7", "8.8.4", "8.6.5"] + ghc: ["9.8.1", "9.6.3", "9.4.8", "9.2.8", "9.0.2", "8.10.7"] os: [ubuntu-latest, macOS-latest, windows-latest] + env: + # Modify this value to "invalidate" the cabal cache. + CABAL_CACHE_VERSION: "2024-01-05" + steps: - uses: actions/checkout@v2 - - uses: haskell/actions/setup@v1 + - uses: haskell-actions/setup@v2 id: setup-haskell with: ghc-version: ${{ matrix.ghc }} - cabal-version: 3.6.2.0 + cabal-version: '3.10.2.1' - name: Set some window specific things if: matrix.os == 'windows-latest' run: echo 'EXE_EXT=.exe' >> $GITHUB_ENV - name: Configure project - run: cabal configure --enable-tests --enable-benchmarks --write-ghc-environment-files=ghc8.4.4+ + run: | + cabal configure --enable-tests --enable-benchmarks --write-ghc-environment-files=ghc8.4.4+ + cabal build all --enable-tests --enable-benchmarks --dry-run - name: Cabal cache over S3 uses: action-works/cabal-cache-s3@v1 @@ -46,7 +52,7 @@ jobs: dist-dir: dist-newstyle store-path: ${{ steps.setup-haskell.outputs.cabal-store }} threads: 16 - archive-uri: ${{ secrets.BINARY_CACHE_URI }} + archive-uri: ${{ secrets.BINARY_CACHE_URI }}/${{ env.CABAL_CACHE_VERSION }}/${{ runner.os }}/${{ matrix.cabal }}/${{ matrix.ghc }} skip: "${{ secrets.BINARY_CACHE_URI == '' }}" - name: Cabal cache over HTTPS @@ -55,18 +61,14 @@ jobs: dist-dir: dist-newstyle store-path: ${{ steps.setup-haskell.outputs.cabal-store }} threads: 16 - archive-uri: https://cache.haskellworks.io/archive + archive-uri: https://cache.haskellworks.io/${{ env.CABAL_CACHE_VERSION }}/${{ runner.os }}/${{ matrix.cabal }}/${{ matrix.ghc }} skip: "${{ secrets.BINARY_CACHE_URI != '' }}" - name: Build - # Try building it twice in case of flakey builds on Windows - run: | - cabal build all --enable-tests --enable-benchmarks --write-ghc-environment-files=ghc8.4.4+ || \ - cabal build all --enable-tests --enable-benchmarks --write-ghc-environment-files=ghc8.4.4+ -j1 + run: cabal build all --enable-tests --enable-benchmarks - name: Test - run: | - cabal test all --enable-tests --enable-benchmarks --write-ghc-environment-files=ghc8.4.4+ + run: cabal test all --enable-tests --enable-benchmarks check: needs: build diff --git a/.vscode/tasks.json b/.vscode/tasks.json index f6d86eb..dc24b1f 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -5,7 +5,7 @@ "label": "Build", "type": "shell", "command": "bash", - "args": ["-lc", "./project.sh build && echo 'Done'"], + "args": ["-lc", "cabal build all --enable-tests && echo 'Done'"], "group": { "kind": "build", "isDefault": true @@ -37,7 +37,7 @@ "label": "Test", "type": "shell", "command": "bash", - "args": ["-lc", "./project.sh test && echo 'Done'"], + "args": ["-lc", "cabal test all --enable-tests && echo 'Done'"], "group": { "kind": "test", "isDefault": true diff --git a/hw-xml.cabal b/hw-xml.cabal index 2a09b3b..80e7efb 100644 --- a/hw-xml.cabal +++ b/hw-xml.cabal @@ -25,19 +25,19 @@ source-repository head common base { build-depends: base >= 4.11 && < 5 } -common ansi-wl-pprint { build-depends: ansi-wl-pprint >= 0.6.9 && < 0.7 } +common prettyprinter { build-depends: prettyprinter >= 0.6.9 && < 2 } common array { build-depends: array >= 0.5.2.0 && < 0.6 } common attoparsec { build-depends: attoparsec >= 0.13.2.2 && < 0.15 } -common bytestring { build-depends: bytestring >= 0.10.8.2 && < 0.12 } +common bytestring { build-depends: bytestring >= 0.10.8.2 && < 0.13 } common cereal { build-depends: cereal >= 0.5.8.1 && < 0.6 } -common containers { build-depends: containers >= 0.5.10.2 && < 0.7 } +common containers { build-depends: containers >= 0.5.10.2 && < 0.8 } common criterion { build-depends: criterion >= 1.5.5.0 && < 1.7 } -common deepseq { build-depends: deepseq >= 1.4.3.0 && < 1.5 } -common doctest { build-depends: doctest >= 0.16.2 && < 0.21 } +common deepseq { build-depends: deepseq >= 1.4.3.0 && < 1.6 } +common doctest { build-depends: doctest >= 0.16.2 && < 0.23 } common doctest-discover { build-depends: doctest-discover >= 0.2 && < 0.3 } common generic-lens { build-depends: generic-lens >= 2.2 && < 2.3 } -common ghc-prim { build-depends: ghc-prim >= 0.5 && < 0.10 } -common hedgehog { build-depends: hedgehog >= 1.0 && < 1.3 } +common ghc-prim { build-depends: ghc-prim >= 0.5 && < 0.12 } +common hedgehog { build-depends: hedgehog >= 1.0 && < 1.5 } common hspec { build-depends: hspec >= 2.5 && < 3 } common hw-balancedparens { build-depends: hw-balancedparens >= 0.3.0.1 && < 0.5 } common hw-bits { build-depends: hw-bits >= 0.7.0.9 && < 0.8 } @@ -49,9 +49,9 @@ common hw-rankselect-base { build-depends: hw-rankselect-base >= common lens { build-depends: lens >= 4.17.1 && < 6 } common mmap { build-depends: mmap >= 0.5.9 && < 0.6 } common mtl { build-depends: mtl >= 2.2.2 && < 3 } -common optparse-applicative { build-depends: optparse-applicative >= 0.15.1.0 && < 0.18 } -common resourcet { build-depends: resourcet >= 1.2.2 && < 1.3 } -common text { build-depends: text >= 1.2.3.2 && < 2 } +common optparse-applicative { build-depends: optparse-applicative >= 0.15.1.0 && < 0.19 } +common resourcet { build-depends: resourcet >= 1.2.2 && < 2 } +common text { build-depends: text >= 1.2.3.2 && < 3 } common transformers { build-depends: transformers >= 0.5 && < 0.7 } common vector { build-depends: vector >= 0.12.0.3 && < 0.14 } common word8 { build-depends: word8 >= 0.1.3 && < 0.2 } @@ -64,7 +64,6 @@ common hw-xml library import: base, config - , ansi-wl-pprint , array , attoparsec , base @@ -82,6 +81,7 @@ library , lens , mmap , mtl + , prettyprinter , resourcet , text , transformers diff --git a/src/HaskellWorks/Data/Xml/RawValue.hs b/src/HaskellWorks/Data/Xml/RawValue.hs index bf311bb..079f2d7 100644 --- a/src/HaskellWorks/Data/Xml/RawValue.hs +++ b/src/HaskellWorks/Data/Xml/RawValue.hs @@ -3,6 +3,7 @@ {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE TypeApplications #-} module HaskellWorks.Data.Xml.RawValue ( RawValue(..) @@ -15,7 +16,7 @@ import Data.Text (Text) import HaskellWorks.Data.Xml.Grammar import HaskellWorks.Data.Xml.Internal.Show import HaskellWorks.Data.Xml.Succinct.Index -import Text.PrettyPrint.ANSI.Leijen hiding ((<$>), (<>)) +import Prettyprinter import qualified Data.Attoparsec.ByteString.Char8 as ABC import qualified Data.ByteString as BS @@ -34,35 +35,49 @@ data RawValue | RawError Text deriving (Eq, Show) +-- TODO use colors and styles + +red :: Doc ann -> Doc ann +red = id + +dullwhite :: Doc ann -> Doc ann +dullwhite = id + +bold :: Doc ann -> Doc ann +bold = id + +dullgreen :: Doc ann -> Doc ann +dullgreen = id + instance Pretty RawValue where pretty mjpv = case mjpv of - RawText s -> ctext $ text (T.unpack s) - RawAttrName s -> text (T.unpack s) - RawAttrValue s -> (ctext . dquotes . text) (T.unpack s) + RawText s -> ctext $ pretty (T.unpack s) + RawAttrName s -> pretty (T.unpack s) + RawAttrValue s -> (ctext . dquotes . pretty) (T.unpack s) RawAttrList ats -> formatAttrs ats - RawComment s -> text $ "" + RawComment s -> pretty $ "" RawElement s xs -> formatElem (T.unpack s) xs RawDocument xs -> formatMeta "?" "xml" xs - RawError s -> red $ text "[error " <> text (T.unpack s) <> text "]" - RawCData s -> cangle " ctag (text "[CDATA[") <> text (T.unpack s) <> cangle (text "]]>") + RawError s -> red $ "[error " <> pretty (T.unpack s) <> "]" + RawCData s -> cangle " ctag "[CDATA[" <> pretty (T.unpack s) <> cangle "]]>" RawMeta s xs -> formatMeta "!" (T.unpack s) xs where formatAttr at = case at of - RawAttrName a -> text " " <> pretty (RawAttrName a) - RawAttrValue a -> text "=" <> pretty (RawAttrValue a) - RawAttrList _ -> red $ text "ATTRS" - _ -> red $ text "booo" + RawAttrName a -> " " <> pretty (RawAttrName a) + RawAttrValue a -> "=" <> pretty (RawAttrValue a) + RawAttrList _ -> red "ATTRS" + _ -> red "booo" formatAttrs ats = hcat (formatAttr <$> ats) formatElem s xs = let (ats, es) = partition isAttrL xs - in cangle langle <> ctag (text s) + in cangle langle <> ctag (pretty s) <> hcat (pretty <$> ats) <> cangle rangle <> hcat (pretty <$> es) - <> cangle (text " ctag (text s) <> cangle rangle + <> cangle " ctag (pretty s) <> cangle rangle formatMeta b s xs = let (ats, es) = partition isAttr xs - in cangle (langle <> text b) <> ctag (text s) + in cangle (langle <> pretty @String b) <> ctag (pretty @String s) <> hcat (pretty <$> ats) <> cangle rangle <> hcat (pretty <$> es) @@ -102,13 +117,13 @@ instance RawValueAt XmlIndex where ABC.Partial _ -> decodeErr "Unexpected end of attr name, expected" bs ABC.Done _ r -> Right r -cangle :: Doc -> Doc +cangle :: Doc ann -> Doc ann cangle = dullwhite -ctag :: Doc -> Doc +ctag :: Doc ann -> Doc ann ctag = bold -ctext :: Doc -> Doc +ctext :: Doc ann -> Doc ann ctext = dullgreen isAttrL :: RawValue -> Bool