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

138 lines
3.2 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
2024-03-13 13:06:20 +00:00
curl --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/haskell/ghcup-hs/master/scripts/bootstrap/bootstrap-haskell | 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() {
2024-01-22 08:13:05 +00:00
case "$(uname -s)" in
MSYS_*|MINGW*)
ghcup -v --url-source="file:${GITHUB_WORKSPACE//\\//}/$METADATA_FILE" "$@"
;;
*)
ghcup -v --url-source="file://${GITHUB_WORKSPACE}/$METADATA_FILE" "$@"
;;
esac
2023-03-12 10:10:21 +00:00
}
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-08-26 06:03:29 +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
2022-12-14 14:37:23 +00:00
cd /tmp/install-bindist-ci
2023-11-17 10:27:57 +00:00
trap 'rm -rf -- /tmp/install-bindist-ci' EXIT
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
2024-03-01 16:13:21 +00:00
ghcup_fun install ghc --set recommended
2023-02-17 15:45:19 +00:00
"$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 ]]
2023-11-17 10:27:57 +00:00
ghcup_fun install cabal recommended
cabal --version
cabal update
cabal install --lib --package-env=. clock
2024-01-03 13:16:10 +00:00
# https://github.com/haskell/ghcup-hs/issues/966
cabal install --lib --package-env=. hashable
2024-02-25 10:29:37 +00:00
case "$(uname -s)" in
MSYS_*|MINGW*)
;;
*)
[[ -e "$(ghcup whereis --directory ghc "$VERSION")/../share/man/man1/ghc.1" ]]
;;
esac
;;
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