Skip to content

Commit d7aa5cd

Browse files
committed
Simplify
1 parent 4ea640e commit d7aa5cd

File tree

7 files changed

+153
-373
lines changed

7 files changed

+153
-373
lines changed

.github/scripts/build.sh

Lines changed: 2 additions & 11 deletions
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

Lines changed: 0 additions & 20 deletions
This file was deleted.

.github/scripts/common.sh

Lines changed: 0 additions & 180 deletions
Original file line numberDiff line numberDiff line change
@@ -2,190 +2,10 @@
22

33
. .github/scripts/env.sh
44

5-
# Colors
6-
RED="0;31"
7-
LT_BROWN="1;33"
8-
LT_BLUE="1;34"
9-
105
ecabal() {
116
cabal "$@"
127
}
138

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"
137-
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}"
141-
fi
142-
}
143-
144-
strip_binary() {
145-
(
146-
set -e
147-
local binary=$1
148-
case "$(uname -s)" in
149-
"Darwin"|"darwin")
150-
;;
151-
MSYS_*|MINGW*)
152-
;;
153-
*)
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"
170-
}
171-
172-
echo_color() {
173-
local color="$1"
174-
local msg="$2"
175-
echo -e "\033[${color}m${msg}\033[0m"
176-
}
177-
178-
error() { echo_color "${RED}" "$1"; }
179-
warn() { echo_color "${LT_BROWN}" "$1"; }
180-
info() { echo_color "${LT_BLUE}" "$1"; }
181-
182-
fail() { error "error: $1"; exit 1; }
183-
184-
run() {
185-
info "Running $*..."
186-
"$@" || ( error "$* failed"; return 1; )
187-
}
188-
1899
emake() {
19010
if command -v gmake >/dev/null 2>&1 ; then
19111
gmake "$@"

.github/scripts/env.sh

Lines changed: 0 additions & 17 deletions
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

0 commit comments

Comments
 (0)