Skip to content

Commit

Permalink
Update CI
Browse files Browse the repository at this point in the history
  • Loading branch information
newhoggy committed Jan 10, 2024
1 parent 11b5cc4 commit 59ce1d3
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 42 deletions.
26 changes: 14 additions & 12 deletions .github/workflows/haskell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
22 changes: 11 additions & 11 deletions hw-xml.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand All @@ -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 }
Expand All @@ -64,7 +64,6 @@ common hw-xml

library
import: base, config
, ansi-wl-pprint
, array
, attoparsec
, base
Expand All @@ -82,6 +81,7 @@ library
, lens
, mmap
, mtl
, prettyprinter
, resourcet
, text
, transformers
Expand Down
49 changes: 32 additions & 17 deletions src/HaskellWorks/Data/Xml/RawValue.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}

module HaskellWorks.Data.Xml.RawValue
( RawValue(..)
Expand All @@ -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
Expand All @@ -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 $ "<!-- " <> show s <> "-->"
RawComment s -> pretty $ "<!-- " <> show s <> "-->"
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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 59ce1d3

Please sign in to comment.