From b2067f3dcafa7d3608437df2ecd88efe2572de37 Mon Sep 17 00:00:00 2001 From: mangoiv Date: Tue, 7 Jan 2025 14:22:26 +0100 Subject: [PATCH 1/3] [feat] add initial ci - add tested-with stanze - add get-tested cabal build --- .github/workflows/haskell.yml | 53 +++++++++++++++++++++++++++++++++++ HaskellNet-SSL.cabal | 1 + 2 files changed, 54 insertions(+) create mode 100644 .github/workflows/haskell.yml diff --git a/.github/workflows/haskell.yml b/.github/workflows/haskell.yml new file mode 100644 index 0000000..438e65b --- /dev/null +++ b/.github/workflows/haskell.yml @@ -0,0 +1,53 @@ +name: haskell ci +on: + workflow_dispatch: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + generate-matrix: + name: "Generate matrix from cabal" + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + runs-on: ubuntu-latest + steps: + - name: Extract the tested GHC versions + id: set-matrix + uses: kleidukos/get-tested@v0.1.7.0 + with: + cabal-file: HaskellNet-SSL.cabal + ubuntu-version: "latest" + macos-version: "latest" + windows-version: "latest" + version: 0.1.7.0 + tests: + name: ${{ matrix.ghc }} on ${{ matrix.os }} + needs: generate-matrix + runs-on: ${{ matrix.os }} + strategy: + matrix: ${{ fromJSON(needs.generate-matrix.outputs.matrix) }} + steps: + - name: Checkout repo + uses: actions/checkout@v4 + - name: Set up Haskell + id: setup-haskell + uses: haskell-actions/setup@v2 + with: + ghc-version: ${{ matrix.ghc }} + cabal-version: 'latest' + - name: Update + run: cabal update + - name: Freeze + run: cabal freeze + - name: Cache + uses: actions/cache@v4.0.2 + with: + path: ${{ steps.setup-haskell.outputs.cabal-store }} + key: ${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze') }} + restore-keys: ${{ runner.os }}-${{ matrix.ghc }}- + - name: Build + run: cabal build diff --git a/HaskellNet-SSL.cabal b/HaskellNet-SSL.cabal index fe73ef2..ff8a279 100644 --- a/HaskellNet-SSL.cabal +++ b/HaskellNet-SSL.cabal @@ -5,6 +5,7 @@ description: This package ties together the HaskellNet and connection packages to make it easy to open IMAP and SMTP connections over SSL. homepage: https://github.com/dpwright/HaskellNet-SSL +tested-with: GHC ==9.4.8 || ==9.6.5 || ==9.8.2 license: BSD3 license-file: LICENSE author: Daniel P. Wright From 18d0d083202e7ec6bc9cde0ea3f6ef162c8b95c7 Mon Sep 17 00:00:00 2001 From: mangoiv Date: Tue, 7 Jan 2025 15:22:01 +0100 Subject: [PATCH 2/3] [fix] fix example and add it to ci - continuously build example - add example as executable to *cabal file --- HaskellNet-SSL.cabal | 12 ++++++++++++ examples/gmail.hs | 28 +++++++++++++++++++++++----- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/HaskellNet-SSL.cabal b/HaskellNet-SSL.cabal index ff8a279..6fb160f 100644 --- a/HaskellNet-SSL.cabal +++ b/HaskellNet-SSL.cabal @@ -43,3 +43,15 @@ library network-bsd >= 2.7 && < 2.9 else build-depends: network >= 2.4 && < 3.0 + +executable HaskellNet-SSL-example + hs-source-dirs: examples + main-is: gmail.hs + other-modules: + build-depends: + base <5 + , HaskellNet-SSL + , HaskellNet + , bytestring + + default-language: Haskell2010 diff --git a/examples/gmail.hs b/examples/gmail.hs index e54d7df..de7f615 100644 --- a/examples/gmail.hs +++ b/examples/gmail.hs @@ -3,34 +3,52 @@ import Network.HaskellNet.IMAP.SSL import Network.HaskellNet.SMTP.SSL as SMTP -import Network.HaskellNet.Auth (AuthType(LOGIN)) +import Network.HaskellNet.Auth (AuthType(LOGIN), Password) +import Network.Mail.Mime import qualified Data.ByteString.Char8 as B +import Data.String +username :: IsString s => s username = "username@gmail.com" + +password :: Password password = "password" + +recipient :: Address recipient = "someone@somewhere.com" +imapTest :: IO () imapTest = do c <- connectIMAPSSLWithSettings "imap.gmail.com" cfg login c username password mboxes <- list c mapM_ print mboxes select c "INBOX" - msgs <- search c [ALLs] - let firstMsg = head msgs + msgs@(firstMsg : _) <- search c [ALLs] msgContent <- fetch c firstMsg B.putStrLn msgContent logout c where cfg = defaultSettingsIMAPSSL { sslMaxLineLength = 100000 } +smtpTest :: IO () smtpTest = doSMTPSTARTTLS "smtp.gmail.com" $ \c -> do authSucceed <- SMTP.authenticate LOGIN username password c if authSucceed - then sendPlainTextMail recipient username subject body c + then do + mail <- simpleMail + recipient + username + subject + body + mempty + mempty + sendMail mail c -- recipient username subject body else print "Authentication error." where subject = "Test message" body = "This is a test message" main :: IO () -main = smtpTest >> imapTest >> return () +main = do + smtpTest + imapTest From fe1edd98655cb08f09769e74ec79e7aaf358f139 Mon Sep 17 00:00:00 2001 From: mangoiv Date: Tue, 7 Jan 2025 15:39:24 +0100 Subject: [PATCH 3/3] [chore] HaskellNet-SSL version 0.4.0.0 --- CHANGELOG.md | 8 ++++++++ HaskellNet-SSL.cabal | 19 +++++++++---------- README.md | 9 ++++----- 3 files changed, 21 insertions(+), 15 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..ed173e3 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,8 @@ +# Revision history for HaskellNet-SSL + +## 0.4.0.0 -- 2025-01-07 + +- drop support for connection in favour of crypton-connection +- compatibility with GHCs up to ghc 9.8 (bump base and bytestring) +- fix example +- add tested-with stanza diff --git a/HaskellNet-SSL.cabal b/HaskellNet-SSL.cabal index 6fb160f..dd0526d 100644 --- a/HaskellNet-SSL.cabal +++ b/HaskellNet-SSL.cabal @@ -1,6 +1,6 @@ name: HaskellNet-SSL synopsis: Helpers to connect to SSL/TLS mail servers with HaskellNet -version: 0.3.4.4 +version: 0.4.0.0 description: This package ties together the HaskellNet and connection packages to make it easy to open IMAP and SMTP connections over SSL. @@ -9,12 +9,12 @@ tested-with: GHC ==9.4.8 || ==9.6.5 || ==9.8.2 license: BSD3 license-file: LICENSE author: Daniel P. Wright -maintainer: Leza M. Lutonda , dani@dpwright.com +maintainer: Leza M. Lutonda , dani@dpwright.com, contact@mangoiv.com copyright: (c) 2013 Daniel P. Wright category: Network build-type: Simple -cabal-version: >=1.10 -data-files: README.md +cabal-version: 1.18 +extra-doc-files: README.md, CHANGELOG.md flag network-bsd description: Get Network.BSD from the network-bsd package @@ -35,7 +35,7 @@ library other-modules: Network.HaskellNet.SSL.Internal build-depends: base >= 4 && < 5, HaskellNet >= 0.3 && < 0.7, - crypton-connection >= 0.3.1, + crypton-connection >= 0.3.1 && < 0.5, bytestring >= 0.9 && < 0.13, data-default >= 0.2 && < 0.8 if flag(network-bsd) @@ -48,10 +48,9 @@ executable HaskellNet-SSL-example hs-source-dirs: examples main-is: gmail.hs other-modules: - build-depends: - base <5 - , HaskellNet-SSL - , HaskellNet - , bytestring + build-depends: base, + HaskellNet-SSL, + HaskellNet, + bytestring default-language: Haskell2010 diff --git a/README.md b/README.md index c22d782..88ad29a 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,12 @@ -HaskellNet-SSL --------------- +# HaskellNet-SSL -[![Build Status](https://travis-ci.org/dpwright/HaskellNet-SSL.svg?branch=master)](https://travis-ci.org/dpwright/HaskellNet-SSL) +[![haskell ci](https://github.com/dpwright/HaskellNet-SSL/actions/workflows/haskell.yml/badge.svg)](https://github.com/dpwright/HaskellNet-SSL/actions/workflows/haskell.yml) This package ties together the excellent [HaskellNet][HaskellNet] and -[connection][connection] packages to make it easy to open IMAP and SMTP +[crypton-connection][crypton-connection] packages to make it easy to open IMAP and SMTP connections over SSL. This is a simple "glue" library; all credit for a) connecting to IMAP/SMTP servers and b) making an SSL connection goes to the aforementioned libraries. [HaskellNet]: https://github.com/jtdaugherty/HaskellNet -[connection]: https://github.com/vincenthz/hs-connection +[crypton-connection]: https://github.com/kazu-yamamoto/crypton-connection