Skip to content

Commit 96138a0

Browse files
committed
Make testsuite compile on newer GHC
1 parent 1155945 commit 96138a0

4 files changed

Lines changed: 218 additions & 5 deletions

File tree

.github/workflows/haskell-ci.yml

Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
# This GitHub workflow config has been generated by a script via
2+
#
3+
# haskell-ci 'github' 'hedis.cabal'
4+
#
5+
# To regenerate the script (for example after adjusting tested-with) run
6+
#
7+
# haskell-ci regenerate
8+
#
9+
# For more information, see https://github.com/haskell-CI/haskell-ci
10+
#
11+
# version: 0.18.1
12+
#
13+
# REGENDATA ("0.18.1",["github","hedis.cabal"])
14+
#
15+
name: Haskell-CI
16+
on:
17+
- push
18+
- pull_request
19+
jobs:
20+
linux:
21+
name: Haskell-CI - Linux - ${{ matrix.compiler }}
22+
runs-on: ubuntu-20.04
23+
timeout-minutes:
24+
60
25+
container:
26+
image: buildpack-deps:bionic
27+
continue-on-error: ${{ matrix.allow-failure }}
28+
strategy:
29+
matrix:
30+
include:
31+
- compiler: ghc-9.4.8
32+
compilerKind: ghc
33+
compilerVersion: 9.4.8
34+
setup-method: ghcup
35+
allow-failure: true
36+
- compiler: ghc-9.6.7
37+
compilerKind: ghc
38+
compilerVersion: 9.6.7
39+
setup-method: ghcup
40+
allow-failure: false
41+
- compiler: ghc-9.8.4
42+
compilerKind: ghc
43+
compilerVersion: 9.8.4
44+
setup-method: ghcup
45+
allow-failure: false
46+
- compiler: ghc-9.10.2
47+
compilerKind: ghc
48+
compilerVersion: 9.10.2
49+
setup-method: ghcup
50+
allow-failure: false
51+
fail-fast: false
52+
steps:
53+
- name: apt
54+
run: |
55+
apt-get update
56+
apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5
57+
mkdir -p "$HOME/.ghcup/bin"
58+
curl -sL https://downloads.haskell.org/ghcup/0.1.20.0/x86_64-linux-ghcup-0.1.20.0 > "$HOME/.ghcup/bin/ghcup"
59+
chmod a+x "$HOME/.ghcup/bin/ghcup"
60+
"$HOME/.ghcup/bin/ghcup" install ghc "$HCVER" || (cat "$HOME"/.ghcup/logs/*.* && false)
61+
"$HOME/.ghcup/bin/ghcup" install cabal 3.10.2.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
62+
env:
63+
HCKIND: ${{ matrix.compilerKind }}
64+
HCNAME: ${{ matrix.compiler }}
65+
HCVER: ${{ matrix.compilerVersion }}
66+
- name: Set PATH and environment variables
67+
run: |
68+
echo "$HOME/.cabal/bin" >> $GITHUB_PATH
69+
echo "LANG=C.UTF-8" >> "$GITHUB_ENV"
70+
echo "CABAL_DIR=$HOME/.cabal" >> "$GITHUB_ENV"
71+
echo "CABAL_CONFIG=$HOME/.cabal/config" >> "$GITHUB_ENV"
72+
HCDIR=/opt/$HCKIND/$HCVER
73+
HC=$("$HOME/.ghcup/bin/ghcup" whereis ghc "$HCVER")
74+
HCPKG=$(echo "$HC" | sed 's#ghc$#ghc-pkg#')
75+
HADDOCK=$(echo "$HC" | sed 's#ghc$#haddock#')
76+
echo "HC=$HC" >> "$GITHUB_ENV"
77+
echo "HCPKG=$HCPKG" >> "$GITHUB_ENV"
78+
echo "HADDOCK=$HADDOCK" >> "$GITHUB_ENV"
79+
echo "CABAL=$HOME/.ghcup/bin/cabal-3.10.2.0 -vnormal+nowrap" >> "$GITHUB_ENV"
80+
HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\d+)\.(\d+)\.(\d+)(\.(\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))')
81+
echo "HCNUMVER=$HCNUMVER" >> "$GITHUB_ENV"
82+
echo "ARG_TESTS=--enable-tests" >> "$GITHUB_ENV"
83+
echo "ARG_BENCH=--enable-benchmarks" >> "$GITHUB_ENV"
84+
echo "HEADHACKAGE=false" >> "$GITHUB_ENV"
85+
echo "ARG_COMPILER=--$HCKIND --with-compiler=$HC" >> "$GITHUB_ENV"
86+
echo "GHCJSARITH=0" >> "$GITHUB_ENV"
87+
env:
88+
HCKIND: ${{ matrix.compilerKind }}
89+
HCNAME: ${{ matrix.compiler }}
90+
HCVER: ${{ matrix.compilerVersion }}
91+
- name: env
92+
run: |
93+
env
94+
- name: write cabal config
95+
run: |
96+
mkdir -p $CABAL_DIR
97+
cat >> $CABAL_CONFIG <<EOF
98+
remote-build-reporting: anonymous
99+
write-ghc-environment-files: never
100+
remote-repo-cache: $CABAL_DIR/packages
101+
logs-dir: $CABAL_DIR/logs
102+
world-file: $CABAL_DIR/world
103+
extra-prog-path: $CABAL_DIR/bin
104+
symlink-bindir: $CABAL_DIR/bin
105+
installdir: $CABAL_DIR/bin
106+
build-summary: $CABAL_DIR/logs/build.log
107+
store-dir: $CABAL_DIR/store
108+
install-dirs user
109+
prefix: $CABAL_DIR
110+
repository hackage.haskell.org
111+
url: http://hackage.haskell.org/
112+
EOF
113+
cat >> $CABAL_CONFIG <<EOF
114+
program-default-options
115+
ghc-options: $GHCJOBS +RTS -M3G -RTS
116+
EOF
117+
cat $CABAL_CONFIG
118+
- name: versions
119+
run: |
120+
$HC --version || true
121+
$HC --print-project-git-commit-id || true
122+
$CABAL --version || true
123+
- name: update cabal index
124+
run: |
125+
$CABAL v2-update -v
126+
- name: install cabal-plan
127+
run: |
128+
mkdir -p $HOME/.cabal/bin
129+
curl -sL https://github.com/haskell-hvr/cabal-plan/releases/download/v0.7.3.0/cabal-plan-0.7.3.0-x86_64-linux.xz > cabal-plan.xz
130+
echo 'f62ccb2971567a5f638f2005ad3173dba14693a45154c1508645c52289714cb2 cabal-plan.xz' | sha256sum -c -
131+
xz -d < cabal-plan.xz > $HOME/.cabal/bin/cabal-plan
132+
rm -f cabal-plan.xz
133+
chmod a+x $HOME/.cabal/bin/cabal-plan
134+
cabal-plan --version
135+
- name: checkout
136+
uses: actions/checkout@v3
137+
with:
138+
path: source
139+
- name: initial cabal.project for sdist
140+
run: |
141+
touch cabal.project
142+
echo "packages: $GITHUB_WORKSPACE/source/." >> cabal.project
143+
cat cabal.project
144+
- name: sdist
145+
run: |
146+
mkdir -p sdist
147+
$CABAL sdist all --output-dir $GITHUB_WORKSPACE/sdist
148+
- name: unpack
149+
run: |
150+
mkdir -p unpacked
151+
find sdist -maxdepth 1 -type f -name '*.tar.gz' -exec tar -C $GITHUB_WORKSPACE/unpacked -xzvf {} \;
152+
- name: generate cabal.project
153+
run: |
154+
PKGDIR_hedis="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/hedis-[0-9.]*')"
155+
echo "PKGDIR_hedis=${PKGDIR_hedis}" >> "$GITHUB_ENV"
156+
rm -f cabal.project cabal.project.local
157+
touch cabal.project
158+
touch cabal.project.local
159+
echo "packages: ${PKGDIR_hedis}" >> cabal.project
160+
echo "package hedis" >> cabal.project
161+
echo " ghc-options: -Werror=missing-methods" >> cabal.project
162+
cat >> cabal.project <<EOF
163+
EOF
164+
$HCPKG list --simple-output --names-only | perl -ne 'for (split /\s+/) { print "constraints: $_ installed\n" unless /^(hedis)$/; }' >> cabal.project.local
165+
cat cabal.project
166+
cat cabal.project.local
167+
- name: dump install plan
168+
run: |
169+
$CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH --dry-run all
170+
cabal-plan
171+
- name: restore cache
172+
uses: actions/cache/restore@v3
173+
with:
174+
key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }}
175+
path: ~/.cabal/store
176+
restore-keys: ${{ runner.os }}-${{ matrix.compiler }}-
177+
- name: install dependencies
178+
run: |
179+
$CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks --dependencies-only -j2 all
180+
$CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH --dependencies-only -j2 all
181+
- name: build w/o tests
182+
run: |
183+
$CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks all
184+
- name: build
185+
run: |
186+
$CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH all --write-ghc-environment-files=always
187+
- name: tests
188+
run: |
189+
$CABAL v2-test $ARG_COMPILER $ARG_TESTS $ARG_BENCH all --test-show-details=direct
190+
- name: cabal check
191+
run: |
192+
cd ${PKGDIR_hedis} || false
193+
${CABAL} -vnormal check
194+
- name: haddock
195+
run: |
196+
$CABAL v2-haddock --disable-documentation --haddock-all $ARG_COMPILER --with-haddock $HADDOCK $ARG_TESTS $ARG_BENCH all
197+
- name: unconstrained build
198+
run: |
199+
rm -f cabal.project.local
200+
$CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks all
201+
- name: save cache
202+
uses: actions/cache/save@v3
203+
if: always()
204+
with:
205+
key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }}
206+
path: ~/.cabal/store

hedis.cabal

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ homepage: https://github.com/informatikr/hedis
4848
bug-reports: https://github.com/informatikr/hedis/issues
4949
extra-source-files: CHANGELOG
5050

51+
tested-with:
52+
GHC ==9.12.2
53+
|| ==9.10.2
54+
|| ==9.8.4
55+
|| ==9.6.7
56+
|| ==9.4.8
57+
5158
source-repository head
5259
type: git
5360
location: https://github.com/informatikr/hedis

test/ClusterMain.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ main = do
2121
Test.defaultMain (tests conn)
2222

2323
tests :: Connection -> [Test.Test]
24-
tests conn = map ($conn) $ concat @[]
24+
tests conn = map ($ conn) $ concat @[]
2525
[ testsMisc, testsKeys, testsStrings, [testHashes], testsLists, testsSets, [testHyperLogLog]
2626
, testsZSets, [testTransaction], [testScripting]
2727
, testsConnection, testsClient, testsServer, [testSScan, testHScan, testZScan], [testZrangelex]

test/PubSubTest.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
{-# LANGUAGE CPP, OverloadedStrings, DeriveDataTypeable #-}
1+
{-# LANGUAGE CPP, OverloadedStrings #-}
22
module PubSubTest (testPubSubThreaded) where
33

44
import Control.Concurrent
55
import Control.Monad
66
import Control.Concurrent.Async
77
import Control.Exception
8-
import Data.Typeable
98
import qualified Data.List
10-
import Data.Text
9+
import Data.Text hiding (show)
10+
import Data.Typeable
1111
import Data.ByteString
1212
import Control.Concurrent.STM
1313
import qualified Test.Framework as Test
@@ -100,7 +100,7 @@ removeAllTest conn = Test.testCase "Multithreaded Pub/Sub - basic" $ do
100100
waitForPMessage msgVar "InitialBar2" "bar2:aaa" "0987"
101101

102102
data TestError = TestError ByteString
103-
deriving (Eq, Show, Typeable)
103+
deriving (Eq, Show)
104104
instance Exception TestError
105105

106106
-- | Test an error thrown from a message handler

0 commit comments

Comments
 (0)