-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from dpwright/mangoiv/ci
add initial ci and cut release
- Loading branch information
Showing
5 changed files
with
105 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/[email protected] | ||
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/[email protected] | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,20 @@ | ||
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. | ||
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 | ||
maintainer: Leza M. Lutonda <[email protected]>, [email protected] | ||
maintainer: Leza M. Lutonda <[email protected]>, [email protected], [email protected] | ||
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 | ||
|
@@ -34,11 +35,22 @@ 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) | ||
build-depends: network >= 3.0 && < 3.2, | ||
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, | ||
HaskellNet-SSL, | ||
HaskellNet, | ||
bytestring | ||
|
||
default-language: Haskell2010 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,12 @@ | ||
HaskellNet-SSL | ||
-------------- | ||
# HaskellNet-SSL | ||
|
||
[](https://travis-ci.org/dpwright/HaskellNet-SSL) | ||
[](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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 = "[email protected]" | ||
|
||
password :: Password | ||
password = "password" | ||
|
||
recipient :: Address | ||
recipient = "[email protected]" | ||
|
||
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 |