|
2 | 2 |
|
3 | 3 | . .github/scripts/env.sh
|
4 | 4 |
|
5 |
| -# Colors |
6 |
| -RED="0;31" |
7 |
| -LT_BROWN="1;33" |
8 |
| -LT_BLUE="1;34" |
9 |
| - |
10 | 5 | ecabal() {
|
11 | 6 | cabal "$@"
|
12 | 7 | }
|
13 | 8 |
|
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 |
| - |
189 | 9 | emake() {
|
190 | 10 | if command -v gmake >/dev/null 2>&1 ; then
|
191 | 11 | gmake "$@"
|
|
0 commit comments