ghcup-metadata/.github/workflows/install-bindist.sh

116 lines
2.6 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
2022-12-17 14:07:34 +00:00
set -x
set -eo pipefail
2023-02-17 15:45:19 +00:00
. .github/workflows/common.sh
export GHCUP_INSTALL_BASE_PREFIX=$RUNNER_TEMP/foobarbaz
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh
2023-02-17 15:45:19 +00:00
source "$GHCUP_INSTALL_BASE_PREFIX"/.ghcup/env || source "$HOME/.bashrc"
ghcup --version
which ghcup | grep foobarbaz
2023-03-12 10:10:21 +00:00
ghcup_fun() {
ghcup -v --url-source=file:$METADATA_FILE "$@"
}
2023-02-24 12:02:07 +00:00
case $TOOL in
ghcup)
2023-03-12 10:10:21 +00:00
ghcup_fun upgrade --force
2023-02-24 12:02:07 +00:00
;;
2023-03-12 10:10:21 +00:00
*) ghcup_fun install $TOOL --set $VERSION
2023-02-24 12:02:07 +00:00
;;
esac
2023-02-11 04:43:22 +00:00
mkdir -p /tmp/install-bindist-ci
2023-03-12 10:12:42 +00:00
cp "$METADATA_FILE" /tmp/install-bindist-ci/
2022-12-14 14:37:23 +00:00
cd /tmp/install-bindist-ci
cat <<EOF > main.hs
{- cabal:
build-depends: base
-}
main = print $ 1 + 1
EOF
case $TOOL in
2023-02-24 12:02:07 +00:00
ghcup)
2023-03-12 10:10:21 +00:00
ghcup_fun list
2023-02-24 12:02:07 +00:00
;;
hls)
2023-03-12 10:10:21 +00:00
ghcup_fun install cabal latest
ghcup_fun install ghc --set recommended
2023-02-17 15:45:19 +00:00
cabal update
test_package="bytestring-0.11.1.0"
test_module="Data/ByteString.hs"
create_cradle() {
echo "cradle:" > hie.yaml
echo " cabal:" >> hie.yaml
}
enter_test_package() {
local tmp_dir
tmp_dir=$(mktempdir)
cd "$tmp_dir"
cabal unpack "${test_package}"
cd "${test_package}"
}
# For all HLS GHC versions and the wrapper, run 'typecheck'
# over the $test_module
test_all_hls() {
local bin
local bin_noexe
local bindir
local hls
bindir=$1
for hls in "${bindir}/"haskell-language-server-* ; do
bin=${hls##*/}
bin_noexe=${bin/.exe/}
if ! [[ "${bin_noexe}" =~ "haskell-language-server-wrapper" ]] && ! [[ "${bin_noexe}" =~ "~" ]] && ! [[ "${bin_noexe}" =~ ".shim" ]] ; then
2023-03-12 10:10:21 +00:00
if ghcup_fun install ghc --set "${bin_noexe/haskell-language-server-/}" ; then
2023-02-17 15:45:19 +00:00
"${hls}" typecheck "${test_module}" || fail "failed to typecheck with HLS for GHC ${bin_noexe/haskell-language-server-/}"
else
fail "GHCup failed to install GHC ${bin_noexe/haskell-language-server-/}"
fi
2023-03-12 10:10:21 +00:00
ghcup_fun rm ghc "${bin_noexe/haskell-language-server-/}"
2023-02-17 15:45:19 +00:00
fi
done
"$bindir/haskell-language-server-wrapper${ext}" typecheck "${test_module}" || fail "failed to typecheck with HLS wrapper"
}
enter_test_package
create_cradle
case "$(uname -s)" in
MSYS_*|MINGW*)
test_all_hls "$(dirname "$(which ghcup)")"
;;
*)
test_all_hls "$(ghcup whereis bindir)"
;;
esac
;;
ghc)
ghc --version
ghc --info
ghc -prof main.hs
[[ $(./main +RTS -s) -eq 2 ]]
;;
cabal)
2023-03-12 10:10:21 +00:00
ghcup_fun install ghc --set "$(ghcup_fun list -t ghc -r -c available | tail -1 | awk '{ print $2 }')"
cabal --version
cabal update
[[ $(cabal --verbose=0 run --enable-profiling ./main.hs -- +RTS -s) -eq 2 ]]
;;
*)
$TOOL --version
;;
esac