Skip to content

Commit 10f2a90

Browse files
authored
Auto-generate more complete CI via haskell-ci (#1061)
Atm. requires a patched version of `haskell-ci` - haskell-CI/haskell-ci#582 to include the "haddock" step. Also: - fix missing `extra-source-files:` in `.cabal` file - delete `.travis.yml`.
1 parent 71bc801 commit 10f2a90

File tree

5 files changed

+236
-128
lines changed

5 files changed

+236
-128
lines changed
File renamed without changes.

.github/workflows/haskell-ci.yml

Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
# This GitHub workflow config has been generated by a script via
2+
#
3+
# haskell-ci 'github' 'hackage-server.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.14.3.20220416
12+
#
13+
# REGENDATA ("0.14.3.20220416",["github","hackage-server.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-18.04
23+
timeout-minutes:
24+
60
25+
container:
26+
image: buildpack-deps:focal
27+
continue-on-error: ${{ matrix.allow-failure }}
28+
strategy:
29+
matrix:
30+
include:
31+
- compiler: ghc-9.2.2
32+
compilerKind: ghc
33+
compilerVersion: 9.2.2
34+
setup-method: ghcup
35+
allow-failure: false
36+
- compiler: ghc-9.0.2
37+
compilerKind: ghc
38+
compilerVersion: 9.0.2
39+
setup-method: ghcup
40+
allow-failure: false
41+
- compiler: ghc-8.10.7
42+
compilerKind: ghc
43+
compilerVersion: 8.10.7
44+
setup-method: ghcup
45+
allow-failure: false
46+
- compiler: ghc-8.8.4
47+
compilerKind: ghc
48+
compilerVersion: 8.8.4
49+
setup-method: hvr-ppa
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+
if [ "${{ matrix.setup-method }}" = ghcup ]; then
58+
mkdir -p "$HOME/.ghcup/bin"
59+
curl -sL https://downloads.haskell.org/ghcup/0.1.17.5/x86_64-linux-ghcup-0.1.17.5 > "$HOME/.ghcup/bin/ghcup"
60+
chmod a+x "$HOME/.ghcup/bin/ghcup"
61+
"$HOME/.ghcup/bin/ghcup" install ghc "$HCVER"
62+
"$HOME/.ghcup/bin/ghcup" install cabal 3.6.2.0
63+
apt-get update
64+
apt-get install -y libbrotli-dev
65+
else
66+
apt-add-repository -y 'ppa:hvr/ghc'
67+
apt-get update
68+
apt-get install -y "$HCNAME" libbrotli-dev
69+
mkdir -p "$HOME/.ghcup/bin"
70+
curl -sL https://downloads.haskell.org/ghcup/0.1.17.5/x86_64-linux-ghcup-0.1.17.5 > "$HOME/.ghcup/bin/ghcup"
71+
chmod a+x "$HOME/.ghcup/bin/ghcup"
72+
"$HOME/.ghcup/bin/ghcup" install cabal 3.6.2.0
73+
fi
74+
env:
75+
HCKIND: ${{ matrix.compilerKind }}
76+
HCNAME: ${{ matrix.compiler }}
77+
HCVER: ${{ matrix.compilerVersion }}
78+
- name: Set PATH and environment variables
79+
run: |
80+
echo "$HOME/.cabal/bin" >> $GITHUB_PATH
81+
echo "LANG=C.UTF-8" >> "$GITHUB_ENV"
82+
echo "CABAL_DIR=$HOME/.cabal" >> "$GITHUB_ENV"
83+
echo "CABAL_CONFIG=$HOME/.cabal/config" >> "$GITHUB_ENV"
84+
HCDIR=/opt/$HCKIND/$HCVER
85+
if [ "${{ matrix.setup-method }}" = ghcup ]; then
86+
HC=$HOME/.ghcup/bin/$HCKIND-$HCVER
87+
echo "HC=$HC" >> "$GITHUB_ENV"
88+
echo "HCPKG=$HOME/.ghcup/bin/$HCKIND-pkg-$HCVER" >> "$GITHUB_ENV"
89+
echo "HADDOCK=$HOME/.ghcup/bin/haddock-$HCVER" >> "$GITHUB_ENV"
90+
echo "CABAL=$HOME/.ghcup/bin/cabal-3.6.2.0 -vnormal+nowrap" >> "$GITHUB_ENV"
91+
else
92+
HC=$HCDIR/bin/$HCKIND
93+
echo "HC=$HC" >> "$GITHUB_ENV"
94+
echo "HCPKG=$HCDIR/bin/$HCKIND-pkg" >> "$GITHUB_ENV"
95+
echo "HADDOCK=$HCDIR/bin/haddock" >> "$GITHUB_ENV"
96+
echo "CABAL=$HOME/.ghcup/bin/cabal-3.6.2.0 -vnormal+nowrap" >> "$GITHUB_ENV"
97+
fi
98+
99+
HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\d+)\.(\d+)\.(\d+)(\.(\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))')
100+
echo "HCNUMVER=$HCNUMVER" >> "$GITHUB_ENV"
101+
echo "ARG_TESTS=--enable-tests" >> "$GITHUB_ENV"
102+
echo "ARG_BENCH=--enable-benchmarks" >> "$GITHUB_ENV"
103+
echo "HEADHACKAGE=false" >> "$GITHUB_ENV"
104+
echo "ARG_COMPILER=--$HCKIND --with-compiler=$HC" >> "$GITHUB_ENV"
105+
echo "GHCJSARITH=0" >> "$GITHUB_ENV"
106+
env:
107+
HCKIND: ${{ matrix.compilerKind }}
108+
HCNAME: ${{ matrix.compiler }}
109+
HCVER: ${{ matrix.compilerVersion }}
110+
- name: env
111+
run: |
112+
env
113+
- name: write cabal config
114+
run: |
115+
mkdir -p $CABAL_DIR
116+
cat >> $CABAL_CONFIG <<EOF
117+
remote-build-reporting: anonymous
118+
write-ghc-environment-files: never
119+
remote-repo-cache: $CABAL_DIR/packages
120+
logs-dir: $CABAL_DIR/logs
121+
world-file: $CABAL_DIR/world
122+
extra-prog-path: $CABAL_DIR/bin
123+
symlink-bindir: $CABAL_DIR/bin
124+
installdir: $CABAL_DIR/bin
125+
build-summary: $CABAL_DIR/logs/build.log
126+
store-dir: $CABAL_DIR/store
127+
install-dirs user
128+
prefix: $CABAL_DIR
129+
repository hackage.haskell.org
130+
url: http://hackage.haskell.org/
131+
EOF
132+
cat >> $CABAL_CONFIG <<EOF
133+
program-default-options
134+
ghc-options: $GHCJOBS +RTS -M3G -RTS
135+
EOF
136+
cat $CABAL_CONFIG
137+
- name: versions
138+
run: |
139+
$HC --version || true
140+
$HC --print-project-git-commit-id || true
141+
$CABAL --version || true
142+
- name: update cabal index
143+
run: |
144+
$CABAL v2-update -v
145+
- name: install cabal-plan
146+
run: |
147+
mkdir -p $HOME/.cabal/bin
148+
curl -sL https://github.com/haskell-hvr/cabal-plan/releases/download/v0.6.2.0/cabal-plan-0.6.2.0-x86_64-linux.xz > cabal-plan.xz
149+
echo 'de73600b1836d3f55e32d80385acc055fd97f60eaa0ab68a755302685f5d81bc cabal-plan.xz' | sha256sum -c -
150+
xz -d < cabal-plan.xz > $HOME/.cabal/bin/cabal-plan
151+
rm -f cabal-plan.xz
152+
chmod a+x $HOME/.cabal/bin/cabal-plan
153+
cabal-plan --version
154+
- name: checkout
155+
uses: actions/checkout@v2
156+
with:
157+
path: source
158+
- name: initial cabal.project for sdist
159+
run: |
160+
touch cabal.project
161+
echo "packages: $GITHUB_WORKSPACE/source/." >> cabal.project
162+
cat cabal.project
163+
- name: sdist
164+
run: |
165+
mkdir -p sdist
166+
$CABAL sdist all --output-dir $GITHUB_WORKSPACE/sdist
167+
- name: unpack
168+
run: |
169+
mkdir -p unpacked
170+
find sdist -maxdepth 1 -type f -name '*.tar.gz' -exec tar -C $GITHUB_WORKSPACE/unpacked -xzvf {} \;
171+
- name: generate cabal.project
172+
run: |
173+
PKGDIR_hackage_server="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/hackage-server-[0-9.]*')"
174+
echo "PKGDIR_hackage_server=${PKGDIR_hackage_server}" >> "$GITHUB_ENV"
175+
rm -f cabal.project cabal.project.local
176+
touch cabal.project
177+
touch cabal.project.local
178+
echo "packages: ${PKGDIR_hackage_server}" >> cabal.project
179+
echo "package hackage-server" >> cabal.project
180+
echo " ghc-options: -Werror=missing-methods" >> cabal.project
181+
cat >> cabal.project <<EOF
182+
EOF
183+
$HCPKG list --simple-output --names-only | perl -ne 'for (split /\s+/) { print "constraints: $_ installed\n" unless /^(Cabal|hackage-server|parsec|text)$/; }' >> cabal.project.local
184+
cat cabal.project
185+
cat cabal.project.local
186+
- name: dump install plan
187+
run: |
188+
$CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH --dry-run all
189+
cabal-plan
190+
- name: cache
191+
uses: actions/cache@v2
192+
with:
193+
key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }}
194+
path: ~/.cabal/store
195+
restore-keys: ${{ runner.os }}-${{ matrix.compiler }}-
196+
- name: install dependencies
197+
run: |
198+
$CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks --dependencies-only -j2 all
199+
$CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH --dependencies-only -j2 all
200+
- name: build w/o tests
201+
run: |
202+
$CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks all
203+
- name: build
204+
run: |
205+
$CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH all --write-ghc-environment-files=always
206+
- name: tests
207+
run: |
208+
$CABAL v2-test $ARG_COMPILER $ARG_TESTS $ARG_BENCH all --test-show-details=direct
209+
- name: cabal check
210+
run: |
211+
cd ${PKGDIR_hackage_server} || false
212+
${CABAL} -vnormal check
213+
- name: haddock
214+
run: |
215+
$CABAL v2-haddock $ARG_COMPILER --with-haddock $HADDOCK $ARG_TESTS $ARG_BENCH all
216+
- name: unconstrained build
217+
run: |
218+
rm -f cabal.project.local
219+
$CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks all

.travis.yml

Lines changed: 0 additions & 125 deletions
This file was deleted.

cabal.haskell-ci

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
irc-channels: irc.libera.chat#hackage
1+
installed: +all -Cabal -text -parsec
22

3-
-- allow failures with ghc-7.6 and ghc-7.8
4-
allow-failures: <7.9
3+
-- -- irc-channels works with GHA, but why send to a channel
4+
-- -- when one can subscribe to github notifications?
5+
-- irc-channels: irc.libera.chat#hackage
6+
7+
-- Does not work with GHA:
8+
-- -- allow failures with ghc-7.6 and ghc-7.8
9+
-- allow-failures: <7.9
10+
11+
-- Use Ubuntu 20.04
12+
distribution: focal
13+
14+
apt: libbrotli-dev

hackage-server.cabal

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ extra-source-files:
5959
tests/unpack-checks/bad-specver-package-0/Main.hs
6060
tests/unpack-checks/bad-specver-package-0/Setup.hs
6161
tests/unpack-checks/bad-specver-package-0/bad-specver-package.cabal
62+
tests/unpack-checks/LANGUAGE-GHC-9.2/LICENSE
63+
tests/unpack-checks/LANGUAGE-GHC-9.2/Main.hs
64+
tests/unpack-checks/LANGUAGE-GHC-9.2/Setup.hs
65+
tests/unpack-checks/LANGUAGE-GHC-9.2/LANGUAGE-GHC.cabal
6266

6367
source-repository head
6468
type: git

0 commit comments

Comments
 (0)