Reimplement `cabal check` (#8427)
[cabal.git] / .gitlab / ci.sh
blobc856f9f2cb951a5a6db2be0c2c58327327370b20
1 #!/usr/bin/env bash
3 set -Eeuo pipefail
5 source "$CI_PROJECT_DIR/.gitlab/common.sh"
7 export GHCUP_INSTALL_BASE_PREFIX="$CI_PROJECT_DIR/toolchain"
8 export CABAL_DIR="$CI_PROJECT_DIR/cabal"
10 case "$(uname)" in
11 MSYS_*|MINGW*)
12 export CABAL_DIR="$(cygpath -w "$CABAL_DIR")"
13 GHCUP_BINDIR="${GHCUP_INSTALL_BASE_PREFIX}/ghcup/bin"
14 EXE_EXT=".exe"
17 GHCUP_BINDIR="${GHCUP_INSTALL_BASE_PREFIX}/.ghcup/bin"
18 EXE_EXT=""
20 esac
22 mkdir -p "$CABAL_DIR"
23 mkdir -p "$GHCUP_BINDIR"
24 export PATH="$GHCUP_BINDIR:$PATH"
26 export BOOTSTRAP_HASKELL_NONINTERACTIVE=1
27 export BOOTSTRAP_HASKELL_GHC_VERSION=$GHC_VERSION
28 export BOOTSTRAP_HASKELL_CABAL_VERSION=$CABAL_INSTALL_VERSION
29 export BOOTSTRAP_HASKELL_ADJUST_CABAL_CONFIG=yes
30 # We don't use stack, and it isn't available on i386-deb9
31 export BOOTSTRAP_HASKELL_INSTALL_NO_STACK=yes
33 # for some reason the subshell doesn't pick up the arm64 environment on darwin
34 # and starts installing x86_64 GHC
35 case "$(uname -s)" in
36 "Darwin"|"darwin")
37 case "$(/usr/bin/arch)" in
38 aarch64|arm64|armv8l)
39 curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | arch -arm64 /bin/bash
42 curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh
44 esac
47 curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh
49 esac
51 # https://github.com/haskell/cabal/issues/7313#issuecomment-811851884
52 # and
53 # https://github.com/haskellari/lukko/issues/17
55 # $PLATFORM comes from CI.
56 if [ "$(getconf LONG_BIT)" = "32" -o "${PLATFORM:=xxx}" = "x86_64-linux-centos7" ] ; then
57 echo 'constraints: lukko -ofd-locking' >> cabal.project.release.local
60 args=(
61 -w "ghc-$GHC_VERSION"
62 --disable-profiling
63 --enable-executable-stripping
64 --project-file=cabal.project.release
65 ${ADD_CABAL_ARGS}
68 run cabal update hackage.haskell.org,HEAD
69 run cabal v2-build ${args[@]} cabal-install
71 mkdir "$CI_PROJECT_DIR/out"
72 cp "$(cabal list-bin ${args[@]} cabal-install:exe:cabal)" "$CI_PROJECT_DIR/out/cabal$EXE_EXT"
73 cp dist-newstyle/cache/plan.json "$CI_PROJECT_DIR/out/plan.json"
74 cd "$CI_PROJECT_DIR/out/"
76 # create tarball/zip
77 TARBALL_PREFIX="cabal-install-$("$CI_PROJECT_DIR/out/cabal" --numeric-version)"
78 case "${TARBALL_EXT}" in
79 zip)
80 zip "${TARBALL_PREFIX}-${TARBALL_ARCHIVE_SUFFIX}.${TARBALL_EXT}" "cabal${EXE_EXT}" plan.json
82 tar.xz)
83 tar caf "${TARBALL_PREFIX}-${TARBALL_ARCHIVE_SUFFIX}.${TARBALL_EXT}" "cabal${EXE_EXT}" plan.json
86 fail "Unknown TARBALL_EXT: ${TARBALL_EXT}"
88 esac
90 rm cabal plan.json