Skip to content

Commit c9025bd

Browse files
committed
Add gitlab CI
1 parent ea032ce commit c9025bd

File tree

5 files changed

+304
-0
lines changed

5 files changed

+304
-0
lines changed

.gitlab-ci.yml

+112
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
variables:
2+
# Commit of ghc/ci-images repository from which to pull Docker images
3+
DOCKER_REV: "853f348f9caf38b08740b280296fbd34e09abb3a"
4+
5+
CABAL_INSTALL_VERSION: 3.4.0.0
6+
7+
.default_matrix: &default_matrix
8+
matrix:
9+
- GHC_VERSION: 8.8.4
10+
CABAL_PROJECT: cabal.project
11+
- GHC_VERSION: 8.10.7
12+
CABAL_PROJECT: cabal.project
13+
- GHC_VERSION: 9.0.1
14+
CABAL_PROJECT: cabal-ghc901.project
15+
16+
.m1_matrix: &m1_matrix
17+
matrix:
18+
- GHC_VERSION: 8.10.7
19+
CABAL_PROJECT: cabal.project
20+
21+
.arm_matrix: &arm_matrix
22+
matrix:
23+
- GHC_VERSION: 8.10.7
24+
CABAL_PROJECT: cabal.project
25+
26+
27+
workflow:
28+
rules:
29+
- if: $CI_COMMIT_TAG
30+
when: always
31+
- when: never
32+
33+
.build:
34+
script:
35+
- bash .gitlab/ci.sh
36+
artifacts:
37+
expire_in: 2 week
38+
paths:
39+
- out
40+
41+
build-aarch64-linux-deb10:
42+
extends: .build
43+
tags:
44+
- aarch64-linux
45+
image: "registry.gitlab.haskell.org/ghc/ci-images/aarch64-linux-deb10:$DOCKER_REV"
46+
parallel: *arm_matrix
47+
48+
build-armv7-linux-deb10:
49+
extends: .build
50+
tags:
51+
- armv7-linux
52+
image: "registry.gitlab.haskell.org/ghc/ci-images/armv7-linux-deb10:$DOCKER_REV"
53+
parallel: *arm_matrix
54+
55+
build-x86_64-linux:
56+
extends: .build
57+
tags:
58+
- x86_64-linux
59+
image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV"
60+
parallel: *default_matrix
61+
62+
build-x86_64-linux-alpine:
63+
extends: .build
64+
tags:
65+
- x86_64-linux
66+
image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-alpine3_12:$DOCKER_REV"
67+
parallel: *default_matrix
68+
69+
build-x86_64-freebsd:
70+
extends: .build
71+
tags:
72+
- x86_64-freebsd13
73+
parallel: *default_matrix
74+
75+
build-x86_64-darwin:
76+
extends: .build
77+
tags:
78+
- x86_64-darwin
79+
parallel: *default_matrix
80+
81+
build-aarch64-darwin:
82+
tags:
83+
- aarch64-darwin-m1
84+
script: |
85+
set -Eeuo pipefail
86+
function runInNixShell() {
87+
time nix-shell $CI_PROJECT_DIR/.gitlab/shell-aarch64-darwin.nix \
88+
-I nixpkgs=https://github.com/angerman/nixpkgs/archive/75f7281738b.tar.gz \
89+
--argstr system "aarch64-darwin" \
90+
--pure \
91+
--keep CI_PROJECT_DIR \
92+
--keep MACOSX_DEPLOYMENT_TARGET \
93+
--keep GHC_VERSION \
94+
--keep CABAL_PROJECT \
95+
--keep CABAL_INSTALL_VERSION \
96+
--run "$1" 2>&1
97+
}
98+
runInNixShell "cabal update && mkdir vendored && cd vendored && cabal unpack network-3.1.2.1 && cd network-3.1.2.1 && autoreconf -fi" 2>&1
99+
runInNixShell "./.gitlab/ci.sh" 2>&1
100+
variables:
101+
MACOSX_DEPLOYMENT_TARGET: "10.7"
102+
parallel: *m1_matrix
103+
artifacts:
104+
expire_in: 2 week
105+
paths:
106+
- out
107+
108+
build-x86_64-windows:
109+
extends: .build
110+
tags:
111+
- new-x86_64-windows
112+
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

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

28+
optional-packages: vendored/*/*.cabal
29+
2830
tests: true
2931

3032
package *

0 commit comments

Comments
 (0)