Skip to content

Commit dbf4add

Browse files
authored
Merge pull request #310 from sheaf/ci
Move tests to separate process-tests package & update CI to use GitHub actions
2 parents 3aecb17 + 13ede6d commit dbf4add

File tree

12 files changed

+202
-69
lines changed

12 files changed

+202
-69
lines changed

.github/workflows/tests.yml

Lines changed: 99 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,45 +3,114 @@ name: Tests
33
on:
44
pull_request:
55
push:
6-
branches:
7-
- master
6+
branches:
7+
- '**'
88

99
jobs:
1010
build:
11-
name: CI
11+
name: GHC ${{ matrix.ghc-version }} on ${{ matrix.os }}
1212
runs-on: ${{ matrix.os }}
1313
strategy:
1414
fail-fast: false
1515
matrix:
1616
os: [ubuntu-latest, macos-latest, windows-latest]
17-
args:
18-
- "--resolver ghc-9.8.1"
19-
- "--resolver ghc-9.6.3"
20-
- "--resolver ghc-9.4.7"
21-
- "--resolver ghc-9.2.8"
22-
- "--resolver ghc-9.0.1"
23-
- "--resolver ghc-8.10.4"
24-
- "--resolver ghc-8.8.4"
25-
- "--resolver ghc-8.6.5"
26-
- "--resolver ghc-8.4.4"
27-
- "--resolver ghc-8.2.2"
17+
ghc-version:
18+
- 'latest'
19+
- '9.8'
20+
- '9.6'
21+
- '9.4'
22+
- '9.2'
23+
- '9.0'
24+
- '8.10'
25+
- '8.8'
26+
- '8.6'
27+
- '8.4'
28+
- '8.2'
29+
30+
exclude:
31+
# Exclude GHC 8.2 on Windows (GHC bug: undefined reference to `__stdio_common_vswprintf_s')
32+
- os: windows-latest
33+
ghc-version: '8.2'
2834

2935
steps:
30-
- name: Clone project
31-
uses: actions/checkout@v4
36+
- uses: actions/checkout@v4
37+
38+
- name: Set up GHC ${{ matrix.ghc-version }}
39+
uses: haskell-actions/setup@v2
40+
id: setup
41+
with:
42+
ghc-version: ${{ matrix.ghc-version }}
43+
# Defaults, added for clarity:
44+
cabal-version: 'latest'
45+
cabal-update: true
46+
47+
- name: Set up autotools (Windows)
48+
if: ${{ runner.os == 'Windows' }}
49+
uses: msys2/setup-msys2@v2
50+
with:
51+
update: true
52+
install: >-
53+
autotools
54+
55+
- name: Run autoreconf (Windows)
56+
if: ${{ runner.os == 'Windows' }}
57+
run: autoreconf -i
58+
shell: "msys2 {0}"
3259

33-
- name: Build and run tests
34-
shell: bash
60+
- name: Run autoreconf (Linux & Mac)
61+
if: ${{ runner.os != 'Windows' }}
62+
run: autoreconf -i
63+
64+
- name: Configure the build
3565
run: |
36-
set -ex
37-
stack upgrade
38-
stack --version
39-
if [[ "${{ runner.os }}" = 'Windows' ]]
40-
then
41-
# Looks like a bug in Stack, this shouldn't break things
42-
ls C:/ProgramData/Chocolatey/bin/
43-
rm -rf C:/ProgramData/Chocolatey/bin/ghc*
44-
stack ${{ matrix.args }} exec pacman -- --sync --refresh --noconfirm autoconf
45-
fi
46-
stack test --bench --no-run-benchmarks --haddock --no-terminal ${{ matrix.args }}
47-
stack sdist --test-tarball
66+
cabal configure --enable-tests --enable-benchmarks --disable-documentation
67+
cabal build all --dry-run
68+
# The last step generates dist-newstyle/cache/plan.json for the cache key.
69+
70+
- name: Restore cached dependencies
71+
uses: actions/cache/restore@v3
72+
id: cache
73+
env:
74+
key: ${{ runner.os }}-ghc-${{ steps.setup.outputs.ghc-version }}-cabal-${{ steps.setup.outputs.cabal-version }}
75+
with:
76+
path: ${{ steps.setup.outputs.cabal-store }}
77+
key: ${{ env.key }}-plan-${{ hashFiles('**/plan.json') }}
78+
restore-keys: ${{ env.key }}-
79+
80+
- name: Install dependencies
81+
# If we had an exact cache hit, the dependencies will be up to date.
82+
if: steps.cache.outputs.cache-hit != 'true'
83+
run: cabal build process --only-dependencies
84+
85+
# Cache dependencies already here, so that we do not have to rebuild them should the subsequent steps fail.
86+
- name: Save cached dependencies
87+
uses: actions/cache/save@v3
88+
# If we had an exact cache hit, trying to save the cache would error because of key clash.
89+
if: steps.cache.outputs.cache-hit != 'true'
90+
with:
91+
path: ${{ steps.setup.outputs.cabal-store }}
92+
key: ${{ steps.cache.outputs.cache-primary-key }}
93+
94+
- name: Build
95+
run: cabal build process
96+
97+
- name: Run tests
98+
run: cabal run process-tests:test
99+
100+
# On Windows and with GHC >= 9.0, re-run the test-suite using WinIO.
101+
- name: Re-run tests with WinIO (Windows && GHC >= 9.0)
102+
if: ${{ runner.os == 'Windows' && matrix.ghc-version >= '9.0' }}
103+
run: cabal run process-tests:test -- +RTS --io-manager=native -RTS
104+
105+
- name: Source dist
106+
run: cabal sdist all --ignore-project
107+
108+
- name: Build documentation
109+
run: cabal haddock process
110+
111+
- name: Check process.cabal
112+
run: cabal check
113+
114+
- name: Check process-tests.cabal
115+
working-directory: ./test
116+
run: cabal check

.gitignore

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
/.cabal-sandbox/
2-
/cabal.project.local
3-
/cabal.sandbox.config
4-
/dist/
5-
/dist-newstyle/
6-
/.stack-work/
1+
**/.cabal-sandbox/
2+
**/cabal.project.local
3+
**/cabal.sandbox.config
4+
**/dist/
5+
**/dist-newstyle/
6+
**/.stack-work/
77
*.swp
8+
stack.yaml.lock
89

910
# Specific generated files
1011
GNUmakefile

Setup.hs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
module Main (main) where
22

33
import Distribution.Simple
4+
( defaultMainWithHooks
5+
, autoconfUserHooks
6+
)
7+
8+
--------------------------------------------------------------------------------
49

510
main :: IO ()
611
main = defaultMainWithHooks autoconfUserHooks

System/Process.hs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,12 @@ import System.IO.Error (mkIOError, ioeSetErrorString)
105105

106106
#if defined(javascript_HOST_ARCH)
107107
import System.Process.JavaScript(getProcessId, getCurrentProcessId)
108-
#elif defined(WINDOWS)
108+
#elif defined(mingw32_HOST_OS)
109109
import System.Win32.Process (getProcessId, getCurrentProcessId, ProcessId)
110110
#else
111111
import System.Posix.Process (getProcessID)
112112
import System.Posix.Types (CPid (..))
113113
#endif
114-
115114
import GHC.IO.Exception ( ioException, IOErrorType(..), IOException(..) )
116115

117116
#if defined(wasm32_HOST_ARCH)
@@ -126,7 +125,7 @@ import System.IO.Error
126125
-- @since 1.6.3.0
127126
#if defined(javascript_HOST_ARCH)
128127
type Pid = Int
129-
#elif defined(WINDOWS)
128+
#elif defined(mingw32_HOST_OS)
130129
type Pid = ProcessId
131130
#else
132131
type Pid = CPid
@@ -668,7 +667,7 @@ getPid (ProcessHandle mh _ _) = do
668667
OpenHandle h -> do
669668
pid <- getProcessId h
670669
return $ Just pid
671-
#elif defined(WINDOWS)
670+
#elif defined(mingw32_HOST_OS)
672671
OpenHandle h -> do
673672
pid <- getProcessId h
674673
return $ Just pid
@@ -691,7 +690,7 @@ getCurrentPid :: IO Pid
691690
getCurrentPid =
692691
#if defined(javascript_HOST_ARCH)
693692
getCurrentProcessId
694-
#elif defined(WINDOWS)
693+
#elif defined(mingw32_HOST_OS)
695694
getCurrentProcessId
696695
#else
697696
getProcessID
@@ -743,7 +742,7 @@ waitForProcess ph@(ProcessHandle _ delegating_ctlc _) = lockWaitpid $ do
743742
when (was_open && delegating_ctlc) $
744743
endDelegateControlC e
745744
return e'
746-
#if defined(WINDOWS)
745+
#if defined(mingw32_HOST_OS)
747746
OpenExtHandle h job -> do
748747
-- First wait for completion of the job...
749748
waitForJobCompletion job
@@ -872,7 +871,7 @@ terminateProcess ph = do
872871
withProcessHandle ph $ \p_ ->
873872
case p_ of
874873
ClosedHandle _ -> return ()
875-
#if defined(WINDOWS)
874+
#if defined(mingw32_HOST_OS)
876875
OpenExtHandle{} -> terminateJobUnsafe p_ 1 >> return ()
877876
#else
878877
OpenExtHandle{} -> error "terminateProcess with OpenExtHandle should not happen on POSIX."

System/Process/Common.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module System.Process.Common
2121
, pfdToHandle
2222

2323
-- Avoid a warning on Windows
24-
#ifdef WINDOWS
24+
#if defined(mingw32_HOST_OS)
2525
, CGid (..)
2626
#else
2727
, CGid
@@ -63,7 +63,7 @@ import GHC.JS.Prim (JSVal)
6363

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

7676
#if defined(javascript_HOST_ARCH)
7777
type PHANDLE = JSVal
78-
#elif defined(WINDOWS)
78+
#elif defined(mingw32_HOST_OS)
7979
-- Define some missing types for Windows compatibility. Note that these values
8080
-- will never actually be used, as the setuid/setgid system calls are not
8181
-- applicable on Windows. No value of this type will ever exist.

System/Process/Internals.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
module System.Process.Internals (
2323
ProcessHandle(..), ProcessHandle__(..),
2424
PHANDLE, closePHANDLE, mkProcessHandle,
25-
#ifdef WINDOWS
25+
#if defined(mingw32_HOST_OS)
2626
CGid(..),
2727
#else
2828
CGid,
@@ -39,7 +39,7 @@ module System.Process.Internals (
3939
endDelegateControlC,
4040
stopDelegateControlC,
4141
unwrapHandles,
42-
#ifdef WINDOWS
42+
#if defined(mingw32_HOST_OS)
4343
terminateJob,
4444
terminateJobUnsafe,
4545
waitForJobCompletion,
@@ -68,7 +68,7 @@ import System.Process.Common
6868

6969
#if defined(javascript_HOST_ARCH)
7070
import System.Process.JavaScript
71-
#elif defined(WINDOWS)
71+
#elif defined(mingw32_HOST_OS)
7272
import System.Process.Windows
7373
#else
7474
import System.Process.Posix

cabal.project

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
packages: ., test

process.cabal

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1+
cabal-version: 2.4
12
name: process
23
version: 1.6.19.0
34
-- NOTE: Don't forget to update ./changelog.md
4-
license: BSD3
5+
license: BSD-3-Clause
56
license-file: LICENSE
67
maintainer: [email protected]
78
bug-reports: https://github.com/haskell/process/issues
89
synopsis: Process libraries
910
category: System
1011
build-type: Configure
11-
cabal-version: >=1.10
1212
description:
1313
This package contains libraries for dealing with system processes.
1414
.
@@ -18,9 +18,11 @@ description:
1818
read more about it at
1919
<https://github.com/fpco/typed-process/#readme>.
2020

21+
extra-doc-files:
22+
changelog.md
23+
2124
extra-source-files:
2225
aclocal.m4
23-
changelog.md
2426
configure
2527
configure.ac
2628
include/HsProcessConfig.h.in
@@ -90,19 +92,3 @@ library
9092
directory >= 1.1 && < 1.4,
9193
filepath >= 1.2 && < 1.6,
9294
deepseq >= 1.1 && < 1.6
93-
94-
test-suite test
95-
default-language: Haskell2010
96-
hs-source-dirs: test
97-
main-is: main.hs
98-
type: exitcode-stdio-1.0
99-
-- Add otherwise redundant bounds on base since GHC's build system runs
100-
-- `cabal check`, which mandates bounds on base.
101-
build-depends: base >= 4 && < 5
102-
, bytestring
103-
, directory
104-
, process
105-
ghc-options: -threaded
106-
-with-rtsopts "-N"
107-
if os(windows)
108-
cpp-options: -DWINDOWS

stack.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,12 @@
11
resolver: ghc-9.2.3
2+
3+
packages:
4+
- .
5+
- test
6+
7+
extra-deps:
8+
- Cabal-3.6.3.0
9+
10+
allow-newer: True
11+
allow-newer-deps:
12+
- Cabal

test/LICENSE

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
Copyright (c) 2024, the Haskell process developers.
2+
3+
All rights reserved.
4+
5+
Redistribution and use in source and binary forms, with or without
6+
modification, are permitted provided that the following conditions are
7+
met:
8+
9+
* Redistributions of source code must retain the above copyright
10+
notice, this list of conditions and the following disclaimer.
11+
12+
* Redistributions in binary form must reproduce the above
13+
copyright notice, this list of conditions and the following
14+
disclaimer in the documentation and/or other materials provided
15+
with the distribution.
16+
17+
* Neither the name of Isaac Jones nor the names of other
18+
contributors may be used to endorse or promote products derived
19+
from this software without specific prior written permission.
20+
21+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

test/main.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ ifWindows action
2222
| otherwise = action
2323

2424
isWindows :: Bool
25-
#if WINDOWS
25+
#if defined(mingw32_HOST_OS)
2626
isWindows = True
2727
#else
2828
isWindows = False

0 commit comments

Comments
 (0)