diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..3af7e25 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,108 @@ +name: ci + +on: + pull_request: + push: + workflow_dispatch: + +jobs: + cabal: + name: ${{ matrix.os }} / ghc ${{ matrix.ghc }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macOS-latest] + ghc: + - "8.10.7" + - "9.0.2" + - "9.2.8" + - "9.4.8" + - "9.6.7" + - "9.8.4" + - "9.10.2" + - "9.12.2" + exclude: + # These don't work on GitHub CI anymore because they need llvm@13, which became + # disabled on 12/31/2024 + - os: macOS-latest + ghc: 8.10.7 + - os: macOS-latest + ghc: 9.0.2 + + steps: + - uses: actions/checkout@v4 + + - uses: haskell-actions/setup@v2 + id: setup-haskell-cabal + name: Setup Haskell + with: + ghc-version: ${{ matrix.ghc }} + cabal-version: "latest" + + - name: Freeze + run: | + cabal freeze + + - uses: actions/cache@v4 + name: Cache ~/.cabal/store + with: + path: ${{ steps.setup-haskell-cabal.outputs.cabal-store }} + key: ${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze') }} + + - name: Build + run: | + cabal configure --enable-tests --enable-benchmarks --test-show-details=direct + cabal build all + + # - name: Test + # run: | + # cabal test all + + stack: + name: stack / ghc ${{ matrix.ghc }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - ghc: "8.10.7" + resolver: lts-18.28 + - ghc: "9.0.2" + resolver: lts-19.33 + - ghc: "9.2.8" + resolver: lts-20.26 + - ghc: "9.4.8" + resolver: lts-21.25 + - ghc: "9.6.7" + resolver: lts-22.44 + - ghc: "9.8.4" + resolver: lts-23.24 + - ghc: "9.10.2" + resolver: nightly-2025-05-26 + # - ghc: "9.12.2" + # resolver: + + steps: + - uses: actions/checkout@v4 + + - uses: haskell-actions/setup@v2 + name: Setup Haskell Stack + with: + ghc-version: ${{ matrix.ghc }} + enable-stack: true + stack-version: "latest" + + - uses: actions/cache@v4 + name: Cache ~/.stack + with: + path: ~/.stack + key: ${{ runner.os }}-${{ matrix.ghc }}-${{ matrix.resolver }} + + - name: Build + run: | + stack build --resolver ${{matrix.resolver}} --system-ghc --test --bench --no-run-tests --no-run-benchmarks + + # - name: Test + # run: | + # stack test --resolver ${{matrix.resolver}} --system-ghc diff --git a/.github/workflows/haskell-ci.yml b/.github/workflows/haskell-ci.yml deleted file mode 100644 index c5fc318..0000000 --- a/.github/workflows/haskell-ci.yml +++ /dev/null @@ -1,210 +0,0 @@ -# This GitHub workflow config has been generated by a script via -# -# haskell-ci 'github' 'HaskellNet.cabal' -# -# To regenerate the script (for example after adjusting tested-with) run -# -# haskell-ci regenerate -# -# For more information, see https://github.com/haskell-CI/haskell-ci -# -# version: 0.16.3 -# -# REGENDATA ("0.16.3",["github","HaskellNet.cabal"]) -# -name: Haskell-CI -on: - - push - - pull_request -jobs: - linux: - name: Haskell-CI - Linux - ${{ matrix.compiler }} - runs-on: ubuntu-20.04 - timeout-minutes: - 60 - container: - image: buildpack-deps:bionic - continue-on-error: ${{ matrix.allow-failure }} - strategy: - matrix: - include: - - compiler: ghc-9.6.2 - compilerKind: ghc - compilerVersion: 9.6.2 - setup-method: ghcup - allow-failure: false - - compiler: ghc-8.10.7 - compilerKind: ghc - compilerVersion: 8.10.7 - setup-method: ghcup - allow-failure: false - fail-fast: false - steps: - - name: apt - run: | - apt-get update - apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5 - if [ "${{ matrix.setup-method }}" = ghcup ]; then - mkdir -p "$HOME/.ghcup/bin" - curl -sL https://downloads.haskell.org/ghcup/0.1.19.2/x86_64-linux-ghcup-0.1.19.2 > "$HOME/.ghcup/bin/ghcup" - chmod a+x "$HOME/.ghcup/bin/ghcup" - "$HOME/.ghcup/bin/ghcup" install ghc "$HCVER" || (cat "$HOME"/.ghcup/logs/*.* && false) - "$HOME/.ghcup/bin/ghcup" install cabal 3.10.1.0 || (cat "$HOME"/.ghcup/logs/*.* && false) - else - apt-add-repository -y 'ppa:hvr/ghc' - apt-get update - apt-get install -y "$HCNAME" - mkdir -p "$HOME/.ghcup/bin" - curl -sL https://downloads.haskell.org/ghcup/0.1.19.2/x86_64-linux-ghcup-0.1.19.2 > "$HOME/.ghcup/bin/ghcup" - chmod a+x "$HOME/.ghcup/bin/ghcup" - "$HOME/.ghcup/bin/ghcup" install cabal 3.10.1.0 || (cat "$HOME"/.ghcup/logs/*.* && false) - fi - env: - HCKIND: ${{ matrix.compilerKind }} - HCNAME: ${{ matrix.compiler }} - HCVER: ${{ matrix.compilerVersion }} - - name: Set PATH and environment variables - run: | - echo "$HOME/.cabal/bin" >> $GITHUB_PATH - 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 - if [ "${{ matrix.setup-method }}" = ghcup ]; then - HC=$HOME/.ghcup/bin/$HCKIND-$HCVER - echo "HC=$HC" >> "$GITHUB_ENV" - echo "HCPKG=$HOME/.ghcup/bin/$HCKIND-pkg-$HCVER" >> "$GITHUB_ENV" - echo "HADDOCK=$HOME/.ghcup/bin/haddock-$HCVER" >> "$GITHUB_ENV" - echo "CABAL=$HOME/.ghcup/bin/cabal-3.10.1.0 -vnormal+nowrap" >> "$GITHUB_ENV" - else - HC=$HCDIR/bin/$HCKIND - echo "HC=$HC" >> "$GITHUB_ENV" - echo "HCPKG=$HCDIR/bin/$HCKIND-pkg" >> "$GITHUB_ENV" - echo "HADDOCK=$HCDIR/bin/haddock" >> "$GITHUB_ENV" - echo "CABAL=$HOME/.ghcup/bin/cabal-3.10.1.0 -vnormal+nowrap" >> "$GITHUB_ENV" - fi - - 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 }} - HCVER: ${{ matrix.compilerVersion }} - - name: env - run: | - env - - name: write cabal config - run: | - mkdir -p $CABAL_DIR - cat >> $CABAL_CONFIG <> $CABAL_CONFIG < cabal-plan.xz - echo 'f62ccb2971567a5f638f2005ad3173dba14693a45154c1508645c52289714cb2 cabal-plan.xz' | sha256sum -c - - xz -d < cabal-plan.xz > $HOME/.cabal/bin/cabal-plan - rm -f cabal-plan.xz - chmod a+x $HOME/.cabal/bin/cabal-plan - cabal-plan --version - - name: checkout - uses: actions/checkout@v3 - with: - path: source - - name: initial cabal.project for sdist - run: | - touch cabal.project - echo "packages: $GITHUB_WORKSPACE/source/." >> cabal.project - cat cabal.project - - name: sdist - run: | - mkdir -p sdist - $CABAL sdist all --output-dir $GITHUB_WORKSPACE/sdist - - name: unpack - run: | - mkdir -p unpacked - find sdist -maxdepth 1 -type f -name '*.tar.gz' -exec tar -C $GITHUB_WORKSPACE/unpacked -xzvf {} \; - - name: generate cabal.project - run: | - PKGDIR_HaskellNet="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/HaskellNet-[0-9.]*')" - echo "PKGDIR_HaskellNet=${PKGDIR_HaskellNet}" >> "$GITHUB_ENV" - rm -f cabal.project cabal.project.local - touch cabal.project - touch cabal.project.local - echo "packages: ${PKGDIR_HaskellNet}" >> cabal.project - echo "package HaskellNet" >> cabal.project - echo " ghc-options: -Werror=missing-methods" >> cabal.project - cat >> cabal.project <> cabal.project.local - cat cabal.project - cat cabal.project.local - - name: dump install plan - run: | - $CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH --dry-run all - cabal-plan - - name: restore cache - uses: actions/cache/restore@v3 - with: - key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }} - path: ~/.cabal/store - restore-keys: ${{ runner.os }}-${{ matrix.compiler }}- - - name: install dependencies - run: | - $CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks --dependencies-only -j2 all - $CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH --dependencies-only -j2 all - - name: build w/o tests - run: | - $CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks all - - name: build - run: | - $CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH all --write-ghc-environment-files=always - - name: cabal check - run: | - cd ${PKGDIR_HaskellNet} || false - ${CABAL} -vnormal check - - name: haddock - run: | - $CABAL v2-haddock --disable-documentation --haddock-all $ARG_COMPILER --with-haddock $HADDOCK $ARG_TESTS $ARG_BENCH all - - name: unconstrained build - run: | - rm -f cabal.project.local - $CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks all - - name: save cache - uses: actions/cache/save@v3 - if: always() - with: - key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }} - path: ~/.cabal/store diff --git a/.gitignore b/.gitignore index 7e38080..57aeef7 100755 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,4 @@ cabal.config *.prof *.aux *.hp +.stack-work diff --git a/HaskellNet.cabal b/HaskellNet.cabal index 76a8083..af2a897 100644 --- a/HaskellNet.cabal +++ b/HaskellNet.cabal @@ -19,11 +19,14 @@ Homepage: https://github.com/qnikst/HaskellNet Cabal-version: 1.22 Build-type: Simple Tested-with: - GHC ==8.8.4 - || ==8.10.7 + GHC ==8.10.7 || ==9.0.2 - || ==9.2.5 - || ==9.4.4 + || ==9.2.8 + || ==9.4.8 + || ==9.6.7 + || ==9.8.4 + || ==9.10.2 + || ==9.12.2 Extra-Source-Files: CHANGELOG @@ -67,14 +70,14 @@ Library Network.Mail.Mime Build-Depends: - base >= 4.3 && < 4.19, + base >= 4.3 && < 4.22, network >= 2.6.3.1 && < 3.3, mtl >= 2.2.2 && < 2.4, - bytestring >=0.10.2 && < 0.12, + bytestring >=0.10.2 && < 0.13, pretty >= 1.1.3 && < 1.2, array >= 0.5 && < 0.6, cryptohash-md5 >= 0.11 && < 0.12, - base64 < 0.5, + base64 < 1.1, old-time >= 1.0 && < 1.2, mime-mail >= 0.4 && < 0.6, text >= 1.0 && < 3 diff --git a/src/Network/HaskellNet/Auth.hs b/src/Network/HaskellNet/Auth.hs index 40663c6..9dd125a 100644 --- a/src/Network/HaskellNet/Auth.hs +++ b/src/Network/HaskellNet/Auth.hs @@ -48,12 +48,7 @@ b64Encode = T.unpack . encode . T.pack b64Decode :: String -> String b64Decode = T.unpack . decode . T.pack - where decode = -#if MIN_VERSION_base64(0,5,0) - B64.decodeBase64Lenient . B64.assertBase64 -#else - B64.decodeBase64Lenient -#endif + where decode = B64.decodeBase64Lenient showOctet :: [Word8] -> String showOctet = concatMap hexChars diff --git a/src/Network/HaskellNet/IMAP.hs b/src/Network/HaskellNet/IMAP.hs index 884f3f6..69af0bd 100644 --- a/src/Network/HaskellNet/IMAP.hs +++ b/src/Network/HaskellNet/IMAP.hs @@ -16,6 +16,7 @@ module Network.HaskellNet.IMAP -- * fetch commands , fetch, fetchHeader, fetchSize, fetchHeaderFields, fetchHeaderFieldsNot , fetchFlags, fetchR, fetchByString, fetchByStringR + , fetchPeek, fetchRPeek -- * other types , Flag(..), Attribute(..), MailboxStatus(..) , SearchQuery(..), FlagsQuery(..) @@ -23,13 +24,13 @@ module Network.HaskellNet.IMAP ) where -import Network.Socket (PortNumber) import Network.Compat +import qualified Network.HaskellNet.Auth as A import Network.HaskellNet.BSStream import Network.HaskellNet.IMAP.Connection -import Network.HaskellNet.IMAP.Types import Network.HaskellNet.IMAP.Parsers -import qualified Network.HaskellNet.Auth as A +import Network.HaskellNet.IMAP.Types +import Network.Socket (PortNumber) import Data.ByteString (ByteString) import qualified Data.ByteString.Char8 as BS @@ -421,8 +422,8 @@ fetchR conn r = -- | Like 'fetchR' but without marking the email as seen/read fetchRPeek :: IMAPConnection -> (UID, UID) -> IO [(UID, ByteString)] fetchRPeek conn range = - do list <- fetchByStringR conn range "BODY.PEEK[]" - return $ map (\(uid, vs) -> (uid, maybe BS.empty BS.pack $ lookup' "BODY[]" vs)) list + do ls <- fetchByStringR conn range "BODY.PEEK[]" + return $ map (\(uid, vs) -> (uid, maybe BS.empty BS.pack $ lookup' "BODY[]" vs)) ls fetchByString :: IMAPConnection -> UID -> String -> IO [(String, String)] diff --git a/src/Network/HaskellNet/POP3.hs b/src/Network/HaskellNet/POP3.hs index 7989cae..b3274ad 100644 --- a/src/Network/HaskellNet/POP3.hs +++ b/src/Network/HaskellNet/POP3.hs @@ -31,10 +31,10 @@ module Network.HaskellNet.POP3 ) where -import Network.HaskellNet.BSStream -import Network.Socket import Network.Compat import qualified Network.HaskellNet.Auth as A +import Network.HaskellNet.BSStream +import Network.Socket import Data.ByteString (ByteString) import qualified Data.ByteString as B @@ -159,9 +159,6 @@ sendCommand conn command = (UIDL msg) -> "UIDL " ++ maybe "" show msg (APOP usern passw) -> "APOP " ++ usern ++ " " ++ hexDigest (apopKey conn ++ passw) - (AUTH _ _ _) -> error "BUG: AUTH should not get matched here" - (RETR _) -> error "BUG: RETR should not get matched here" - (TOP _ _) -> error "BUG: TOP should not get matched here" user :: POP3Connection -> String -> IO () user conn name = do (resp, _) <- sendCommand conn (USER name) diff --git a/src/Network/HaskellNet/SMTP/Internal.hs b/src/Network/HaskellNet/SMTP/Internal.hs index dde4743..c1ad33e 100644 --- a/src/Network/HaskellNet/SMTP/Internal.hs +++ b/src/Network/HaskellNet/SMTP/Internal.hs @@ -302,10 +302,6 @@ sendCommand (SMTPC conn _) meth = NOOP -> "NOOP" RSET -> "RSET" QUIT -> "QUIT" - (DATA _) -> - error "BUG: DATA pattern should be matched by sendCommand patterns" - (AUTH {}) -> - error "BUG: AUTH pattern should be matched by sendCommand patterns" -- | Sends quit to the server. Connection must be terminated afterwards, i.e. it's not -- allowed to issue any command on this connection. diff --git a/src/Text/Packrat/Parse.hs b/src/Text/Packrat/Parse.hs index 049005a..7284da6 100644 --- a/src/Text/Packrat/Parse.hs +++ b/src/Text/Packrat/Parse.hs @@ -12,7 +12,6 @@ import Data.List import Text.Packrat.Pos import Control.Monad -import Control.Applicative (Applicative(..)) import qualified Control.Applicative as A import qualified Control.Monad.Fail as Fail @@ -371,4 +370,3 @@ dvString d = case dvChar d of NoParse _ -> [] Parsed c rem _ -> c : dvString rem - diff --git a/stack.yaml b/stack.yaml new file mode 100644 index 0000000..cbd5a9a --- /dev/null +++ b/stack.yaml @@ -0,0 +1,5 @@ + +resolver: nightly-2025-05-25 + +packages: +- ./. diff --git a/stack.yaml.lock b/stack.yaml.lock new file mode 100644 index 0000000..bfebde4 --- /dev/null +++ b/stack.yaml.lock @@ -0,0 +1,12 @@ +# This file was autogenerated by Stack. +# You should not edit this file by hand. +# For more information, please see the documentation at: +# https://docs.haskellstack.org/en/stable/topics/lock_files + +packages: [] +snapshots: +- completed: + sha256: 3f794c3c7a7c50ef09964803ef60d67884c890c9115bc759409639a57cc59449 + size: 712235 + url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/nightly/2025/5/25.yaml + original: nightly-2025-05-25