diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..218ed58 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,78 @@ +variables: + GIT_SSL_NO_VERIFY: "1" + + # Commit of ghc/ci-images repository from which to pull Docker images + DOCKER_REV: cefaee3c742af193e0f7783f87edb0d35374515c + +############################################################ +# CI Step +############################################################ + +.debian: + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + tags: + - x86_64-linux + +.darwin: + tags: + - x86_64-darwin + +.test_ghcup_version: + script: + - ./.gitlab/script/ghcup_version.sh + variables: + JSON_VERSION: "0.0.1" + +.test_ghcup_version:linux: + extends: + - .test_ghcup_version + - .debian + before_script: + - ./.gitlab/before_script/linux/install_deps.sh + variables: + OS: "LINUX" + +.test_ghcup_version:darwin: + extends: + - .test_ghcup_version + - .darwin + before_script: + - ./.gitlab/before_script/darwin/install_deps.sh + variables: + OS: "DARWIN" + after_script: + - BUILD_DIR=$CI_PROJECT_DIR + - echo "Cleaning $BUILD_DIR" + - cd $HOME + - rm -Rf "$BUILD_DIR"/* + - exit 0 + + + +######## linux ######## + +test:linux:recommended: + extends: .test_ghcup_version:linux + variables: + GHC_VERSION: "recommended" + +test:linux:latest: + extends: .test_ghcup_version:linux + variables: + GHC_VERSION: "latest" + allow_failure: true + + +######## darwin ######## + +test:mac:recommended: + extends: .test_ghcup_version:darwin + variables: + GHC_VERSION: "recommended" + +test:mac:latest: + extends: .test_ghcup_version:darwin + variables: + GHC_VERSION: "latest" + allow_failure: true + diff --git a/.gitlab/before_script/darwin/install_deps.sh b/.gitlab/before_script/darwin/install_deps.sh new file mode 100755 index 0000000..b6de4fa --- /dev/null +++ b/.gitlab/before_script/darwin/install_deps.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +set -eux + +. "$( cd "$(dirname "$0")" ; pwd -P )/../../ghcup_env" + +curl -sSfL https://gitlab.haskell.org/haskell/ghcup/-/raw/master/ghcup > ./ghcup-legacy +chmod +x ghcup-legacy + +./ghcup-legacy install ${GHC_VERSION} +./ghcup-legacy set ${GHC_VERSION} +./ghcup-legacy install-cabal + +exit 0 diff --git a/.gitlab/before_script/linux/install_deps.sh b/.gitlab/before_script/linux/install_deps.sh new file mode 100755 index 0000000..25a8c91 --- /dev/null +++ b/.gitlab/before_script/linux/install_deps.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +set -eux + +sudo apt-get update -y +sudo apt-get install -y libnuma-dev zlib1g-dev libgmp-dev libgmp10 libssl-dev liblzma-dev + +. "$( cd "$(dirname "$0")" ; pwd -P )/../../ghcup_env" + +curl -sSfL https://gitlab.haskell.org/haskell/ghcup/-/raw/master/ghcup > ./ghcup-legacy +chmod +x ghcup-legacy + +./ghcup-legacy install ${GHC_VERSION} +./ghcup-legacy set ${GHC_VERSION} +./ghcup-legacy install-cabal + diff --git a/.gitlab/ghcup_env b/.gitlab/ghcup_env new file mode 100644 index 0000000..9a5ba38 --- /dev/null +++ b/.gitlab/ghcup_env @@ -0,0 +1,3 @@ +export GHCUP_INSTALL_BASE_PREFIX="$CI_PROJECT_DIR" +export PATH="$CI_PROJECT_DIR/.ghcup/bin:$CI_PROJECT_DIR/.local/bin:$PATH" + diff --git a/.gitlab/script/ghcup_version.sh b/.gitlab/script/ghcup_version.sh new file mode 100755 index 0000000..68ad54c --- /dev/null +++ b/.gitlab/script/ghcup_version.sh @@ -0,0 +1,58 @@ +#!/bin/sh + +set -eux + +. "$( cd "$(dirname "$0")" ; pwd -P )/../ghcup_env" + +mkdir -p "$CI_PROJECT_DIR"/.local/bin + +ecabal() { + cabal --store-dir="$(pwd)"/.store "$@" +} + + +# build +ecabal update + +if [ "${OS}" = "DARWIN" ] ; then + ecabal build -fcurl +else + ecabal build +fi + +cp "$(ecabal new-exec --enable-tests --verbose=0 --offline sh -- -c 'command -v ghcup')" . +cp "$(ecabal new-exec --enable-tests --verbose=0 --offline sh -- -c 'command -v ghcup-gen')" . + + +# testing + +cp ./ghcup "$CI_PROJECT_DIR"/.local/bin/ghcup +cp ./ghcup-gen "$CI_PROJECT_DIR"/.local/bin/ghcup-gen +rm -rf "${GHCUP_INSTALL_BASE_PREFIX}"/.ghcup + +ghcup-gen check -f ghcup-${JSON_VERSION}.json + +ghcup numeric-version + +ghcup -v -c install ${GHC_VERSION} +ghcup -v -c set ${GHC_VERSION} +ghcup -v -c install-cabal + +cabal --version + +ghcup -v -c debug-info + +ghcup -v -c list +ghcup -v -c list -t ghc +ghcup -v -c list -t cabal + +ghc --version +ghci --version +ghc-$(ghc --numeric-version) --version +ghci-$(ghc --numeric-version) --version + +ghcup -v upgrade +ghcup -v upgrade -f + +ghcup -v rm $(ghc --numeric-version) +