Skip to content

Commit

Permalink
Add support for building on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
newhoggy committed Oct 6, 2020
1 parent d0341e2 commit f6a6549
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 28 deletions.
101 changes: 75 additions & 26 deletions .github/workflows/haskell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ on: [push]

jobs:
build:
runs-on: ubuntu-18.04
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
ghc: ["8.6.5"]
os: [ubuntu-latest, windows-latest]

steps:
- uses: actions/checkout@v1
Expand All @@ -19,12 +25,20 @@ jobs:
echo "BINARY_CACHE_THREADS: $BINARY_CACHE_THREADS"
echo "BINARY_CACHE_URI: $BINARY_CACHE_URI"
- uses: actions/setup-haskell@v1.1
- uses: msys2/setup-msys2@v2
if: matrix.os == 'windows-latest'
with:
update: true
install: autoconf

- uses: actions/setup-haskell@v1
id: setup-haskell
with:
ghc-version: '8.6.5'
cabal-version: '3.4.0.0'
ghc-version: ${{ matrix.ghc }}
cabal-version: '3.2.0.0'

- name: Install build environment
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get -y install libsodium23 libsodium-dev
Expand All @@ -37,46 +51,80 @@ jobs:
flags: -external-libsodium-vrf
EOF
- name: Install cabal-cache tool
run: |
CACHE_TOOL_TAG=$(curl -s -X GET https://api.github.com/repos/haskell-works/cabal-cache/releases/latest | jq -rc .tag_name)
echo "Downloading: https://github.com/haskell-works/cabal-cache/releases/download/${CACHE_TOOL_TAG}/cabal-cache_x86_64_linux.tar.gz"
curl -Ls https://github.com/haskell-works/cabal-cache/releases/download/${CACHE_TOOL_TAG}/cabal-cache_x86_64_linux.tar.gz | tar -xvz -C /tmp/
sudo cp /tmp/cabal-cache /usr/local/bin/cabal-cache
cabal-cache version
- name: Cabal update
run: cabal update

- name: Cabal Configure
run: cabal configure

- name: Restore cabal cache
uses: haskell-works/cabal-cache-action@v1
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
BINARY_CACHE_REGION: ${{ secrets.BINARY_CACHE_REGION }}
BINARY_CACHE_THREADS: ${{ secrets.BINARY_CACHE_THREADS }}
BINARY_CACHE_URI: ${{ secrets.BINARY_CACHE_URI }}
with:
args: |
sync-from-archive \
--threads "$BINARY_CACHE_THREADS" \
--archive-uri "$BINARY_CACHE_URI" \
--region "$BINARY_CACHE_REGION"
- name: Select build directory
run: echo "::set-output name=CABAL_BUILDDIR::dist"

- name: Install dependencies (Posix)
if: matrix.os != 'windows-latest'
run: cabal build all --builddir dist --enable-tests --enable-benchmarks --write-ghc-environment-files=always --only-dependencies

- name: Install dependencies (Windows)
if: matrix.os == 'windows-latest'
run: |
cabal-cache sync-from-archive \
--threads "$BINARY_CACHE_THREADS" \
--archive-uri "$BINARY_CACHE_URI" \
--region "$BINARY_CACHE_REGION"
echo "Path bash: $PATH"
msys2 -c 'echo "Path msys2: $PATH"'
msys2 -c "cabal build all --builddir dist --enable-tests --enable-benchmarks --write-ghc-environment-files=always --only-dependencies"
- name: Install dependencies
run: cabal build all --enable-tests --enable-benchmarks --write-ghc-environment-files=always --only-dependencies
- name: Build (Posix)
if: matrix.os != 'windows-latest'
run: cabal build all --builddir dist --enable-tests --enable-benchmarks --write-ghc-environment-files=always

- name: Build
run: cabal build all --enable-tests --enable-benchmarks --write-ghc-environment-files=always
- name: Build (Windows)
if: matrix.os == 'windows-latest'
run: msys2 -c "cabal build all --builddir dist --enable-tests --enable-benchmarks --write-ghc-environment-files=always"

- name: Save cabal cache
uses: haskell-works/cabal-cache-action@v1
if: ${{ always() }}
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
BINARY_CACHE_REGION: ${{ secrets.BINARY_CACHE_REGION }}
BINARY_CACHE_THREADS: ${{ secrets.BINARY_CACHE_THREADS }}
BINARY_CACHE_URI: ${{ secrets.BINARY_CACHE_URI }}
with:
args: |
sync-to-archive \
--threads "$BINARY_CACHE_THREADS" \
--archive-uri "$BINARY_CACHE_URI" \
--region "$BINARY_CACHE_REGION"
- name: Git clone
run: git clone https://github.com/input-output-hk/cardano-mainnet-mirror

- name: Run tests
run: cabal test cardano-cli cardano-node cardano-node-chairman --enable-tests --enable-benchmarks --write-ghc-environment-files=always --test-show-details=direct --test-options='+RTS -g1'
run: |
cabal test cardano-cli cardano-node cardano-node-chairman \
--builddir dist \
--enable-tests \
--enable-benchmarks \
--write-ghc-environment-files=always \
--test-show-details=direct \
--test-options='+RTS -g1'
- name: Save cabal cache
uses: haskell-works/cabal-cache-action@v1
if: ${{ always() }}
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
Expand All @@ -85,8 +133,9 @@ jobs:
BINARY_CACHE_THREADS: ${{ secrets.BINARY_CACHE_THREADS }}
BINARY_CACHE_URI: ${{ secrets.BINARY_CACHE_URI }}
CARDANO_MAINNET_MIRROR: cardano-mainnet-mirror/epoch
run: |
cabal-cache sync-to-archive \
--threads "$BINARY_CACHE_THREADS" \
--archive-uri "$BINARY_CACHE_URI" \
--region "$BINARY_CACHE_REGION"
with:
args: |
sync-to-archive \
--threads "$BINARY_CACHE_THREADS" \
--archive-uri "$BINARY_CACHE_URI" \
--region "$BINARY_CACHE_REGION"
12 changes: 10 additions & 2 deletions hedgehog-extras/src/Hedgehog/Extras/Test/Process.hs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,17 @@ import qualified Hedgehog.Extras.Test.Base as H
import qualified System.Directory as IO
import qualified System.Environment as IO
import qualified System.Exit as IO
import qualified System.IO.Unsafe as IO
import qualified System.Process as IO

planJsonFile :: String
planJsonFile = IO.unsafePerformIO $ do
maybeBuildDir <- liftIO $ IO.lookupEnv "CABAL_BUILDDIR"
case maybeBuildDir of
Just buildDir -> return buildDir
Nothing -> return "../dist-newstyle/cache/plan.json"
{-# NOINLINE planJsonFile #-}

-- | Create a process returning handles to stdin, stdout, and stderr as well as the process handle.
createProcess
:: (MonadTest m, MonadResource m, HasCallStack)
Expand Down Expand Up @@ -157,8 +166,7 @@ procDist
-> m CreateProcess
-- ^ Captured stdout
procDist pkg arguments = do
base <- getProjectBase
contents <- H.evalIO . LBS.readFile $ base </> "dist-newstyle/cache/plan.json"
contents <- H.evalIO . LBS.readFile $ planJsonFile

case eitherDecode contents of
Right plan -> case L.filter matching (plan & installPlan) of
Expand Down

0 comments on commit f6a6549

Please sign in to comment.