From a52aff859cebb1d77b86dc5dd743f7566bd53b9c Mon Sep 17 00:00:00 2001
From: Matthew Pickering <matthewtpickering@gmail.com>
Date: Mon, 13 Mar 2023 14:25:05 +0000
Subject: [PATCH] Add CI

Currently tests the build on ghc-9.2.5, ghc-9.4.4 and ghc-9.6.1.
---
 .gitlab-ci.yml | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++
 .gitlab/ci.sh  | 23 ++++++++++++++++++++
 2 files changed, 82 insertions(+)
 create mode 100644 .gitlab-ci.yml
 create mode 100755 .gitlab/ci.sh

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644
index 0000000..74c4004
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,59 @@
+variables:
+  GIT_SSL_NO_VERIFY: "1"
+
+  # Commit of ghc/ci-images repository from which to pull Docker images
+  DOCKER_REV: 572353e0644044fe3a5465bba4342a9a0b0eb60e
+
+  # Sequential version number of all cached things.
+  # Bump to invalidate GitLab CI cache.
+  CACHE_REV: 10
+
+  # Disable shallow clones; they break our linting rules
+  GIT_DEPTH: 0
+
+  # Always start with a fresh clone to avoid non-hermetic builds
+  GIT_STRATEGY: clone
+
+default:
+  interruptible: true
+
+stages:
+  - build
+
+workflow:
+  # N.B. Don't run on wip/ branches, instead on run on merge requests.
+  rules:
+    - if: $CI_MERGE_REQUEST_ID
+    - if: $CI_COMMIT_TAG
+    - if: '$CI_COMMIT_BRANCH == "master"'
+    - if: '$CI_COMMIT_BRANCH =~ /ghc-[0-9]+\.[0-9]+/'
+    - if: '$CI_PIPELINE_SOURCE == "web"'
+
+.version_matrix : &version_matrix
+  matrix:
+    - VERSION: 9.2.5
+    - VERSION: 9.4.4
+    - VERSION: 9.6.1
+
+build-linux:
+  tags:
+    - x86_64-linux
+  parallel: *version_matrix
+  before_script:
+    - sudo chown ghc:ghc -R .
+  stage: build
+  image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10:$DOCKER_REV"
+  needs: []
+  dependencies: []
+  script:
+    - .gitlab/ci.sh
+
+build-windows:
+  tags:
+    - new-x86_64-windows
+  parallel: *version_matrix
+  needs: []
+  dependencies: []
+  stage: build
+  script:
+    - bash .gitlab/ci.sh
diff --git a/.gitlab/ci.sh b/.gitlab/ci.sh
new file mode 100755
index 0000000..6988357
--- /dev/null
+++ b/.gitlab/ci.sh
@@ -0,0 +1,23 @@
+#!/usr/bin/env bash
+set -x
+set -eo pipefail
+
+runner_temp=$(mktemp -d)
+
+export GHCUP_INSTALL_BASE_PREFIX=$runner_temp/foobarbaz
+export BOOTSTRAP_HASKELL_NONINTERACTIVE=1
+export BOOTSTRAP_HASKELL_MINIMAL=1
+export BOOTSTRAP_HASKELL_ADJUST_BASHRC=1
+
+curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh
+
+source $GHCUP_INSTALL_BASE_PREFIX/.ghcup/env || source ~/.bashrc
+
+ghcup --version
+which ghcup | grep foobarbaz
+
+ghcup install ghc --set $VERSION
+ghcup install cabal
+
+cabal update
+cabal build
-- 
GitLab