Fix CI for cabal

This commit is contained in:
Julian Ospald 2023-03-12 18:10:21 +08:00
parent b8606ec3b7
commit 7de9fd3a8c
Signed by: hasufell
GPG Key ID: 3786C5262ECB4A3F

View File

@ -13,11 +13,15 @@ source "$GHCUP_INSTALL_BASE_PREFIX"/.ghcup/env || source "$HOME/.bashrc"
ghcup --version ghcup --version
which ghcup | grep foobarbaz which ghcup | grep foobarbaz
ghcup_fun() {
ghcup -v --url-source=file:$METADATA_FILE "$@"
}
case $TOOL in case $TOOL in
ghcup) ghcup)
ghcup -v --url-source=file:$METADATA_FILE upgrade --force ghcup_fun upgrade --force
;; ;;
*) ghcup -v --url-source=file:$METADATA_FILE install $TOOL --set $VERSION *) ghcup_fun install $TOOL --set $VERSION
;; ;;
esac esac
@ -34,11 +38,11 @@ EOF
case $TOOL in case $TOOL in
ghcup) ghcup)
ghcup --verbose list ghcup_fun list
;; ;;
hls) hls)
ghcup install cabal latest ghcup_fun install cabal latest
ghcup install ghc --set recommended ghcup_fun install ghc --set recommended
cabal update cabal update
test_package="bytestring-0.11.1.0" test_package="bytestring-0.11.1.0"
@ -70,12 +74,12 @@ case $TOOL in
bin=${hls##*/} bin=${hls##*/}
bin_noexe=${bin/.exe/} bin_noexe=${bin/.exe/}
if ! [[ "${bin_noexe}" =~ "haskell-language-server-wrapper" ]] && ! [[ "${bin_noexe}" =~ "~" ]] && ! [[ "${bin_noexe}" =~ ".shim" ]] ; then if ! [[ "${bin_noexe}" =~ "haskell-language-server-wrapper" ]] && ! [[ "${bin_noexe}" =~ "~" ]] && ! [[ "${bin_noexe}" =~ ".shim" ]] ; then
if ghcup install ghc --set "${bin_noexe/haskell-language-server-/}" ; then if ghcup_fun install ghc --set "${bin_noexe/haskell-language-server-/}" ; then
"${hls}" typecheck "${test_module}" || fail "failed to typecheck with HLS for GHC ${bin_noexe/haskell-language-server-/}" "${hls}" typecheck "${test_module}" || fail "failed to typecheck with HLS for GHC ${bin_noexe/haskell-language-server-/}"
else else
fail "GHCup failed to install GHC ${bin_noexe/haskell-language-server-/}" fail "GHCup failed to install GHC ${bin_noexe/haskell-language-server-/}"
fi fi
ghcup rm ghc "${bin_noexe/haskell-language-server-/}" ghcup_fun rm ghc "${bin_noexe/haskell-language-server-/}"
fi fi
done done
"$bindir/haskell-language-server-wrapper${ext}" typecheck "${test_module}" || fail "failed to typecheck with HLS wrapper" "$bindir/haskell-language-server-wrapper${ext}" typecheck "${test_module}" || fail "failed to typecheck with HLS wrapper"
@ -99,6 +103,7 @@ case $TOOL in
[[ $(./main +RTS -s) -eq 2 ]] [[ $(./main +RTS -s) -eq 2 ]]
;; ;;
cabal) cabal)
ghcup_fun install ghc --set "$(ghcup_fun list -t ghc -r -c available | tail -1 | awk '{ print $2 }')"
cabal --version cabal --version
cabal update cabal update
[[ $(cabal --verbose=0 run --enable-profiling ./main.hs -- +RTS -s) -eq 2 ]] [[ $(cabal --verbose=0 run --enable-profiling ./main.hs -- +RTS -s) -eq 2 ]]