Skip to content

Commit e74cf55

Browse files
hasufellmergify[bot]jneira
authored
Build on FreeBSD12 only (#2420)
* Build on FreeBSD12 only * Use deb10 for linux builds * Improve gitlab CI * Fix taring up Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Javier Neira <[email protected]>
1 parent 84ece63 commit e74cf55

File tree

3 files changed

+268
-40
lines changed

3 files changed

+268
-40
lines changed

.gitlab-ci.yml

Lines changed: 200 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
# Used for ci setup in the gitlab mirror of the project:
1+
stages:
2+
- build
3+
- tar
4+
5+
# Used for ci setup in the gitlab mirror of the project:
26
# https://gitlab.haskell.org/haskell/haskell-language-server/-/pipelines
37
variables:
48
# Commit of ghc/ci-images repository from which to pull Docker images
5-
DOCKER_REV: "853f348f9caf38b08740b280296fbd34e09abb3a"
9+
DOCKER_REV: "4ed1a4f27828ba96a34662dc954335e29b470cd2"
610

7-
CABAL_INSTALL_VERSION: 3.4.0.0
11+
CABAL_INSTALL_VERSION: 3.6.2.0
812

913
.default_matrix: &default_matrix
1014
matrix:
@@ -32,83 +36,252 @@ workflow:
3236
when: always
3337
- when: never
3438

35-
.build:
36-
script:
37-
- bash .gitlab/ci.sh
39+
.artifacts:
3840
artifacts:
3941
expire_in: 2 week
4042
paths:
4143
- out
4244

45+
.artifacts:short:
46+
artifacts:
47+
expire_in: 1 day
48+
paths:
49+
- out
50+
51+
.build:
52+
extends: .artifacts:short
53+
stage: build
54+
script:
55+
- bash .gitlab/ci.sh
56+
4357
build-aarch64-linux-deb10:
4458
extends: .build
4559
tags:
4660
- aarch64-linux
4761
image: "registry.gitlab.haskell.org/ghc/ci-images/aarch64-linux-deb10:$DOCKER_REV"
4862
parallel: *arm_matrix
63+
variables:
64+
ADD_CABAL_ARGS: ""
65+
66+
tar-aarch64-linux-deb10:
67+
extends: .artifacts
68+
stage: tar
69+
needs: ["build-aarch64-linux-deb10"]
70+
tags:
71+
- aarch64-linux
72+
image: "registry.gitlab.haskell.org/ghc/ci-images/aarch64-linux-deb10:$DOCKER_REV"
73+
script:
74+
- ./.gitlab/tar.sh
75+
variables:
76+
TARBALL_ARCHIVE_SUFFIX: aarch64-linux-deb10
77+
TARBALL_EXT: tar.xz
4978

5079
build-armv7-linux-deb10:
5180
extends: .build
5281
tags:
5382
- armv7-linux
5483
image: "registry.gitlab.haskell.org/ghc/ci-images/armv7-linux-deb10:$DOCKER_REV"
5584
parallel: *arm_matrix
85+
variables:
86+
ADD_CABAL_ARGS: ""
87+
88+
tar-armv7-linux-deb10:
89+
extends: .artifacts
90+
stage: tar
91+
needs: ["build-armv7-linux-deb10"]
92+
tags:
93+
- armv7-linux
94+
image: "registry.gitlab.haskell.org/ghc/ci-images/armv7-linux-deb10:$DOCKER_REV"
95+
script:
96+
- ./.gitlab/tar.sh
97+
variables:
98+
TARBALL_ARCHIVE_SUFFIX: armv7-linux-deb10
99+
TARBALL_EXT: tar.xz
56100

57101
build-x86_64-linux:
58102
extends: .build
59103
tags:
60104
- x86_64-linux
61-
image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV"
105+
image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10:$DOCKER_REV"
62106
parallel: *default_matrix
107+
variables:
108+
ADD_CABAL_ARGS: "--enable-split-sections"
109+
110+
tar-x86_64-linux:
111+
extends: .artifacts
112+
stage: tar
113+
needs: ["build-x86_64-linux"]
114+
tags:
115+
- x86_64-linux
116+
image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10:$DOCKER_REV"
117+
script:
118+
- ./.gitlab/tar.sh
119+
variables:
120+
TARBALL_ARCHIVE_SUFFIX: x86_64-linux
121+
TARBALL_EXT: tar.xz
63122

64123
build-x86_64-linux-alpine:
65124
extends: .build
66125
tags:
67126
- x86_64-linux
68127
image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-alpine3_12:$DOCKER_REV"
128+
before_script:
129+
- sudo apk add --no-cache zlib zlib-dev zlib-static bzip2 bzip2-dev bzip2-static gmp gmp-dev xz xz-dev ncurses-static
130+
parallel: *default_matrix
131+
variables:
132+
ADD_CABAL_ARGS: "--enable-split-sections --enable-executable-static"
133+
134+
tar-x86_64-linux-alpine:
135+
extends: .artifacts
136+
stage: tar
137+
needs: ["build-x86_64-linux-alpine"]
138+
tags:
139+
- x86_64-linux
140+
image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-alpine3_12:$DOCKER_REV"
141+
script:
142+
- ./.gitlab/tar.sh
143+
variables:
144+
TARBALL_ARCHIVE_SUFFIX: x86_64-linux-alpine
145+
TARBALL_EXT: tar.xz
146+
147+
build-x86_64-freebsd12:
148+
extends: .build
149+
tags:
150+
- x86_64-freebsd12
69151
parallel: *default_matrix
152+
variables:
153+
ADD_CABAL_ARGS: "--enable-split-sections"
154+
155+
tar-x86_64-freebsd12:
156+
extends: .artifacts
157+
stage: tar
158+
needs: ["build-x86_64-freebsd12"]
159+
tags:
160+
- x86_64-freebsd12
161+
script:
162+
- ./.gitlab/tar.sh
163+
variables:
164+
TARBALL_ARCHIVE_SUFFIX: x86_64-freebsd12
165+
TARBALL_EXT: tar.xz
70166

71-
build-x86_64-freebsd:
167+
build-x86_64-freebsd13:
72168
extends: .build
73169
tags:
74170
- x86_64-freebsd13
75171
parallel: *default_matrix
172+
before_script:
173+
- sudo pkg update
174+
- sudo pkg install --yes compat12x-amd64
175+
- sudo ln -s libncurses.so.6 /usr/local/lib/libncurses.so.6.2
176+
variables:
177+
ADD_CABAL_ARGS: "--enable-split-sections"
178+
179+
tar-x86_64-freebsd13:
180+
extends: .artifacts
181+
stage: tar
182+
needs: ["build-x86_64-freebsd13"]
183+
tags:
184+
- x86_64-freebsd13
185+
script:
186+
- ./.gitlab/tar.sh
187+
variables:
188+
TARBALL_ARCHIVE_SUFFIX: x86_64-freebsd13
189+
TARBALL_EXT: tar.xz
76190

77191
build-x86_64-darwin:
78192
extends: .build
79193
tags:
80194
- x86_64-darwin
81195
parallel: *default_matrix
196+
variables:
197+
ADD_CABAL_ARGS: ""
198+
199+
tar-x86_64-darwin:
200+
extends: .artifacts
201+
stage: tar
202+
needs: ["build-x86_64-darwin"]
203+
tags:
204+
- x86_64-darwin
205+
script:
206+
- ./.gitlab/tar.sh
207+
variables:
208+
TARBALL_ARCHIVE_SUFFIX: x86_64-darwin
209+
TARBALL_EXT: tar.xz
82210

83211
build-aarch64-darwin:
212+
extends: .artifacts:short
213+
stage: build
84214
tags:
85215
- aarch64-darwin-m1
216+
before_script:
217+
# Install brew locally in the project dir. Packages will also be installed here.
218+
- '[ -e "$CI_PROJECT_DIR/.brew" ] || git clone --depth=1 https://github.com/Homebrew/brew $CI_PROJECT_DIR/.brew'
219+
- export PATH="$CI_PROJECT_DIR/.brew/bin:$CI_PROJECT_DIR/.brew/sbin:$PATH"
220+
221+
# otherwise we seem to get intel binaries
222+
- export HOMEBREW_CHANGE_ARCH_TO_ARM=1
223+
224+
# make sure to not pollute the machine with temp files etc
225+
- mkdir -p $CI_PROJECT_DIR/.brew_cache
226+
- export HOMEBREW_CACHE=$CI_PROJECT_DIR/.brew_cache
227+
- mkdir -p $CI_PROJECT_DIR/.brew_logs
228+
- export HOMEBREW_LOGS=$CI_PROJECT_DIR/.brew_logs
229+
- mkdir -p /private/tmp/.brew_tmp
230+
- export HOMEBREW_TEMP=/private/tmp/.brew_tmp
231+
232+
# update and install packages
233+
- brew update
234+
- brew install llvm
235+
- brew install autoconf automake coreutils
86236
script: |
87-
set -Eeuo pipefail
88-
function runInNixShell() {
89-
time nix-shell $CI_PROJECT_DIR/.gitlab/shell-aarch64-darwin.nix \
90-
-I nixpkgs=https://github.com/angerman/nixpkgs/archive/75f7281738b.tar.gz \
91-
--argstr system "aarch64-darwin" \
92-
--pure \
93-
--keep CI_PROJECT_DIR \
94-
--keep MACOSX_DEPLOYMENT_TARGET \
95-
--keep GHC_VERSION \
96-
--keep CABAL_PROJECT \
97-
--keep CABAL_INSTALL_VERSION \
98-
--run "$1" 2>&1
99-
}
100-
runInNixShell "cabal update && mkdir vendored && cd vendored && cabal unpack network-3.1.2.1 && cd network-3.1.2.1 && autoreconf -fi" 2>&1
101-
runInNixShell "./.gitlab/ci.sh" 2>&1
237+
export PATH="$CI_PROJECT_DIR/.brew/opt/llvm/bin:$CI_PROJECT_DIR/.brew/bin:$CI_PROJECT_DIR/.brew/sbin:$PATH"
238+
export CC=$CI_PROJECT_DIR/.brew/opt/llvm/bin/clang
239+
export CXX=$CI_PROJECT_DIR/.brew/opt/llvm/bin/clang++
240+
export LD=ld
241+
export AR=$CI_PROJECT_DIR/.brew/opt/llvm/bin/llvm-ar
242+
export RANLIB=$CI_PROJECT_DIR/.brew/opt/llvm/bin/llvm-ranlib
243+
arch -arm64 /bin/bash ./.gitlab/ci.sh
244+
after_script:
245+
- rm -Rf /private/tmp/.brew_tmp
102246
variables:
103247
MACOSX_DEPLOYMENT_TARGET: "10.7"
248+
ADD_CABAL_ARGS: ""
104249
parallel: *m1_matrix
105-
artifacts:
106-
expire_in: 2 week
107-
paths:
108-
- out
250+
251+
tar-aarch64-darwin:
252+
extends: .artifacts
253+
stage: tar
254+
needs: ["build-aarch64-darwin"]
255+
tags:
256+
- aarch64-darwin-m1
257+
script:
258+
- arch -arm64 /bin/bash ./.gitlab/tar.sh
259+
variables:
260+
TARBALL_ARCHIVE_SUFFIX: aarch64-darwin
261+
TARBALL_EXT: tar.xz
109262

110263
build-x86_64-windows:
111264
extends: .build
112265
tags:
113266
- new-x86_64-windows
114267
parallel: *default_matrix
268+
script:
269+
- bash '-lc' 'pacman --noconfirm -S zip'
270+
- $env:CHERE_INVOKING = "yes"
271+
- bash '-lc' "ADD_CABAL_ARGS=$env:ADD_CABAL_ARGS GHC_VERSION=$env:GHC_VERSION CABAL_INSTALL_VERSION=$CABAL_INSTALL_VERSION .gitlab/ci.sh"
272+
variables:
273+
ADD_CABAL_ARGS: ""
274+
275+
tar-x86_64-windows:
276+
extends: .artifacts
277+
stage: tar
278+
needs: ["build-x86_64-windows"]
279+
tags:
280+
- new-x86_64-windows
281+
script:
282+
- $env:CHERE_INVOKING = "yes"
283+
- bash '-lc' "TARBALL_ARCHIVE_SUFFIX=$env:TARBALL_ARCHIVE_SUFFIX TARBALL_EXT=$env:TARBALL_EXT .gitlab/tar.sh"
284+
variables:
285+
TARBALL_ARCHIVE_SUFFIX: x86_64-windows
286+
TARBALL_EXT: zip
287+

.gitlab/ci.sh

Lines changed: 42 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ set -Eeuxo pipefail
44

55
source "$CI_PROJECT_DIR/.gitlab/common.sh"
66

7-
87
export GHCUP_INSTALL_BASE_PREFIX="$CI_PROJECT_DIR/toolchain"
98
export CABAL_DIR="$CI_PROJECT_DIR/cabal"
109

@@ -28,24 +27,54 @@ export BOOTSTRAP_HASKELL_CABAL_VERSION="$CABAL_INSTALL_VERSION"
2827
export BOOTSTRAP_HASKELL_VERBOSE=1
2928
export BOOTSTRAP_HASKELL_ADJUST_CABAL_CONFIG=yes
3029

31-
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh
30+
# for some reason the subshell doesn't pick up the arm64 environment on darwin
31+
# and starts installing x86_64 GHC
32+
case "$(uname -s)" in
33+
"Darwin"|"darwin")
34+
case "$(/usr/bin/arch)" in
35+
aarch64|arm64|armv8l)
36+
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | arch -arm64 /bin/bash
37+
;;
38+
*)
39+
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh
40+
;;
41+
esac
42+
;;
43+
*)
44+
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh
45+
;;
46+
esac
3247

3348
# some alpines need workaround
3449
if ghc --info | grep -q integer-simple ; then
3550
echo -e 'package blaze-textual\n flags: +integer-simple' >> cabal.project.local
3651
fi
3752

38-
run cabal v2-install exe:haskell-language-server exe:haskell-language-server-wrapper \
39-
-O2 \
40-
-w "ghc-$GHC_VERSION" \
41-
--project-file "$CABAL_PROJECT" \
42-
--installdir="$CI_PROJECT_DIR/out" \
43-
--install-method=copy \
44-
--overwrite-policy=always \
45-
--enable-executable-static \
46-
--disable-profiling \
47-
--disable-tests \
48-
--enable-split-sections \
53+
# Shorten binary names
54+
sed -i.bak -e 's/haskell-language-server/hls/g' \
55+
-e 's/haskell_language_server/hls/g' \
56+
haskell-language-server.cabal cabal.project
57+
sed -i.bak -e 's/Paths_haskell_language_server/Paths_hls/g' \
58+
src/**/*.hs exe/*.hs
59+
60+
args=(
61+
-O2
62+
-w "ghc-$GHC_VERSION"
63+
--project-file "$CABAL_PROJECT"
64+
--disable-profiling
65+
--disable-tests
4966
--enable-executable-stripping
67+
${ADD_CABAL_ARGS}
68+
)
69+
70+
run cabal v2-build ${args[@]} exe:hls exe:hls-wrapper
71+
72+
mkdir "$CI_PROJECT_DIR/out"
73+
74+
cp "$(cabal list-bin ${args[@]} exe:hls)" "$CI_PROJECT_DIR/out/haskell-language-server-${GHC_VERSION}"
75+
cp "$(cabal list-bin ${args[@]} exe:hls-wrapper)" "$CI_PROJECT_DIR/out/haskell-language-server-wrapper"
5076

5177
cp dist-newstyle/cache/plan.json "$CI_PROJECT_DIR/out/plan.json"
78+
79+
cd "$CI_PROJECT_DIR/out/"
80+

.gitlab/tar.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env bash
2+
3+
set -Eeuxo pipefail
4+
5+
source "$CI_PROJECT_DIR/.gitlab/common.sh"
6+
7+
ls -la out/
8+
cd out/
9+
10+
# create tarball/zip
11+
TARBALL_PREFIX="haskell-language-server-$("$CI_PROJECT_DIR/out/haskell-language-server-wrapper" --numeric-version)"
12+
case "${TARBALL_EXT}" in
13+
zip)
14+
zip "${TARBALL_PREFIX}-${TARBALL_ARCHIVE_SUFFIX}.${TARBALL_EXT}" haskell-language-server-*
15+
find . -type f ! -name '*.zip' -delete
16+
;;
17+
tar.xz)
18+
tar caf "${TARBALL_PREFIX}-${TARBALL_ARCHIVE_SUFFIX}.${TARBALL_EXT}" haskell-language-server-*
19+
find . -type f ! -name '*.tar.xz' -delete
20+
;;
21+
*)
22+
fail "Unknown TARBALL_EXT: ${TARBALL_EXT}"
23+
;;
24+
esac
25+
26+

0 commit comments

Comments
 (0)