From 9aaaac3c5f1e3c59168178d4acb00f357dfd96d3 Mon Sep 17 00:00:00 2001 From: Ben Franksen Date: Sat, 11 Mar 2023 20:12:57 +0100 Subject: [PATCH] Add github actions to test building --- .github/workflows/build.yml | 57 ++++++++++++++++++++++++++ src/System/Console/Terminal/Windows.hs | 2 +- 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..3b4da86 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,57 @@ +name: Build + +on: push + +jobs: + build-with-cabal: + name: ${{ matrix.os }} / ghc-${{ matrix.ghc }} + + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: + - ubuntu-latest + - macOS-latest + - windows-2022 + ghc: + - 8.2.2 + - 8.4.4 + - 8.6.5 + - 8.8.2 + - 8.10.7 + - 9.0.2 + - 9.2.4 + - 9.4.2 + cabal: + - latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup Haskell + id: setup-haskell-cabal + uses: haskell/actions/setup@v2 + with: + ghc-version: ${{ matrix.ghc }} + cabal-version: ${{ matrix.cabal }} + + - name: Cache cabal store + uses: actions/cache@v3 + with: + path: ${{ steps.setup-haskell-cabal.outputs.cabal-store }} + key: cabal-store-${{ matrix.os }}-ghc-${{ matrix.ghc }}-${{ hashFiles('terminal-size.cabal') }} + restore-keys: cabal-store-${{ matrix.os }}-ghc-${{ matrix.ghc }}- + + - name: Build dependencies + run: cabal build --only-dependencies + + - name: Build + run: cabal build --write-ghc-environment-files=always + + - name: Build Test Program + # It would be nice if we could also run it. But that doesn't work + # because the std handles are redirected in the gihub runner + # so hSize always returns Nothing. + run: ghc test.hs diff --git a/src/System/Console/Terminal/Windows.hs b/src/System/Console/Terminal/Windows.hs index ea6ed14..816bbe9 100644 --- a/src/System/Console/Terminal/Windows.hs +++ b/src/System/Console/Terminal/Windows.hs @@ -20,7 +20,7 @@ hSize :: Integral n => Handle -> IO (Maybe (Window n)) hSize hdl = withHandleToHANDLE hdl nativeSize `catchIOError` \_ -> do - -- This could happen on Cygwin or MSYS + -- Fallback to use for Cygwin or MSYS let stty = (shell "stty size") { std_in = UseHandle hdl , std_out = CreatePipe