Skip to content

Commit 597bee9

Browse files
hasufelljneiramergify[bot]
authored
Add gitlab CI (#2200)
* Add gitlab CI * Add comment * Comment about vendored packages * Add link to gitlab ci config Co-authored-by: Javier Neira <atreyu.bbb@gmail.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent d5dd00a commit 597bee9

File tree

5 files changed

+309
-0
lines changed

5 files changed

+309
-0
lines changed

.gitlab-ci.yml

+114
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# Used for ci setup in the gitlab mirror of the project:
2+
# https://gitlab.haskell.org/haskell/haskell-language-server/-/pipelines
3+
variables:
4+
# Commit of ghc/ci-images repository from which to pull Docker images
5+
DOCKER_REV: "853f348f9caf38b08740b280296fbd34e09abb3a"
6+
7+
CABAL_INSTALL_VERSION: 3.4.0.0
8+
9+
.default_matrix: &default_matrix
10+
matrix:
11+
- GHC_VERSION: 8.8.4
12+
CABAL_PROJECT: cabal.project
13+
- GHC_VERSION: 8.10.7
14+
CABAL_PROJECT: cabal.project
15+
- GHC_VERSION: 9.0.1
16+
CABAL_PROJECT: cabal-ghc901.project
17+
18+
.m1_matrix: &m1_matrix
19+
matrix:
20+
- GHC_VERSION: 8.10.7
21+
CABAL_PROJECT: cabal.project
22+
23+
.arm_matrix: &arm_matrix
24+
matrix:
25+
- GHC_VERSION: 8.10.7
26+
CABAL_PROJECT: cabal.project
27+
28+
29+
workflow:
30+
rules:
31+
- if: $CI_COMMIT_TAG
32+
when: always
33+
- when: never
34+
35+
.build:
36+
script:
37+
- bash .gitlab/ci.sh
38+
artifacts:
39+
expire_in: 2 week
40+
paths:
41+
- out
42+
43+
build-aarch64-linux-deb10:
44+
extends: .build
45+
tags:
46+
- aarch64-linux
47+
image: "registry.gitlab.haskell.org/ghc/ci-images/aarch64-linux-deb10:$DOCKER_REV"
48+
parallel: *arm_matrix
49+
50+
build-armv7-linux-deb10:
51+
extends: .build
52+
tags:
53+
- armv7-linux
54+
image: "registry.gitlab.haskell.org/ghc/ci-images/armv7-linux-deb10:$DOCKER_REV"
55+
parallel: *arm_matrix
56+
57+
build-x86_64-linux:
58+
extends: .build
59+
tags:
60+
- x86_64-linux
61+
image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV"
62+
parallel: *default_matrix
63+
64+
build-x86_64-linux-alpine:
65+
extends: .build
66+
tags:
67+
- x86_64-linux
68+
image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-alpine3_12:$DOCKER_REV"
69+
parallel: *default_matrix
70+
71+
build-x86_64-freebsd:
72+
extends: .build
73+
tags:
74+
- x86_64-freebsd13
75+
parallel: *default_matrix
76+
77+
build-x86_64-darwin:
78+
extends: .build
79+
tags:
80+
- x86_64-darwin
81+
parallel: *default_matrix
82+
83+
build-aarch64-darwin:
84+
tags:
85+
- aarch64-darwin-m1
86+
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
102+
variables:
103+
MACOSX_DEPLOYMENT_TARGET: "10.7"
104+
parallel: *m1_matrix
105+
artifacts:
106+
expire_in: 2 week
107+
paths:
108+
- out
109+
110+
build-x86_64-windows:
111+
extends: .build
112+
tags:
113+
- new-x86_64-windows
114+
parallel: *default_matrix

.gitlab/ci.sh

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/usr/bin/env bash
2+
3+
set -Eeuxo pipefail
4+
5+
source "$CI_PROJECT_DIR/.gitlab/common.sh"
6+
7+
8+
export GHCUP_INSTALL_BASE_PREFIX="$CI_PROJECT_DIR/toolchain"
9+
export CABAL_DIR="$CI_PROJECT_DIR/cabal"
10+
11+
case "$(uname)" in
12+
MSYS_*|MINGW*)
13+
export CABAL_DIR="$(cygpath -w "$CABAL_DIR")"
14+
GHCUP_BINDIR="${GHCUP_INSTALL_BASE_PREFIX}/ghcup/bin"
15+
;;
16+
*)
17+
GHCUP_BINDIR="${GHCUP_INSTALL_BASE_PREFIX}/.ghcup/bin"
18+
;;
19+
esac
20+
21+
mkdir -p "$CABAL_DIR"
22+
mkdir -p "$GHCUP_BINDIR"
23+
export PATH="$GHCUP_BINDIR:$PATH"
24+
25+
export BOOTSTRAP_HASKELL_NONINTERACTIVE=1
26+
export BOOTSTRAP_HASKELL_GHC_VERSION="$GHC_VERSION"
27+
export BOOTSTRAP_HASKELL_CABAL_VERSION="$CABAL_INSTALL_VERSION"
28+
export BOOTSTRAP_HASKELL_VERBOSE=1
29+
export BOOTSTRAP_HASKELL_ADJUST_CABAL_CONFIG=yes
30+
31+
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh
32+
33+
# some alpines need workaround
34+
if ghc --info | grep -q integer-simple ; then
35+
echo -e 'package blaze-textual\n flags: +integer-simple' >> cabal.project.local
36+
fi
37+
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 \
49+
--enable-executable-stripping
50+
51+
cp dist-newstyle/cache/plan.json "$CI_PROJECT_DIR/out/plan.json"

.gitlab/common.sh

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Common bash utilities
2+
# ----------------------
3+
4+
# Colors
5+
BLACK="0;30"
6+
GRAY="1;30"
7+
RED="0;31"
8+
LT_RED="1;31"
9+
BROWN="0;33"
10+
LT_BROWN="1;33"
11+
GREEN="0;32"
12+
LT_GREEN="1;32"
13+
BLUE="0;34"
14+
LT_BLUE="1;34"
15+
PURPLE="0;35"
16+
LT_PURPLE="1;35"
17+
CYAN="0;36"
18+
LT_CYAN="1;36"
19+
WHITE="1;37"
20+
LT_GRAY="0;37"
21+
22+
# GitLab Pipelines log section delimiters
23+
# https://gitlab.com/gitlab-org/gitlab-foss/issues/14664
24+
start_section() {
25+
name="$1"
26+
echo -e "section_start:$(date +%s):$name\015\033[0K"
27+
}
28+
29+
end_section() {
30+
name="$1"
31+
echo -e "section_end:$(date +%s):$name\015\033[0K"
32+
}
33+
34+
echo_color() {
35+
local color="$1"
36+
local msg="$2"
37+
echo -e "\033[${color}m${msg}\033[0m"
38+
}
39+
40+
error() { echo_color "${RED}" "$1"; }
41+
warn() { echo_color "${LT_BROWN}" "$1"; }
42+
info() { echo_color "${LT_BLUE}" "$1"; }
43+
44+
fail() { error "error: $1"; exit 1; }
45+
46+
function run() {
47+
info "Running $*..."
48+
"$@" || ( error "$* failed"; return 1; )
49+
}

.gitlab/shell-aarch64-darwin.nix

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
{ system ? "aarch64-darwin"
2+
#, nixpkgs ? fetchTarball https://github.com/angerman/nixpkgs/archive/257cb120334.tar.gz #apple-silicon.tar.gz
3+
, pkgs ? import <nixpkgs> { inherit system; }
4+
, compiler ? if system == "aarch64-darwin" then "ghc8103Binary" else "ghc8103"
5+
}: pkgs.mkShell {
6+
# this prevents nix from trying to write the env-vars file.
7+
# we can't really, as NIX_BUILD_TOP/env-vars is not set.
8+
noDumpEnvVars=1;
9+
10+
# stop polluting LDFLAGS with -liconv
11+
dontAddExtraLibs = true;
12+
13+
# we need to inject ncurses into --with-curses-libraries.
14+
# the real fix is to teach terminfo to use libcurses on macOS.
15+
# CONFIGURE_ARGS = "--with-intree-gmp --with-curses-libraries=${pkgs.ncurses.out}/lib";
16+
CONFIGURE_ARGS = "--with-intree-gmp --with-curses-libraries=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib --with-iconv-includes=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include --with-iconv-libraries=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib SH=/bin/bash";
17+
18+
# magic speedup pony :facepalm:
19+
#
20+
# nix has the ugly habbit of duplicating ld flags more than necessary. This
21+
# somewhat consolidates this.
22+
shellHook = ''
23+
export NIX_LDFLAGS=$(for a in $NIX_LDFLAGS; do echo $a; done |sort|uniq|xargs)
24+
export NIX_LDFLAGS_FOR_TARGET=$(for a in $NIX_LDFLAGS_FOR_TARGET; do echo $a; done |sort|uniq|xargs)
25+
export NIX_LDFLAGS_FOR_TARGET=$(comm -3 <(for l in $NIX_LDFLAGS_FOR_TARGET; do echo $l; done) <(for l in $NIX_LDFLAGS; do echo $l; done))
26+
27+
28+
# Impurity hack for GHC releases.
29+
#################################
30+
# We don't want binary releases to depend on nix, thus we'll need to make sure we don't leak in references.
31+
# GHC externally depends only on iconv and curses. However we can't force a specific curses library for
32+
# the terminfo package, as such we'll need to make sure we only look in the system path for the curses library
33+
# and not pick up the tinfo from the nix provided ncurses package.
34+
#
35+
# We also need to force us to use the systems COREFOUNDATION, not the one that nix builds. Again this is impure,
36+
# but it will allow us to have proper binary distributions.
37+
#
38+
# do not use nixpkgs provided core foundation
39+
export NIX_COREFOUNDATION_RPATH=/System/Library/Frameworks
40+
# drop curses from the LDFLAGS, we really want the system ones, not the nix ones.
41+
export NIX_LDFLAGS=$(for lib in $NIX_LDFLAGS; do case "$lib" in *curses*);; *) echo -n "$lib ";; esac; done;)
42+
export NIX_CFLAGS_COMPILE+=" -Wno-nullability-completeness -Wno-availability -Wno-expansion-to-defined -Wno-builtin-requires-header -Wno-unused-command-line-argument"
43+
44+
# unconditionally add the MacOSX.sdk and TargetConditional.h
45+
export NIX_CFLAGS_COMPILE+=" -isystem /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include"
46+
export NIX_LDFLAGS="-L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib $NIX_LDFLAGS"
47+
48+
'';
49+
50+
nativeBuildInputs = (with pkgs; [
51+
# This needs to come *before* ghc,
52+
# otherwise we migth end up with the clang from
53+
# the bootstrap GHC in PATH with higher priority.
54+
clang_11
55+
llvm_11
56+
57+
haskell.compiler.${compiler}
58+
haskell.packages.${compiler}.cabal-install
59+
haskell.packages.${compiler}.alex
60+
haskell.packages.${compiler}.happy # _1_19_12 is needed for older GHCs.
61+
62+
automake
63+
autoconf
64+
m4
65+
66+
gmp
67+
zlib.out
68+
zlib.dev
69+
glibcLocales
70+
# locale doesn't build yet :-/
71+
# locale
72+
73+
git
74+
75+
python3
76+
# python3Full
77+
# python3Packages.sphinx
78+
perl
79+
80+
which
81+
wget
82+
curl
83+
file
84+
85+
xz
86+
xlibs.lndir
87+
88+
cacert ])
89+
++ (with pkgs.darwin.apple_sdk.frameworks; [ Foundation Security ]);
90+
}

cabal.project

+5
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ packages:
2525
./plugins/hls-ormolu-plugin
2626
./plugins/hls-call-hierarchy-plugin
2727

28+
-- Standard location for temporary packages needed for particular environments
29+
-- For example it is used in the project gitlab mirror to help in the MAcOS M1 build script
30+
-- See https://github.com/haskell/haskell-language-server/blob/master/.gitlab-ci.yml
31+
optional-packages: vendored/*/*.cabal
32+
2833
tests: true
2934

3035
package *

0 commit comments

Comments
 (0)