From d81957195560271e5961bcbec340e3f463a230eb Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Fri, 17 Feb 2023 23:45:19 +0800 Subject: [PATCH] Fix HLS CI --- .github/workflows/bindists.yaml | 14 +++--- .github/workflows/common.sh | 30 +++++++++++++ .github/workflows/install-bindist.sh | 65 ++++++++++++++++++++++++---- 3 files changed, 95 insertions(+), 14 deletions(-) create mode 100644 .github/workflows/common.sh diff --git a/.github/workflows/bindists.yaml b/.github/workflows/bindists.yaml index 48ade7d..da78e09 100644 --- a/.github/workflows/bindists.yaml +++ b/.github/workflows/bindists.yaml @@ -3,10 +3,6 @@ defaults: run: shell: bash on: - pull_request: - types: [opened] - issue_comment: - types: [created] workflow_dispatch: inputs: tool: @@ -45,10 +41,10 @@ jobs: toolRequirements: build-essential curl libffi-dev libgmp-dev libgmp10 libncurses-dev libncurses5 libtinfo5 - image: debian:10 installCmd: apt-get update && apt-get install -y - toolRequirements: build-essential curl libffi-dev libgmp-dev libgmp10 libncurses-dev libncurses5 libtinfo5 + toolRequirements: build-essential curl libffi-dev libgmp-dev libgmp10 libncurses-dev libncurses5 libtinfo5 libnuma-dev - image: debian:11 installCmd: apt-get update && apt-get install -y - toolRequirements: build-essential curl libffi-dev libgmp-dev libgmp10 libncurses-dev libncurses5 libtinfo5 + toolRequirements: build-essential curl libffi-dev libgmp-dev libgmp10 libncurses-dev libncurses5 libtinfo5 libnuma-dev - image: ubuntu:18.04 installCmd: apt-get update && apt-get install -y toolRequirements: build-essential curl libffi-dev libffi6 libgmp-dev libgmp10 libncurses-dev libncurses5 libtinfo5 @@ -70,12 +66,18 @@ jobs: - image: rockylinux:8 installCmd: dnf install -y toolRequirements: which findutils gcc gcc-c++ gmp gmp-devel make ncurses ncurses-compat-libs xz perl + - image: rockylinux:9 + installCmd: dnf install -y --allowerasing + toolRequirements: which findutils gcc gcc-c++ gmp gmp-devel make ncurses xz perl - image: linuxmintd/mint19.3-amd64 installCmd: apt-get update && apt-get install -y toolRequirements: build-essential curl libffi-dev libffi6 libgmp-dev libgmp10 libncurses-dev libncurses5 libtinfo5 - image: linuxmintd/mint20.2-amd64 installCmd: apt-get update && apt-get install -y toolRequirements: build-essential curl libffi-dev libffi7 libgmp-dev libgmp10 libncurses-dev libncurses5 libtinfo5 + - image: linuxmintd/mint21.1-amd64 + installCmd: apt-get update && apt-get install -y + toolRequirements: build-essential curl libffi-dev libffi7 libgmp-dev libgmp10 libncurses-dev libncurses5 libtinfo5 container: image: ${{ matrix.image }} steps: diff --git a/.github/workflows/common.sh b/.github/workflows/common.sh new file mode 100644 index 0000000..97618d5 --- /dev/null +++ b/.github/workflows/common.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +if [ "${RUNNER_OS}" = "Windows" ] ; then + ext=".exe" +else + ext='' +fi + +echo_color() { + local color="$1" + local msg="$2" + echo -e "\033[${color}m${msg}\033[0m" +} + +error() { echo_color "${RED}" "$1"; } +warn() { echo_color "${LT_BROWN}" "$1"; } +info() { echo_color "${LT_BLUE}" "$1"; } + +fail() { error "error: $1"; exit 1; } + +mktempdir() { + case "$(uname -s)" in + "Darwin"|"darwin") + mktemp -d -t hls_ci.XXXXXXX + ;; + *) + mktemp -d + ;; + esac +} diff --git a/.github/workflows/install-bindist.sh b/.github/workflows/install-bindist.sh index 2cf2708..8b0c66b 100755 --- a/.github/workflows/install-bindist.sh +++ b/.github/workflows/install-bindist.sh @@ -2,20 +2,17 @@ set -x set -eo pipefail +. .github/workflows/common.sh + export GHCUP_INSTALL_BASE_PREFIX=$RUNNER_TEMP/foobarbaz curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh -source $GHCUP_INSTALL_BASE_PREFIX/.ghcup/env || source ~/.bashrc +source "$GHCUP_INSTALL_BASE_PREFIX"/.ghcup/env || source "$HOME/.bashrc" ghcup --version which ghcup | grep foobarbaz -# oh no -if [ "${TOOL}" = "hls" ] ; then - ghcup -v --url-source=file:$METADATA_FILE install ghc --set 9.2.4 -fi - ghcup -v --url-source=file:$METADATA_FILE install $TOOL --set $VERSION mkdir -p /tmp/install-bindist-ci @@ -31,8 +28,60 @@ EOF case $TOOL in hls) - haskell-language-server-wrapper --version - haskell-language-server-wrapper typecheck main.hs + ghcup install cabal latest + ghcup install ghc --set recommended + 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 + if ghcup 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-/}" + else + fail "GHCup failed to install GHC ${bin_noexe/haskell-language-server-/}" + fi + ghcup rm ghc "${bin_noexe/haskell-language-server-/}" + 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