diff --git a/.github/workflows/haskell-ci.yml b/.github/workflows/haskell-ci.yml index 6e067ac..253e964 100644 --- a/.github/workflows/haskell-ci.yml +++ b/.github/workflows/haskell-ci.yml @@ -1,6 +1,6 @@ # This GitHub workflow config has been generated by a script via # -# haskell-ci 'github' '--doctest' '--doctest-version=^>=0.22' 'cgi.cabal' +# haskell-ci 'github' '--doctest' '--doctest-version=^>=0.24' 'cgi.cabal' # # To regenerate the script (for example after adjusting tested-with) run # @@ -8,9 +8,9 @@ # # For more information, see https://github.com/haskell-CI/haskell-ci # -# version: 0.19.20240708 +# version: 0.19.20250216 # -# REGENDATA ("0.19.20240708",["github","--doctest","--doctest-version=^>=0.22","cgi.cabal"]) +# REGENDATA ("0.19.20250216",["github","--doctest","--doctest-version=^>=0.24","cgi.cabal"]) # name: Haskell-CI on: @@ -19,7 +19,7 @@ on: jobs: linux: name: Haskell-CI - Linux - ${{ matrix.compiler }} - runs-on: ubuntu-20.04 + runs-on: ubuntu-24.04 timeout-minutes: 60 container: @@ -28,19 +28,24 @@ jobs: strategy: matrix: include: + - compiler: ghc-9.12.1 + compilerKind: ghc + compilerVersion: 9.12.1 + setup-method: ghcup + allow-failure: false - compiler: ghc-9.10.1 compilerKind: ghc compilerVersion: 9.10.1 setup-method: ghcup allow-failure: false - - compiler: ghc-9.8.2 + - compiler: ghc-9.8.4 compilerKind: ghc - compilerVersion: 9.8.2 + compilerVersion: 9.8.4 setup-method: ghcup allow-failure: false - - compiler: ghc-9.6.3 + - compiler: ghc-9.6.6 compilerKind: ghc - compilerVersion: 9.6.3 + compilerVersion: 9.6.6 setup-method: ghcup allow-failure: false - compiler: ghc-9.4.8 @@ -90,15 +95,29 @@ jobs: allow-failure: false fail-fast: false steps: - - name: apt + - name: apt-get install run: | apt-get update apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5 libnuma-dev + - name: Install GHCup + run: | mkdir -p "$HOME/.ghcup/bin" curl -sL https://downloads.haskell.org/ghcup/0.1.30.0/x86_64-linux-ghcup-0.1.30.0 > "$HOME/.ghcup/bin/ghcup" chmod a+x "$HOME/.ghcup/bin/ghcup" - "$HOME/.ghcup/bin/ghcup" install ghc "$HCVER" || (cat "$HOME"/.ghcup/logs/*.* && false) + - name: Install cabal-install + run: | "$HOME/.ghcup/bin/ghcup" install cabal 3.12.1.0 || (cat "$HOME"/.ghcup/logs/*.* && false) + echo "CABAL=$HOME/.ghcup/bin/cabal-3.12.1.0 -vnormal+nowrap" >> "$GITHUB_ENV" + - name: Install GHC (GHCup) + if: matrix.setup-method == 'ghcup' + run: | + "$HOME/.ghcup/bin/ghcup" install ghc "$HCVER" || (cat "$HOME"/.ghcup/logs/*.* && false) + HC=$("$HOME/.ghcup/bin/ghcup" whereis ghc "$HCVER") + HCPKG=$(echo "$HC" | sed 's#ghc$#ghc-pkg#') + HADDOCK=$(echo "$HC" | sed 's#ghc$#haddock#') + echo "HC=$HC" >> "$GITHUB_ENV" + echo "HCPKG=$HCPKG" >> "$GITHUB_ENV" + echo "HADDOCK=$HADDOCK" >> "$GITHUB_ENV" env: HCKIND: ${{ matrix.compilerKind }} HCNAME: ${{ matrix.compiler }} @@ -109,21 +128,12 @@ jobs: echo "LANG=C.UTF-8" >> "$GITHUB_ENV" echo "CABAL_DIR=$HOME/.cabal" >> "$GITHUB_ENV" echo "CABAL_CONFIG=$HOME/.cabal/config" >> "$GITHUB_ENV" - HCDIR=/opt/$HCKIND/$HCVER - HC=$("$HOME/.ghcup/bin/ghcup" whereis ghc "$HCVER") - HCPKG=$(echo "$HC" | sed 's#ghc$#ghc-pkg#') - HADDOCK=$(echo "$HC" | sed 's#ghc$#haddock#') - echo "HC=$HC" >> "$GITHUB_ENV" - echo "HCPKG=$HCPKG" >> "$GITHUB_ENV" - echo "HADDOCK=$HADDOCK" >> "$GITHUB_ENV" - echo "CABAL=$HOME/.ghcup/bin/cabal-3.12.1.0 -vnormal+nowrap" >> "$GITHUB_ENV" HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\d+)\.(\d+)\.(\d+)(\.(\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))') echo "HCNUMVER=$HCNUMVER" >> "$GITHUB_ENV" echo "ARG_TESTS=--enable-tests" >> "$GITHUB_ENV" echo "ARG_BENCH=--enable-benchmarks" >> "$GITHUB_ENV" echo "HEADHACKAGE=false" >> "$GITHUB_ENV" echo "ARG_COMPILER=--$HCKIND --with-compiler=$HC" >> "$GITHUB_ENV" - echo "GHCJSARITH=0" >> "$GITHUB_ENV" env: HCKIND: ${{ matrix.compilerKind }} HCNAME: ${{ matrix.compiler }} @@ -166,7 +176,7 @@ jobs: - name: cache (tools) uses: actions/cache/restore@v4 with: - key: ${{ runner.os }}-${{ matrix.compiler }}-tools-1cf0e533 + key: ${{ runner.os }}-${{ matrix.compiler }}-tools-2ae1f11d path: ~/.haskell-ci-tools - name: install cabal-plan run: | @@ -179,13 +189,13 @@ jobs: cabal-plan --version - name: install doctest run: | - $CABAL --store-dir=$HOME/.haskell-ci-tools/store v2-install $ARG_COMPILER --ignore-project -j2 doctest --constraint='doctest ^>=0.22' + $CABAL --store-dir=$HOME/.haskell-ci-tools/store v2-install $ARG_COMPILER --ignore-project -j2 doctest --constraint='doctest ^>=0.24' doctest --version - name: save cache (tools) - uses: actions/cache/save@v4 if: always() + uses: actions/cache/save@v4 with: - key: ${{ runner.os }}-${{ matrix.compiler }}-tools-1cf0e533 + key: ${{ runner.os }}-${{ matrix.compiler }}-tools-2ae1f11d path: ~/.haskell-ci-tools - name: checkout uses: actions/checkout@v4 @@ -255,8 +265,8 @@ jobs: rm -f cabal.project.local $CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks all - name: save cache - uses: actions/cache/save@v4 if: always() + uses: actions/cache/save@v4 with: key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }} path: ~/.cabal/store diff --git a/cgi.cabal b/cgi.cabal index 2c5c7a7..8cc5a3b 100644 --- a/cgi.cabal +++ b/cgi.cabal @@ -1,5 +1,5 @@ name: cgi -version: 3001.5.0.1 +version: 3001.5.1.0 synopsis: A library for writing CGI programs description: This is a Haskell library for writing CGI programs. license: BSD3 @@ -9,8 +9,8 @@ copyright: Bjorn Bringert, John Chee, Andy Gill, Anders Kaseorg, author: Bjorn Bringert maintainer: John Chee , Peter Simons tested-with: GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.4, GHC == 8.6.5, GHC == 8.8.4, - GHC == 8.10.7, GHC == 9.0.2, GHC == 9.2.8, GHC == 9.4.8, GHC == 9.6.3, - GHC == 9.8.2, GHC == 9.10.1 + GHC == 8.10.7, GHC == 9.0.2, GHC == 9.2.8, GHC == 9.4.8, GHC == 9.6.6, + GHC == 9.8.4, GHC == 9.10.1, GHC == 9.12.1 category: Network homepage: https://github.com/cheecheeo/haskell-cgi bug-reports: https://github.com/cheecheeo/haskell-cgi/issues @@ -42,8 +42,9 @@ library , multipart >= 0.1.2 && < 0.3 , network-uri == 2.6.* , parsec >= 2.0 && < 3.2 + , text < 2.2 , time >= 1.5 && < 1.15 - , xhtml >= 3000.0.0 && < 3000.3 + , xhtml >= 3000.0.0 && < 3000.5 other-extensions: MultiParamTypeClasses default-language: Haskell2010 diff --git a/src/Network/CGI.hs b/src/Network/CGI.hs index 30f0f7c..5e363d1 100644 --- a/src/Network/CGI.hs +++ b/src/Network/CGI.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} ----------------------------------------------------------------------------- -- | -- Module : Network.CGI @@ -116,6 +117,17 @@ import Network.CGI.Protocol import Text.XHtml (Html, renderHtml, header, (<<), thetitle, (+++), body, h1, paragraph, hr, address) +#if MIN_VERSION_xhtml(3000,3,0) +import Data.ByteString.Builder (toLazyByteString) +import qualified Data.Text.Lazy as LText +import qualified Data.Text.Lazy.Encoding as LText +import Text.XHtml (Builder) + +-- Taken from Text.XHtml.Internal +builderToString :: Builder -> String +builderToString = LText.unpack . LText.decodeUtf8 . toLazyByteString +#endif + -- | Run a CGI action. Typically called by the main function. -- Reads input from stdin and writes to stdout. Gets -- CGI environment variables from the program environment. @@ -206,7 +218,11 @@ outputError c m es = output text _ -> do setHeader "Content-type" (showContentType htmlType) page <- errorPage c m es +#if MIN_VERSION_xhtml(3000,3,0) + output $ builderToString $ renderHtml page +#else output $ renderHtml page +#endif -- | Create an HTML error page. errorPage :: MonadCGI m =>