Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d3fc16e

Browse files
committedJan 20, 2025··
Simplify
1 parent 4ea640e commit d3fc16e

File tree

9 files changed

+184
-417
lines changed

9 files changed

+184
-417
lines changed
 

‎.github/scripts/bindist.sh

-5
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@ set -eux
55
. .github/scripts/env.sh
66
. .github/scripts/common.sh
77

8-
# ensure ghcup
9-
if ! command -v ghcup ; then
10-
install_ghcup
11-
fi
12-
138
# create tarball/zip
149
case "${TARBALL_EXT}" in
1510
zip)

‎.github/scripts/build.sh

+2-11
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,7 @@ uname
1111
pwd
1212
env
1313

14-
# ensure ghcup
15-
install_ghcup
16-
17-
# ensure cabal-cache
18-
download_cabal_cache "$HOME/.local/bin/cabal-cache"
19-
20-
2114
# build
22-
ghcup install ghc "${GHC_VERSION}"
23-
ghcup set ghc "${GHC_VERSION}"
2415
sed -i.bak -e '/DELETE MARKER FOR CI/,/END DELETE/d' cabal.project # see comment in cabal.project
2516
ecabal update
2617
ecabal user-config diff
@@ -48,7 +39,7 @@ case "$(uname)" in
4839
src/**/*.hs exe/*.hs
4940

5041
# shellcheck disable=SC2068
51-
build_with_cache ${args[@]} exe:hls exe:hls-wrapper
42+
ecabal build ${args[@]} exe:hls exe:hls-wrapper
5243
cp dist-newstyle/cache/plan.json "$CI_PROJECT_DIR/out/plan.json/${ARTIFACT}-ghc-${GHC_VERSION}-plan.json"
5344

5445
# shellcheck disable=SC2068
@@ -58,7 +49,7 @@ case "$(uname)" in
5849
;;
5950
*)
6051
emake --version
61-
emake GHCUP=ghcup CABAL_CACHE_BIN=cabal-cache.sh S3_HOST="${S3_HOST}" S3_KEY="${ARTIFACT}" GHC_VERSION="${GHC_VERSION}" hls-ghc
52+
emake GHCUP=ghcup GHC_VERSION="${GHC_VERSION}" hls-ghc
6253
;;
6354
esac
6455

‎.github/scripts/cabal-cache.sh

-20
This file was deleted.

‎.github/scripts/common.sh

+9-176
Original file line numberDiff line numberDiff line change
@@ -4,169 +4,28 @@
44

55
# Colors
66
RED="0;31"
7-
LT_BROWN="1;33"
8-
LT_BLUE="1;34"
97

108
ecabal() {
119
cabal "$@"
1210
}
1311

14-
nonfatal() {
15-
"$@" || "$* failed"
16-
}
17-
18-
# sync the relevant parts of cabal artifacts that are part of
19-
# the current plan.json from an S3 bucket
20-
sync_from() {
21-
if [ "${RUNNER_OS}" != "Windows" ] ; then
22-
cabal_store_path="$(dirname "$(cabal help user-config | tail -n 1 | xargs)")/store"
23-
fi
24-
25-
cabal-cache.sh sync-from-archive \
26-
--host-name-override="${S3_HOST}" \
27-
--host-port-override=443 \
28-
--host-ssl-override=True \
29-
--region us-west-2 \
30-
$([ "${RUNNER_OS}" != "Windows" ] && echo --store-path="$cabal_store_path") \
31-
--archive-uri "s3://haskell-language-server/${ARTIFACT}"
32-
}
33-
34-
# sync the relevant parts of cabal artifacts that are part of
35-
# the current plan.json to an S3 bucket
36-
sync_to() {
37-
if [ "${RUNNER_OS}" != "Windows" ] ; then
38-
cabal_store_path="$(dirname "$(cabal help user-config | tail -n 1 | xargs)")/store"
39-
fi
40-
41-
cabal-cache.sh sync-to-archive \
42-
--host-name-override="${S3_HOST}" \
43-
--host-port-override=443 \
44-
--host-ssl-override=True \
45-
--region us-west-2 \
46-
$([ "${RUNNER_OS}" != "Windows" ] && echo --store-path="$cabal_store_path") \
47-
--archive-uri "s3://haskell-language-server/${ARTIFACT}"
48-
}
49-
50-
sha_sum() {
51-
if [ "${RUNNER_OS}" = "FreeBSD" ] ; then
52-
sha256 "$@"
53-
else
54-
sha256sum "$@"
55-
fi
56-
}
57-
58-
git_describe() {
59-
git config --global --get-all safe.directory | grep '^\*$' || git config --global --add safe.directory "*"
60-
git describe --always
61-
}
62-
63-
download_cabal_cache() {
64-
(
65-
set -e
66-
dest="$HOME/.local/bin/cabal-cache"
67-
url=""
68-
exe=""
69-
cd /tmp
70-
case "${RUNNER_OS}" in
71-
"Linux")
72-
case "${ARCH}" in
73-
"32") url=https://downloads.haskell.org/~ghcup/unofficial-bindists/cabal-cache/experimental5/i386-linux-cabal-cache
74-
;;
75-
"64") url=https://downloads.haskell.org/~ghcup/unofficial-bindists/cabal-cache/experimental5/x86_64-linux-cabal-cache
76-
;;
77-
"ARM64") url=https://downloads.haskell.org/~ghcup/unofficial-bindists/cabal-cache/experimental5/aarch64-linux-cabal-cache
78-
;;
79-
"ARM") url=https://downloads.haskell.org/~ghcup/unofficial-bindists/cabal-cache/experimental5/armv7-linux-cabal-cache
80-
;;
81-
esac
82-
;;
83-
"FreeBSD")
84-
url=https://downloads.haskell.org/~ghcup/unofficial-bindists/cabal-cache/experimental5/x86_64-portbld-freebsd-cabal-cache
85-
;;
86-
"Windows")
87-
exe=".exe"
88-
url=https://downloads.haskell.org/~ghcup/unofficial-bindists/cabal-cache/experimental5/x86_64-mingw64-cabal-cache
89-
;;
90-
"macOS")
91-
case "${ARCH}" in
92-
"ARM64") url=https://downloads.haskell.org/~ghcup/unofficial-bindists/cabal-cache/experimental5/aarch64-apple-darwin-cabal-cache
93-
;;
94-
"64") url=https://downloads.haskell.org/~ghcup/unofficial-bindists/cabal-cache/experimental5/x86_64-apple-darwin-cabal-cache
95-
;;
96-
esac
97-
;;
98-
esac
99-
100-
if [ -n "${url}" ] ; then
101-
case "${url##*.}" in
102-
"gz")
103-
curl -L -o - "${url}" | gunzip > cabal-cache${exe}
104-
;;
105-
*)
106-
curl -o cabal-cache${exe} -L "${url}"
107-
;;
108-
esac
109-
sha_sum cabal-cache${exe}
110-
mv "cabal-cache${exe}" "${dest}${exe}"
111-
chmod +x "${dest}${exe}"
112-
fi
113-
114-
# install shell wrapper
115-
cp "${CI_PROJECT_DIR}"/.github/scripts/cabal-cache.sh "$HOME"/.local/bin/
116-
chmod +x "$HOME"/.local/bin/cabal-cache.sh
117-
)
118-
}
119-
120-
build_with_cache() {
121-
ecabal configure "$@"
122-
ecabal build --dependencies-only "$@" --dry-run
123-
nonfatal sync_from
124-
ecabal build "$@"
125-
nonfatal sync_to
126-
}
127-
128-
install_ghcup() {
129-
# find "$GHCUP_INSTALL_BASE_PREFIX"
130-
mkdir -p "$GHCUP_BIN"
131-
mkdir -p "$GHCUP_BIN"/../cache
132-
133-
if [ "${RUNNER_OS}" = "FreeBSD" ] ; then
134-
curl -o ghcup https://downloads.haskell.org/ghcup/tmp/x86_64-portbld-freebsd-ghcup-0.1.18.1
135-
chmod +x ghcup
136-
mv ghcup "$HOME/.local/bin/ghcup"
12+
emake() {
13+
if command -v gmake >/dev/null 2>&1 ; then
14+
gmake "$@"
13715
else
138-
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | BOOTSTRAP_HASKELL_MINIMAL=1 sh
139-
source "$(dirname "${GHCUP_BIN}")/env"
140-
ghcup install cabal --set "${BOOTSTRAP_HASKELL_CABAL_VERSION}"
16+
make "$@"
14117
fi
14218
}
14319

144-
strip_binary() {
145-
(
146-
set -e
147-
local binary=$1
20+
mktempdir() {
14821
case "$(uname -s)" in
14922
"Darwin"|"darwin")
150-
;;
151-
MSYS_*|MINGW*)
23+
mktemp -d -t hls_ci.XXXXXXX
15224
;;
15325
*)
154-
strip -s "${binary}"
155-
;;
156-
esac
157-
)
158-
}
159-
160-
# GitLab Pipelines log section delimiters
161-
# https://gitlab.com/gitlab-org/gitlab-foss/issues/14664
162-
start_section() {
163-
name="$1"
164-
echo -e "section_start:$(date +%s):$name\015\033[0K"
165-
}
166-
167-
end_section() {
168-
name="$1"
169-
echo -e "section_end:$(date +%s):$name\015\033[0K"
26+
mktemp -d
27+
;;
28+
esac
17029
}
17130

17231
echo_color() {
@@ -176,31 +35,5 @@ echo_color() {
17635
}
17736

17837
error() { echo_color "${RED}" "$1"; }
179-
warn() { echo_color "${LT_BROWN}" "$1"; }
180-
info() { echo_color "${LT_BLUE}" "$1"; }
18138

18239
fail() { error "error: $1"; exit 1; }
183-
184-
run() {
185-
info "Running $*..."
186-
"$@" || ( error "$* failed"; return 1; )
187-
}
188-
189-
emake() {
190-
if command -v gmake >/dev/null 2>&1 ; then
191-
gmake "$@"
192-
else
193-
make "$@"
194-
fi
195-
}
196-
197-
mktempdir() {
198-
case "$(uname -s)" in
199-
"Darwin"|"darwin")
200-
mktemp -d -t hls_ci.XXXXXXX
201-
;;
202-
*)
203-
mktemp -d
204-
;;
205-
esac
206-
}

‎.github/scripts/env.sh

-17
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,19 @@
11
#!/bin/bash
22

3-
mkdir -p "$HOME"/.local/bin
4-
53
if [ "${RUNNER_OS}" = "Windows" ] ; then
64
ext=".exe"
75
else
86
ext=''
97
fi
108

11-
export PATH="$HOME/.local/bin:$PATH"
12-
13-
export BOOTSTRAP_HASKELL_NONINTERACTIVE=1
14-
export BOOTSTRAP_HASKELL_CABAL_VERSION="${CABAL_VER:-3.10.3.0}"
15-
export BOOTSTRAP_HASKELL_ADJUST_CABAL_CONFIG=no
16-
export BOOTSTRAP_HASKELL_INSTALL_NO_STACK=yes
17-
export BOOTSTRAP_HASKELL_ADJUST_BASHRC=1
18-
199
if [ "${RUNNER_OS}" = "Windows" ] ; then
2010
# on windows use pwd to get unix style path
2111
CI_PROJECT_DIR="$(pwd)"
2212
export CI_PROJECT_DIR
23-
export GHCUP_INSTALL_BASE_PREFIX="/c"
24-
export GHCUP_BIN="$GHCUP_INSTALL_BASE_PREFIX/ghcup/bin"
25-
export PATH="$GHCUP_BIN:$PATH"
2613
export CABAL_DIR="C:\\Users\\runneradmin\\AppData\\Roaming\\cabal"
2714
else
2815
export CI_PROJECT_DIR="${GITHUB_WORKSPACE}"
29-
export GHCUP_INSTALL_BASE_PREFIX="$CI_PROJECT_DIR"
30-
export GHCUP_BIN="$GHCUP_INSTALL_BASE_PREFIX/.ghcup/bin"
31-
export PATH="$GHCUP_BIN:$PATH"
3216
export CABAL_DIR="$CI_PROJECT_DIR/cabal"
33-
export CABAL_CACHE="$CI_PROJECT_DIR/cabal-cache"
3417
fi
3518

3619
export DEBIAN_FRONTEND=noninteractive

‎.github/scripts/test.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,14 @@ uname
7070
env
7171

7272
# ensure ghcup
73-
install_ghcup
7473
ghcup install ghc --set 9.4.8
7574

7675
(cd .. && ecabal update) # run cabal update outside project dir
7776

7877
# unpack
7978
TARBALL_PREFIX="haskell-language-server"
79+
80+
: "${GHCUP_BIN:=$(ghcup whereis bindir)}"
8081
mkdir -p "${GHCUP_BIN}"
8182

8283
case "${TARBALL_EXT}" in

‎.github/workflows/release.yaml

+170-128
Large diffs are not rendered by default.

‎.github/workflows/s3-cache.yaml

-43
This file was deleted.

‎GNUmakefile

+1-16
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ GHCUP ?= echo
4545
GHCUP_GC ?= $(GHCUP) gc
4646
GHCUP_RM ?= $(GHCUP) rm
4747

48-
CABAL_CACHE_BIN ?= echo
49-
5048
ifeq ($(UNAME), Darwin)
5149
DLL := *.dylib
5250
else
@@ -65,24 +63,13 @@ CABAL_INSTALL_ARGS ?= --overwrite-policy=always --install-method=copy
6563
CABAL_INSTALL := $(CABAL) $(CABAL_BASE_ARGS) v2-install
6664
PROJECT_FILE := cabal.project
6765

68-
S3_HOST ?=
69-
S3_KEY ?=
70-
7166
# set rpath relative to the current executable
7267
# TODO: on darwin, this doesn't overwrite rpath, but just adds to it,
7368
# so we'll have the old rpaths from the build host in there as well
7469
define set_rpath
7570
$(if $(filter Darwin,$(UNAME)), $(INSTALL_NAME_TOOL) -add_rpath "@executable_path/$(1)" "$(2)", $(PATCHELF) --force-rpath --set-rpath "\$$ORIGIN/$(1)" "$(2)")
7671
endef
7772

78-
define sync_from
79-
$(CABAL_CACHE_BIN) sync-from-archive --host-name-override=$(S3_HOST) --host-port-override=443 --host-ssl-override=True --region us-west-2 --store-path="$(ROOT_DIR)/$(STORE_DIR)" --archive-uri "s3://haskell-language-server/$(S3_KEY)"
80-
endef
81-
82-
define sync_to
83-
$(CABAL_CACHE_BIN) sync-to-archive --host-name-override=$(S3_HOST) --host-port-override=443 --host-ssl-override=True --region us-west-2 --store-path="$(ROOT_DIR)/$(STORE_DIR)" --archive-uri "s3://haskell-language-server/$(S3_KEY)"
84-
endef
85-
8673
hls:
8774
@if test -z "$(GHCS)" ; then echo >&2 "GHCS is not set" ; false ; fi
8875
for ghc in $(GHCS) ; do \
@@ -98,10 +85,8 @@ hls-ghc:
9885
@if test -z "$(GHC_VERSION)" ; then echo >&2 "GHC_VERSION is not set" ; false ; fi
9986
$(CABAL) $(CABAL_BASE_ARGS) configure --project-file="$(PROJECT_FILE)" -w "ghc-$(GHC_VERSION)" $(CABAL_ARGS) exe:haskell-language-server exe:haskell-language-server-wrapper
10087
$(CABAL) $(CABAL_BASE_ARGS) build --project-file="$(PROJECT_FILE)" -w "ghc-$(GHC_VERSION)" $(CABAL_ARGS) --dependencies-only --dry-run exe:haskell-language-server exe:haskell-language-server-wrapper
101-
$(call sync_from)
10288
$(CP) dist-newstyle/cache/plan.json "$(ROOT_DIR)/out/plan.json/$(ARTIFACT)-ghc-$(GHC_VERSION)-plan.json"
10389
$(CABAL_INSTALL) --project-file="$(PROJECT_FILE)" -w "ghc-$(GHC_VERSION)" $(CABAL_ARGS) $(CABAL_INSTALL_ARGS) --installdir="$(ROOT_DIR)/out/$(ARTIFACT)/$(GHC_VERSION)" exe:haskell-language-server exe:haskell-language-server-wrapper
104-
$(call sync_to)
10590
$(STRIP_S) "$(ROOT_DIR)/out/$(ARTIFACT)/$(GHC_VERSION)/haskell-language-server"
10691
$(STRIP_S) "$(ROOT_DIR)/out/$(ARTIFACT)/$(GHC_VERSION)/haskell-language-server-wrapper"
10792

@@ -138,7 +123,7 @@ bindist-ghc:
138123
$(INSTALL_D) "$(BINDIST_OUT_DIR)/bin/"
139124
$(INSTALL_X) "out/$(ARTIFACT)/$(GHC_VERSION)/haskell-language-server-wrapper" "$(BINDIST_OUT_DIR)/bin/haskell-language-server-wrapper"
140125
$(INSTALL_D) "$(ROOT_DIR)/$(BINDIST_OUT_DIR)/lib/$(GHC_VERSION)"
141-
$(FIND) "$(STORE_DIR)/ghc-$(GHC_VERSION)" -type f -name "$(DLL)" -execdir $(INSTALL_X) "{}" "$(ROOT_DIR)/$(BINDIST_OUT_DIR)/lib/$(GHC_VERSION)/{}" \;
126+
$(FIND) "$(STORE_DIR)/ghc-$(GHC_VERSION)"* -type f -name "$(DLL)" -execdir $(INSTALL_X) "{}" "$(ROOT_DIR)/$(BINDIST_OUT_DIR)/lib/$(GHC_VERSION)/{}" \;
142127
$(FIND) "$(ROOT_DIR)/$(BINDIST_OUT_DIR)/lib/$(GHC_VERSION)" -type f -name '$(DLL)' -execdir $(call set_rpath,,{}) \;
143128

144129
version:

0 commit comments

Comments
 (0)
Please sign in to comment.