Skip to content

Commit 9bf2406

Browse files
committed
Setup CI using haskell-ci program
1 parent 224c0fe commit 9bf2406

File tree

2 files changed

+248
-0
lines changed

2 files changed

+248
-0
lines changed

.github/workflows/haskell-ci.yml

Lines changed: 246 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,246 @@
1+
# This GitHub workflow config has been generated by a script via
2+
#
3+
# haskell-ci 'github' 'system-linux-proc.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.19.20241202
12+
#
13+
# REGENDATA ("0.19.20241202",["github","system-linux-proc.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:jammy
27+
continue-on-error: ${{ matrix.allow-failure }}
28+
strategy:
29+
matrix:
30+
include:
31+
- compiler: ghc-9.12.0.20241128
32+
compilerKind: ghc
33+
compilerVersion: 9.12.0.20241128
34+
setup-method: ghcup-prerelease
35+
allow-failure: false
36+
- compiler: ghc-9.10.1
37+
compilerKind: ghc
38+
compilerVersion: 9.10.1
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.6.6
47+
compilerKind: ghc
48+
compilerVersion: 9.6.6
49+
setup-method: ghcup
50+
allow-failure: false
51+
- compiler: ghc-8.10.7
52+
compilerKind: ghc
53+
compilerVersion: 8.10.7
54+
setup-method: ghcup
55+
allow-failure: false
56+
fail-fast: false
57+
steps:
58+
- name: apt-get install
59+
run: |
60+
apt-get update
61+
apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5
62+
- name: Install GHCup
63+
run: |
64+
mkdir -p "$HOME/.ghcup/bin"
65+
curl -sL https://downloads.haskell.org/ghcup/0.1.30.0/x86_64-linux-ghcup-0.1.30.0 > "$HOME/.ghcup/bin/ghcup"
66+
chmod a+x "$HOME/.ghcup/bin/ghcup"
67+
- name: Install cabal-install
68+
run: |
69+
"$HOME/.ghcup/bin/ghcup" install cabal 3.12.1.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
70+
echo "CABAL=$HOME/.ghcup/bin/cabal-3.12.1.0 -vnormal+nowrap" >> "$GITHUB_ENV"
71+
- name: Install GHC (GHCup)
72+
if: matrix.setup-method == 'ghcup'
73+
run: |
74+
"$HOME/.ghcup/bin/ghcup" install ghc "$HCVER" || (cat "$HOME"/.ghcup/logs/*.* && false)
75+
HC=$("$HOME/.ghcup/bin/ghcup" whereis ghc "$HCVER")
76+
HCPKG=$(echo "$HC" | sed 's#ghc$#ghc-pkg#')
77+
HADDOCK=$(echo "$HC" | sed 's#ghc$#haddock#')
78+
echo "HC=$HC" >> "$GITHUB_ENV"
79+
echo "HCPKG=$HCPKG" >> "$GITHUB_ENV"
80+
echo "HADDOCK=$HADDOCK" >> "$GITHUB_ENV"
81+
env:
82+
HCKIND: ${{ matrix.compilerKind }}
83+
HCNAME: ${{ matrix.compiler }}
84+
HCVER: ${{ matrix.compilerVersion }}
85+
- name: Install GHC (GHCup prerelease)
86+
if: matrix.setup-method == 'ghcup-prerelease'
87+
run: |
88+
"$HOME/.ghcup/bin/ghcup" config add-release-channel https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-prereleases-0.0.8.yaml;
89+
"$HOME/.ghcup/bin/ghcup" install ghc "$HCVER" || (cat "$HOME"/.ghcup/logs/*.* && false)
90+
HC=$("$HOME/.ghcup/bin/ghcup" whereis ghc "$HCVER")
91+
HCPKG=$(echo "$HC" | sed 's#ghc$#ghc-pkg#')
92+
HADDOCK=$(echo "$HC" | sed 's#ghc$#haddock#')
93+
echo "HC=$HC" >> "$GITHUB_ENV"
94+
echo "HCPKG=$HCPKG" >> "$GITHUB_ENV"
95+
echo "HADDOCK=$HADDOCK" >> "$GITHUB_ENV"
96+
env:
97+
HCKIND: ${{ matrix.compilerKind }}
98+
HCNAME: ${{ matrix.compiler }}
99+
HCVER: ${{ matrix.compilerVersion }}
100+
- name: Set PATH and environment variables
101+
run: |
102+
echo "$HOME/.cabal/bin" >> $GITHUB_PATH
103+
echo "LANG=C.UTF-8" >> "$GITHUB_ENV"
104+
echo "CABAL_DIR=$HOME/.cabal" >> "$GITHUB_ENV"
105+
echo "CABAL_CONFIG=$HOME/.cabal/config" >> "$GITHUB_ENV"
106+
HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\d+)\.(\d+)\.(\d+)(\.(\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))')
107+
echo "HCNUMVER=$HCNUMVER" >> "$GITHUB_ENV"
108+
echo "ARG_TESTS=--enable-tests" >> "$GITHUB_ENV"
109+
echo "ARG_BENCH=--enable-benchmarks" >> "$GITHUB_ENV"
110+
if [ $((HCNUMVER >= 91200)) -ne 0 ] ; then echo "HEADHACKAGE=true" >> "$GITHUB_ENV" ; else echo "HEADHACKAGE=false" >> "$GITHUB_ENV" ; fi
111+
echo "ARG_COMPILER=--$HCKIND --with-compiler=$HC" >> "$GITHUB_ENV"
112+
env:
113+
HCKIND: ${{ matrix.compilerKind }}
114+
HCNAME: ${{ matrix.compiler }}
115+
HCVER: ${{ matrix.compilerVersion }}
116+
- name: env
117+
run: |
118+
env
119+
- name: write cabal config
120+
run: |
121+
mkdir -p $CABAL_DIR
122+
cat >> $CABAL_CONFIG <<EOF
123+
remote-build-reporting: anonymous
124+
write-ghc-environment-files: never
125+
remote-repo-cache: $CABAL_DIR/packages
126+
logs-dir: $CABAL_DIR/logs
127+
world-file: $CABAL_DIR/world
128+
extra-prog-path: $CABAL_DIR/bin
129+
symlink-bindir: $CABAL_DIR/bin
130+
installdir: $CABAL_DIR/bin
131+
build-summary: $CABAL_DIR/logs/build.log
132+
store-dir: $CABAL_DIR/store
133+
install-dirs user
134+
prefix: $CABAL_DIR
135+
repository hackage.haskell.org
136+
url: http://hackage.haskell.org/
137+
EOF
138+
if $HEADHACKAGE; then
139+
cat >> $CABAL_CONFIG <<EOF
140+
repository head.hackage.ghc.haskell.org
141+
url: https://ghc.gitlab.haskell.org/head.hackage/
142+
secure: True
143+
root-keys: 7541f32a4ccca4f97aea3b22f5e593ba2c0267546016b992dfadcd2fe944e55d
144+
26021a13b401500c8eb2761ca95c61f2d625bfef951b939a8124ed12ecf07329
145+
f76d08be13e9a61a377a85e2fb63f4c5435d40f8feb3e12eb05905edb8cdea89
146+
key-threshold: 3
147+
active-repositories: hackage.haskell.org, head.hackage.ghc.haskell.org:override
148+
EOF
149+
fi
150+
cat >> $CABAL_CONFIG <<EOF
151+
program-default-options
152+
ghc-options: $GHCJOBS +RTS -M3G -RTS
153+
EOF
154+
cat $CABAL_CONFIG
155+
- name: versions
156+
run: |
157+
$HC --version || true
158+
$HC --print-project-git-commit-id || true
159+
$CABAL --version || true
160+
- name: update cabal index
161+
run: |
162+
$CABAL v2-update -v
163+
- name: install cabal-plan
164+
run: |
165+
mkdir -p $HOME/.cabal/bin
166+
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
167+
echo 'f62ccb2971567a5f638f2005ad3173dba14693a45154c1508645c52289714cb2 cabal-plan.xz' | sha256sum -c -
168+
xz -d < cabal-plan.xz > $HOME/.cabal/bin/cabal-plan
169+
rm -f cabal-plan.xz
170+
chmod a+x $HOME/.cabal/bin/cabal-plan
171+
cabal-plan --version
172+
- name: checkout
173+
uses: actions/checkout@v4
174+
with:
175+
path: source
176+
- name: initial cabal.project for sdist
177+
run: |
178+
touch cabal.project
179+
echo "packages: $GITHUB_WORKSPACE/source/." >> cabal.project
180+
cat cabal.project
181+
- name: sdist
182+
run: |
183+
mkdir -p sdist
184+
$CABAL sdist all --output-dir $GITHUB_WORKSPACE/sdist
185+
- name: unpack
186+
run: |
187+
mkdir -p unpacked
188+
find sdist -maxdepth 1 -type f -name '*.tar.gz' -exec tar -C $GITHUB_WORKSPACE/unpacked -xzvf {} \;
189+
- name: generate cabal.project
190+
run: |
191+
PKGDIR_system_linux_proc="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/system-linux-proc-[0-9.]*')"
192+
echo "PKGDIR_system_linux_proc=${PKGDIR_system_linux_proc}" >> "$GITHUB_ENV"
193+
rm -f cabal.project cabal.project.local
194+
touch cabal.project
195+
touch cabal.project.local
196+
echo "packages: ${PKGDIR_system_linux_proc}" >> cabal.project
197+
echo "package system-linux-proc" >> cabal.project
198+
echo " ghc-options: -Werror=missing-methods" >> cabal.project
199+
cat >> cabal.project <<EOF
200+
EOF
201+
if $HEADHACKAGE; then
202+
echo "allow-newer: $($HCPKG list --simple-output | sed -E 's/([a-zA-Z-]+)-[0-9.]+/*:\1,/g')" >> cabal.project
203+
fi
204+
$HCPKG list --simple-output --names-only | perl -ne 'for (split /\s+/) { print "constraints: any.$_ installed\n" unless /^(system-linux-proc)$/; }' >> cabal.project.local
205+
cat cabal.project
206+
cat cabal.project.local
207+
- name: dump install plan
208+
run: |
209+
$CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH --dry-run all
210+
cabal-plan
211+
- name: restore cache
212+
uses: actions/cache/restore@v4
213+
with:
214+
key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }}
215+
path: ~/.cabal/store
216+
restore-keys: ${{ runner.os }}-${{ matrix.compiler }}-
217+
- name: install dependencies
218+
run: |
219+
$CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks --dependencies-only -j2 all
220+
$CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH --dependencies-only -j2 all
221+
- name: build w/o tests
222+
run: |
223+
$CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks all
224+
- name: build
225+
run: |
226+
$CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH all --write-ghc-environment-files=always
227+
- name: tests
228+
run: |
229+
$CABAL v2-test $ARG_COMPILER $ARG_TESTS $ARG_BENCH all --test-show-details=direct
230+
- name: cabal check
231+
run: |
232+
cd ${PKGDIR_system_linux_proc} || false
233+
${CABAL} -vnormal check
234+
- name: haddock
235+
run: |
236+
$CABAL v2-haddock --disable-documentation --haddock-all $ARG_COMPILER --with-haddock $HADDOCK $ARG_TESTS $ARG_BENCH all
237+
- name: unconstrained build
238+
run: |
239+
rm -f cabal.project.local
240+
$CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks all
241+
- name: save cache
242+
if: always()
243+
uses: actions/cache/save@v4
244+
with:
245+
key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }}
246+
path: ~/.cabal/store

system-linux-proc.cabal

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ extra-source-files: ChangeLog.md
1717
stability: provisional
1818
cabal-version: >= 1.10
1919

20+
tested-with: GHC == 8.10.7, GHC == 9.6.6, GHC == 9.8.4, GHC == 9.10.1, GHC == 9.12.1
21+
2022
library
2123
default-language: Haskell2010
2224
ghc-options: -Wall -fwarn-tabs

0 commit comments

Comments
 (0)