Skip to content

Commit

Permalink
Added workflows and reformatted code. (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
brianjosephmckeon authored Jan 18, 2024
1 parent cc2fb67 commit b83ca74
Show file tree
Hide file tree
Showing 14 changed files with 493 additions and 322 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/build-arm64-main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: main arm64

on:
push:
branches:
- main

workflow_dispatch:
branches:
- main

jobs:
call-workflow:
uses: layer-3-communications/.github/.github/workflows/build-haskell.yaml@main
with:
build-arch: arm64
slack-name: ${{ github.ref_name }}
secrets: inherit
14 changes: 14 additions & 0 deletions .github/workflows/build-arm64-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: pull request arm64

on:
pull_request:
branches:
- "*"

jobs:
call-workflow:
uses: layer-3-communications/.github/.github/workflows/build-haskell.yaml@main
with:
build-arch: arm64
slack-name: ${{ github.event.pull_request.head.ref }}
secrets: inherit
18 changes: 18 additions & 0 deletions .github/workflows/build-x64-main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: main x64

on:
push:
branches:
- main

workflow_dispatch:
branches:
- main

jobs:
call-workflow:
uses: layer-3-communications/.github/.github/workflows/build-haskell.yaml@main
with:
build-arch: x64
slack-name: ${{ github.ref_name }}
secrets: inherit
14 changes: 14 additions & 0 deletions .github/workflows/build-x64-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: pull request x64

on:
pull_request:
branches:
- "*"

jobs:
call-workflow:
uses: layer-3-communications/.github/.github/workflows/build-haskell.yaml@main
with:
build-arch: x64
slack-name: ${{ github.event.pull_request.head.ref }}
secrets: inherit
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.vscode/
dist
dist-*
cabal-dev
Expand Down
44 changes: 25 additions & 19 deletions app-http-insecure/Main.hs
Original file line number Diff line number Diff line change
@@ -1,35 +1,41 @@
{-# language OverloadedStrings #-}
{-# LANGUAGE OverloadedStrings #-}

import Control.Exception (bracket,throwIO)
import Control.Exception (bracket, throwIO)
import Http.Exchange.Network (exchange)
import Http.Types (Request(..),RequestLine(..),Bodied(..),Header(Header))
import Http.Headers qualified as Headers
import Http.Types (Bodied (..), Header (Header), Request (..), RequestLine (..))
import Network.Socket qualified as N
import Text.Show.Pretty (pPrint)
import qualified Http.Headers as Headers
import qualified Network.Socket as N

main :: IO ()
main = do
let hints = N.defaultHints { N.addrSocketType = N.Stream }
let hints = N.defaultHints {N.addrSocketType = N.Stream}
minfo <- N.getAddrInfo (Just hints) (Just "ifconfig.me") (Just "80")
info <- case minfo of
info : _ -> pure info
[] -> fail "Impossible: getAddrInfo cannot return empty list"
bracket (N.openSocket info) N.close $ \sock -> do
N.connect sock (N.addrAddress info)
result <- exchange sock Bodied
{ metadata = Request
{ requestLine = RequestLine
{ method = "GET"
, path = "/ip"
result <-
exchange
sock
Bodied
{ metadata =
Request
{ requestLine =
RequestLine
{ method = "GET"
, path = "/ip"
}
, headers =
Headers.fromList
[ Header "Host" "ifconfig.me"
, Header "Accept" "text/plain"
, Header "User-Agent" "curl/0.0.0"
]
}
, body = mempty
}
, headers = Headers.fromList
[ Header "Host" "ifconfig.me"
, Header "Accept" "text/plain"
, Header "User-Agent" "curl/0.0.0"
]
}
, body = mempty
}
case result of
Left e -> throwIO e
Right resp -> pPrint resp
91 changes: 50 additions & 41 deletions app-http-secure/Main.hs
Original file line number Diff line number Diff line change
@@ -1,36 +1,40 @@
{-# language OverloadedStrings #-}
{-# LANGUAGE OverloadedStrings #-}

import Control.Exception (bracket,throwIO)
import Http.Exchange.Tls (SocketThrowingNetworkException(..),exchange)
import Http.Types (Request(..),RequestLine(..),Bodied(..),Header(Header))
import Text.Show.Pretty (pPrint)
import Control.Exception (bracket, throwIO)
import Data.Default (def)
import qualified Http.Headers as Headers
import qualified Network.Socket as N
import qualified Network.TLS.Extra.Cipher as Tls
import qualified Network.TLS as Tls
import Http.Exchange.Tls (SocketThrowingNetworkException (..), exchange)
import Http.Headers qualified as Headers
import Http.Types (Bodied (..), Header (Header), Request (..), RequestLine (..))
import Network.Socket qualified as N
import Network.TLS qualified as Tls
import Network.TLS.Extra.Cipher qualified as Tls
import Text.Show.Pretty (pPrint)

main :: IO ()
main = do
let noValidation = Tls.ValidationCache
(\_ _ _ -> return Tls.ValidationCachePass)
(\_ _ _ -> return ())
let clientParams = (Tls.defaultParamsClient "ifconfig.me" mempty)
{ Tls.clientSupported = def
{ Tls.supportedVersions = [Tls.TLS13]
, Tls.supportedCiphers =
[ Tls.cipher_TLS13_AES128GCM_SHA256
, Tls.cipher_TLS13_AES256GCM_SHA384
, Tls.cipher_TLS13_CHACHA20POLY1305_SHA256
, Tls.cipher_TLS13_AES128CCM_SHA256
, Tls.cipher_TLS13_AES128CCM8_SHA256
]
let noValidation =
Tls.ValidationCache
(\_ _ _ -> return Tls.ValidationCachePass)
(\_ _ _ -> return ())
let clientParams =
(Tls.defaultParamsClient "ifconfig.me" mempty)
{ Tls.clientSupported =
def
{ Tls.supportedVersions = [Tls.TLS13]
, Tls.supportedCiphers =
[ Tls.cipher_TLS13_AES128GCM_SHA256
, Tls.cipher_TLS13_AES256GCM_SHA384
, Tls.cipher_TLS13_CHACHA20POLY1305_SHA256
, Tls.cipher_TLS13_AES128CCM_SHA256
, Tls.cipher_TLS13_AES128CCM8_SHA256
]
}
, Tls.clientShared =
def
{ Tls.sharedValidationCache = noValidation
}
}
, Tls.clientShared = def
{ Tls.sharedValidationCache = noValidation
}
}
let hints = N.defaultHints { N.addrSocketType = N.Stream }
let hints = N.defaultHints {N.addrSocketType = N.Stream}
minfo <- N.getAddrInfo (Just hints) (Just "ifconfig.me") (Just "443")
info <- case minfo of
info : _ -> pure info
Expand All @@ -39,21 +43,26 @@ main = do
N.connect sock (N.addrAddress info)
ctx <- Tls.contextNew (SocketThrowingNetworkException sock) clientParams
Tls.handshake ctx
result <- exchange ctx Bodied
{ metadata = Request
{ requestLine = RequestLine
{ method = "GET"
, path = "/ip"
result <-
exchange
ctx
Bodied
{ metadata =
Request
{ requestLine =
RequestLine
{ method = "GET"
, path = "/ip"
}
, headers =
Headers.fromList
[ Header "Host" "ifconfig.me"
, Header "Accept" "text/plain"
, Header "User-Agent" "curl/0.0.0"
]
}
, body = mempty
}
, headers = Headers.fromList
[ Header "Host" "ifconfig.me"
, Header "Accept" "text/plain"
, Header "User-Agent" "curl/0.0.0"
]
}
, body = mempty
}
case result of
Left e -> throwIO e
Right resp -> pPrint resp

51 changes: 51 additions & 0 deletions fourmolu.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Number of spaces per indentation step
indentation: 2

# Max line length for automatic line breaking
column-limit: 200

# Styling of arrows in type signatures (choices: trailing, leading, or leading-args)
function-arrows: trailing

# How to place commas in multi-line lists, records, etc. (choices: leading or trailing)
comma-style: leading

# Styling of import/export lists (choices: leading, trailing, or diff-friendly)
import-export-style: leading

# Whether to full-indent or half-indent 'where' bindings past the preceding body
indent-wheres: false

# Whether to leave a space before an opening record brace
record-brace-space: true

# Number of spaces between top-level declarations
newlines-between-decls: 1

# How to print Haddock comments (choices: single-line, multi-line, or multi-line-compact)
haddock-style: multi-line

# How to print module docstring
haddock-style-module: null

# Styling of let blocks (choices: auto, inline, newline, or mixed)
let-style: auto

# How to align the 'in' keyword with respect to the 'let' keyword (choices: left-align, right-align, or no-space)
in-style: right-align

# Whether to put parentheses around a single constraint (choices: auto, always, or never)
single-constraint-parens: always

# Output Unicode syntax (choices: detect, always, or never)
unicode: never

# Give the programmer more choice on where to insert blank lines
respectful: true

# Fixity information for operators
fixities: []

# Module reexports Fourmolu should know about
reexports: []

Loading

0 comments on commit b83ca74

Please sign in to comment.