Skip to content

Move tests to separate process-tests package & update CI to use GitHub actions #310

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 99 additions & 30 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,114 @@ name: Tests
on:
pull_request:
push:
branches:
- master
branches:
- '**'

jobs:
build:
name: CI
name: GHC ${{ matrix.ghc-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
args:
- "--resolver ghc-9.8.1"
- "--resolver ghc-9.6.3"
- "--resolver ghc-9.4.7"
- "--resolver ghc-9.2.8"
- "--resolver ghc-9.0.1"
- "--resolver ghc-8.10.4"
- "--resolver ghc-8.8.4"
- "--resolver ghc-8.6.5"
- "--resolver ghc-8.4.4"
- "--resolver ghc-8.2.2"
ghc-version:
- 'latest'
- '9.8'
- '9.6'
- '9.4'
- '9.2'
- '9.0'
- '8.10'
- '8.8'
- '8.6'
- '8.4'
- '8.2'

exclude:
# Exclude GHC 8.2 on Windows (GHC bug: undefined reference to `__stdio_common_vswprintf_s')
- os: windows-latest
ghc-version: '8.2'

steps:
- name: Clone project
uses: actions/checkout@v4
- uses: actions/checkout@v4

- name: Set up GHC ${{ matrix.ghc-version }}
uses: haskell-actions/setup@v2
id: setup
with:
ghc-version: ${{ matrix.ghc-version }}
# Defaults, added for clarity:
cabal-version: 'latest'
cabal-update: true

- name: Set up autotools (Windows)
if: ${{ runner.os == 'Windows' }}
uses: msys2/setup-msys2@v2
with:
update: true
install: >-
autotools

- name: Run autoreconf (Windows)
if: ${{ runner.os == 'Windows' }}
run: autoreconf -i
shell: "msys2 {0}"

- name: Build and run tests
shell: bash
- name: Run autoreconf (Linux & Mac)
if: ${{ runner.os != 'Windows' }}
run: autoreconf -i

- name: Configure the build
run: |
set -ex
stack upgrade
stack --version
if [[ "${{ runner.os }}" = 'Windows' ]]
then
# Looks like a bug in Stack, this shouldn't break things
ls C:/ProgramData/Chocolatey/bin/
rm -rf C:/ProgramData/Chocolatey/bin/ghc*
stack ${{ matrix.args }} exec pacman -- --sync --refresh --noconfirm autoconf
fi
stack test --bench --no-run-benchmarks --haddock --no-terminal ${{ matrix.args }}
stack sdist --test-tarball
cabal configure --enable-tests --enable-benchmarks --disable-documentation
cabal build all --dry-run
# The last step generates dist-newstyle/cache/plan.json for the cache key.

- name: Restore cached dependencies
uses: actions/cache/restore@v3
id: cache
env:
key: ${{ runner.os }}-ghc-${{ steps.setup.outputs.ghc-version }}-cabal-${{ steps.setup.outputs.cabal-version }}
with:
path: ${{ steps.setup.outputs.cabal-store }}
key: ${{ env.key }}-plan-${{ hashFiles('**/plan.json') }}
restore-keys: ${{ env.key }}-

- name: Install dependencies
# If we had an exact cache hit, the dependencies will be up to date.
if: steps.cache.outputs.cache-hit != 'true'
run: cabal build process --only-dependencies

# Cache dependencies already here, so that we do not have to rebuild them should the subsequent steps fail.
- name: Save cached dependencies
uses: actions/cache/save@v3
# If we had an exact cache hit, trying to save the cache would error because of key clash.
if: steps.cache.outputs.cache-hit != 'true'
with:
path: ${{ steps.setup.outputs.cabal-store }}
key: ${{ steps.cache.outputs.cache-primary-key }}

- name: Build
run: cabal build process

- name: Run tests
run: cabal run process-tests:test

# On Windows and with GHC >= 9.0, re-run the test-suite using WinIO.
- name: Re-run tests with WinIO (Windows && GHC >= 9.0)
if: ${{ runner.os == 'Windows' && matrix.ghc-version >= '9.0' }}
run: cabal run process-tests:test -- +RTS --io-manager=native -RTS

- name: Source dist
run: cabal sdist all --ignore-project

- name: Build documentation
run: cabal haddock process

- name: Check process.cabal
run: cabal check

- name: Check process-tests.cabal
working-directory: ./test
run: cabal check
13 changes: 7 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
/.cabal-sandbox/
/cabal.project.local
/cabal.sandbox.config
/dist/
/dist-newstyle/
/.stack-work/
**/.cabal-sandbox/
**/cabal.project.local
**/cabal.sandbox.config
**/dist/
**/dist-newstyle/
**/.stack-work/
*.swp
stack.yaml.lock

# Specific generated files
GNUmakefile
Expand Down
5 changes: 5 additions & 0 deletions Setup.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
module Main (main) where

import Distribution.Simple
( defaultMainWithHooks
, autoconfUserHooks
)

--------------------------------------------------------------------------------

main :: IO ()
main = defaultMainWithHooks autoconfUserHooks
13 changes: 6 additions & 7 deletions System/Process.hs
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,12 @@ import System.IO.Error (mkIOError, ioeSetErrorString)

#if defined(javascript_HOST_ARCH)
import System.Process.JavaScript(getProcessId, getCurrentProcessId)
#elif defined(WINDOWS)
#elif defined(mingw32_HOST_OS)
import System.Win32.Process (getProcessId, getCurrentProcessId, ProcessId)
#else
import System.Posix.Process (getProcessID)
import System.Posix.Types (CPid (..))
#endif

import GHC.IO.Exception ( ioException, IOErrorType(..), IOException(..) )

#if defined(wasm32_HOST_ARCH)
Expand All @@ -126,7 +125,7 @@ import System.IO.Error
-- @since 1.6.3.0
#if defined(javascript_HOST_ARCH)
type Pid = Int
#elif defined(WINDOWS)
#elif defined(mingw32_HOST_OS)
type Pid = ProcessId
#else
type Pid = CPid
Expand Down Expand Up @@ -668,7 +667,7 @@ getPid (ProcessHandle mh _ _) = do
OpenHandle h -> do
pid <- getProcessId h
return $ Just pid
#elif defined(WINDOWS)
#elif defined(mingw32_HOST_OS)
OpenHandle h -> do
pid <- getProcessId h
return $ Just pid
Expand All @@ -691,7 +690,7 @@ getCurrentPid :: IO Pid
getCurrentPid =
#if defined(javascript_HOST_ARCH)
getCurrentProcessId
#elif defined(WINDOWS)
#elif defined(mingw32_HOST_OS)
getCurrentProcessId
#else
getProcessID
Expand Down Expand Up @@ -743,7 +742,7 @@ waitForProcess ph@(ProcessHandle _ delegating_ctlc _) = lockWaitpid $ do
when (was_open && delegating_ctlc) $
endDelegateControlC e
return e'
#if defined(WINDOWS)
#if defined(mingw32_HOST_OS)
OpenExtHandle h job -> do
-- First wait for completion of the job...
waitForJobCompletion job
Expand Down Expand Up @@ -872,7 +871,7 @@ terminateProcess ph = do
withProcessHandle ph $ \p_ ->
case p_ of
ClosedHandle _ -> return ()
#if defined(WINDOWS)
#if defined(mingw32_HOST_OS)
OpenExtHandle{} -> terminateJobUnsafe p_ 1 >> return ()
#else
OpenExtHandle{} -> error "terminateProcess with OpenExtHandle should not happen on POSIX."
Expand Down
6 changes: 3 additions & 3 deletions System/Process/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module System.Process.Common
, pfdToHandle

-- Avoid a warning on Windows
#ifdef WINDOWS
#if defined(mingw32_HOST_OS)
, CGid (..)
#else
, CGid
Expand Down Expand Up @@ -63,7 +63,7 @@ import GHC.JS.Prim (JSVal)

-- We do a minimal amount of CPP here to provide uniform data types across
-- Windows and POSIX.
#ifdef WINDOWS
#if defined(mingw32_HOST_OS)
import Data.Word (Word32)
import System.Win32.DebugApi (PHANDLE)
#if defined(__IO_MANAGER_WINIO__)
Expand All @@ -75,7 +75,7 @@ import System.Posix.Types

#if defined(javascript_HOST_ARCH)
type PHANDLE = JSVal
#elif defined(WINDOWS)
#elif defined(mingw32_HOST_OS)
-- Define some missing types for Windows compatibility. Note that these values
-- will never actually be used, as the setuid/setgid system calls are not
-- applicable on Windows. No value of this type will ever exist.
Expand Down
6 changes: 3 additions & 3 deletions System/Process/Internals.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
module System.Process.Internals (
ProcessHandle(..), ProcessHandle__(..),
PHANDLE, closePHANDLE, mkProcessHandle,
#ifdef WINDOWS
#if defined(mingw32_HOST_OS)
CGid(..),
#else
CGid,
Expand All @@ -39,7 +39,7 @@ module System.Process.Internals (
endDelegateControlC,
stopDelegateControlC,
unwrapHandles,
#ifdef WINDOWS
#if defined(mingw32_HOST_OS)
terminateJob,
terminateJobUnsafe,
waitForJobCompletion,
Expand Down Expand Up @@ -68,7 +68,7 @@ import System.Process.Common

#if defined(javascript_HOST_ARCH)
import System.Process.JavaScript
#elif defined(WINDOWS)
#elif defined(mingw32_HOST_OS)
import System.Process.Windows
#else
import System.Process.Posix
Expand Down
1 change: 1 addition & 0 deletions cabal.project
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
packages: ., test
24 changes: 5 additions & 19 deletions process.cabal
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
cabal-version: 2.4
name: process
version: 1.6.19.0
-- NOTE: Don't forget to update ./changelog.md
license: BSD3
license: BSD-3-Clause
license-file: LICENSE
maintainer: [email protected]
bug-reports: https://github.com/haskell/process/issues
synopsis: Process libraries
category: System
build-type: Configure
cabal-version: >=1.10
description:
This package contains libraries for dealing with system processes.
.
Expand All @@ -18,9 +18,11 @@ description:
read more about it at
<https://github.com/fpco/typed-process/#readme>.

extra-doc-files:
changelog.md

extra-source-files:
aclocal.m4
changelog.md
configure
configure.ac
include/HsProcessConfig.h.in
Expand Down Expand Up @@ -90,19 +92,3 @@ library
directory >= 1.1 && < 1.4,
filepath >= 1.2 && < 1.6,
deepseq >= 1.1 && < 1.6

test-suite test
default-language: Haskell2010
hs-source-dirs: test
main-is: main.hs
type: exitcode-stdio-1.0
-- Add otherwise redundant bounds on base since GHC's build system runs
-- `cabal check`, which mandates bounds on base.
build-depends: base >= 4 && < 5
, bytestring
, directory
, process
ghc-options: -threaded
-with-rtsopts "-N"
if os(windows)
cpp-options: -DWINDOWS
11 changes: 11 additions & 0 deletions stack.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
resolver: ghc-9.2.3

packages:
- .
- test

extra-deps:
- Cabal-3.6.3.0

allow-newer: True
allow-newer-deps:
- Cabal
31 changes: 31 additions & 0 deletions test/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Copyright (c) 2024, the Haskell process developers.

All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.

* Neither the name of Isaac Jones nor the names of other
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2 changes: 1 addition & 1 deletion test/main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ifWindows action
| otherwise = action

isWindows :: Bool
#if WINDOWS
#if defined(mingw32_HOST_OS)
isWindows = True
#else
isWindows = False
Expand Down
Loading
Loading