Skip to content

Commit

Permalink
Merge #1808
Browse files Browse the repository at this point in the history
1808: Windows CI using github-actions r=coot a=coot

Building natively and running tests using a VM provided by `github` using `github-actions`.

Co-authored-by: Marcin Szamotulski <[email protected]>
  • Loading branch information
iohk-bors[bot] and coot authored Mar 25, 2020
2 parents a5b88fb + ee87730 commit a6ca924
Show file tree
Hide file tree
Showing 5 changed files with 225 additions and 7 deletions.
181 changes: 181 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
name: "Ouroboros-Network"
on: [push]

# One cannot specify builddir in `cabal.project`: cabal issue #5271
#
# Run commands are using PowerShell by default; the quoting rules for
# PowerShell are described in this document:
# https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_quoting_rules?view=powershell-7
#
# Quoting for tasty `-p` command, this works (i.e. one needs to pass `\"` to
# tasty):
# ```
# -p '$0 != \"typed-protocols.Socket.socket send receive IPv4\"'
# ```
# or this will do too:
# ```
# -p "`$0 != \""typed-protocols.Socket.socket send receive IPv4\"""
# ``

jobs:
test-windows-8_6_5:
name: "Windows GHC-8.6.5"
runs-on: windows-latest
steps:
#
# Provisioning:
# * install ghc-8.6.5, msys2, cabal-isntall
# * setup path
# * close the repository
#
- name: Configure Chocolatey
run: choco source add -n mistuke -s https://www.myget.org/F/mistuke/api/v2
- name: Install msys2
run: choco install -y msys2
- name: Install GHC
run: choco install -y ghc --version 8.6.5
- name: Install Cabal
run: choco install -y cabal --version 3.0.0.0
- name: Set PATH
run: |
[Environment]::GetEnvironmentVariable("Path")
Write-Host "::add-path::C:\ProgramData\chocolatey\lib\cabal\tools\cabal-3.0.0.0"
Write-Host "::add-path::C:\ProgramData\chocolatey\lib\ghc\tools\ghc-8.6.5\bin"
- name: Print versions
run: |
ghc --version
cabal --version
cabal user-config init -a "http-transport: plain-http" -a "store-dir: C:\SR" -f -v3
# Cache cabal-store
- name: cache cabal store
uses: actions/cache@v1
with:
path: C:\SR
key: cabal-store-8.6.5
# Cache parts of dist-newstyle (C:\dist)
- name: cache buiddir [cache]
uses: actions/cache@v1
with:
path: C:\dist\cache
key: dist-cache
- name: cache buiddir [src]
uses: actions/cache@v1
with:
path: C:\dist\src
key: dist-src
- name: cache builddir [packagedb]
uses: actions/cache@v1
with:
path: C:\dist\packagedb
key: dist-packagedb

- name: update Hackage index
run: cabal v2-update

# checkout repository
- name: checkout ouroboros-network repository
uses: actions/checkout@v2

- name: Use cabal.project.local.windows
run: Copy-Item "./cabal.project.local.ci.windows" -Destination "./cabal.project.local"

#
# Build & Test network packages
#

# Win32-network
- name: Win32-network [dependencies]
run: cabal v2-build --builddir "C:\dist" --only-dependencies Win32-network

- name: Win32-network [build]
run: cabal v2-build --builddir "C:\dist" Win32-network

- name: Win32-network [test]
run: cabal v2-run --builddir "C:\dist" test-Win32-network

# ntp-client
- name: ntp-client [dependencies]
run: cabal v2-build --builddir "C:\dist" ntp-client

- name: ntp-client [build]
run: cabal v2-build --builddir "C:\dist" ntp-client

- name: ntp-client [test]
run: cabal v2-run test-ntp-client


# io-sim-classes
- name: io-sim-classes [dependencies]
run: cabal v2-build --only-dependencies --builddir "C:\dist" io-sim-classes

- name: io-sim-classes [build]
run: cabal v2-build --builddir "C:\dist" io-sim-classes


# io-sim
- name: io-sim [dependencies]
run: cabal v2-build --only-dependencies --builddir "C:\dist" io-sim

- name: io-sim [build]
run: cabal v2-build --builddir "C:\dist" io-sim

- name: io-sim [test]
run: cabal v2-run --builddir "C:\dist" test-sim


# typed-protocols
- name: typed-protcols [dependencies]
run: cabal v2-build --only-dependencies --builddir "C:\dist" typed-protocols

- name: typed-protocols [build]
run: cabal v2-build --builddir "C:\dist" typed-protocols


# typed-protocols-examples
- name: typed-protocols-examples [dependencies]
run: cabal v2-build --only-dependencies --builddir "C:\dist" typed-protocols-examples

- name: typed-protocols-examples [build]
run: cabal v2-build --builddir "C:\dist" typed-protocols-examples

- name: typed-protocols-examples [test]
run: cabal v2-run --builddir "C:\dist" typed-protocols-tests


# network-mux
- name: network-mux [dependencies]
run: cabal v2-build --only-dependencies --builddir "C:\dist" network-mux

- name: network-mux [build]
run: cabal v2-build --builddir "C:\dist" network-mux

- name: network-mux [test]
run: cabal v2-run --builddir "C:\dist" test-network-mux


# ouroboros-network-framework
- name: ouroboros-network-framework [dependencies]
run: cabal v2-build --only-dependencies --builddir "C:\dist" ouroboros-network-framework

- name: ouroboros-network-framework [build]
run: cabal v2-build --builddir "C:\dist" ouroboros-network-framework

# issue: #1818
- name: ourobors-network-framework [test]
run: cabal v2-run --builddir "C:\dist" ouroboros-network-framework-tests -- -p '$0 != \"typed-protocols.Socket.socket send receive IPv4\"'


# ouroboros-network
- name: ouroboros-network [dependencies]
run: cabal v2-build --only-dependencies --builddir "C:\dist" ouroboros-network

- name: ouroboros-network [build]
run: cabal v2-build --builddir "C:\dist" ouroboros-network

- name: ouroboros-network [test]
run: cabal v2-run --builddir "C:\dist" test-network

# TODO: we need to install the cddl tool
# - name: ouroboros-network [cddl]
# run: cabal v2-run --builddir "C:\dist" test-cddl
34 changes: 34 additions & 0 deletions cabal.project.local.ci.windows
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
tests: True

max-backjumps: 5000
reorder-goals: True

package Win32-network
ghc-options: -Werror
flags: +demo

package ntp-client
ghc-options: -Werror
flags: +demo

package io-sim-classes
ghc-options: -Werror
flags: +asserts +checktvarinvariant

package typed-protocols
ghc-options: -Werror

package typed-protocols-examples
ghc-options: -Werror
flags:

package network-mux
ghc-options: -Werror
flags: +ipv6 +asserts

package ouroboros-network-framework
ghc-options: -Werror

package ouroboros-network
ghc-options: -Werror
flags: +ipv6 +cddl +asserts
9 changes: 5 additions & 4 deletions network-mux/demo/mux-demo.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import Test.Mux.ReqResp
import System.Win32
import System.Win32.NamedPipes
import qualified System.Win32.Async as Win32.Async
import System.IOManager

import System.IO
import System.Exit
Expand Down Expand Up @@ -71,7 +72,7 @@ defaultProtocolLimits =
-- | Server accept loop.
--
echoServer :: IO ()
echoServer = Win32.Async.withIOManager $ \iocp -> do
echoServer = withIOManager $ \ioManager -> do
hpipe <- createNamedPipe pipeName
(pIPE_ACCESS_DUPLEX .|. fILE_FLAG_OVERLAPPED)
(pIPE_TYPE_BYTE .|. pIPE_READMODE_BYTE)
Expand All @@ -80,7 +81,7 @@ echoServer = Win32.Async.withIOManager $ \iocp -> do
1024
0
Nothing
Win32.Async.associateWithIOCompletionPort (Left hpipe) iocp
associateWithIOManager ioManager (Left hpipe)
Win32.Async.connectNamedPipe hpipe
_ <- forkIO $ do
serverLoop hpipe
Expand Down Expand Up @@ -122,15 +123,15 @@ serverLoop h = do


client :: Int -> String -> IO ()
client n msg = Win32.Async.withIOManager $ \iocp -> do
client n msg = withIOManager $ \ioManager -> do
hpipe <- createFile pipeName
(gENERIC_READ .|. gENERIC_WRITE)
fILE_SHARE_NONE
Nothing
oPEN_EXISTING
fILE_FLAG_OVERLAPPED
Nothing
Win32.Async.associateWithIOCompletionPort (Left hpipe) iocp
associateWithIOManager ioManager (Left hpipe)
let pipeChannel = Mx.pipeChannelFromNamedPipe hpipe
bearer = Mx.pipeAsMuxBearer nullTracer pipeChannel
Mx.muxStart
Expand Down
7 changes: 4 additions & 3 deletions network-mux/test/Test/Mux.hs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import Control.Tracer (Tracer (..), contramap, nullTracer)
import qualified System.Win32.NamedPipes as Win32.NamedPipes
import qualified System.Win32.File as Win32.File
import qualified System.Win32.Async as Win32.Async
import System.IOManager
#else
import System.IO (hClose)
import System.Process (createPipe)
Expand Down Expand Up @@ -460,7 +461,7 @@ runWithQueues initApp respApp = do
runWithPipe :: RunMuxApplications
runWithPipe initApp respApp =
#if defined(mingw32_HOST_OS)
Win32.Async.withIOManager $ \iocp -> do
withIOManager $ \ioManager -> do
let pipeName = "\\\\.\\pipe\\mux-test-pipe"
bracket
(Win32.NamedPipes.createNamedPipe
Expand All @@ -484,8 +485,8 @@ runWithPipe initApp respApp =
Nothing)
Win32.File.closeHandle
$ \hCli -> do
Win32.Async.associateWithIOCompletionPort (Left hSrv) iocp
Win32.Async.associateWithIOCompletionPort (Left hCli) iocp
associateWithIOManager ioManager (Left hSrv)
associateWithIOManager ioManager (Left hCli)

let clientChannel = pipeChannelFromNamedPipe hCli
serverChannel = pipeChannelFromNamedPipe hSrv
Expand Down
1 change: 1 addition & 0 deletions ouroboros-network/test/Test/Pipe.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import Data.Bits ((.|.))
import qualified System.Win32.NamedPipes as Win32.NamedPipes
import qualified System.Win32.Async as Win32.Async
import qualified System.Win32 as Win32
import System.IOManager
#else
import System.Process (createPipe)
import System.IO (hClose)
Expand Down

0 comments on commit a6ca924

Please sign in to comment.