Skip to content

Commit

Permalink
Use GHCUP to install GHC
Browse files Browse the repository at this point in the history
  • Loading branch information
harendra-kumar committed Dec 15, 2023
1 parent cba7192 commit 6d6e19a
Show file tree
Hide file tree
Showing 6 changed files with 258 additions and 154 deletions.
155 changes: 71 additions & 84 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ env: &env
# Common options
# ------------------------------------------------------------------------
# GHC_OPTIONS: "-Werror"
GHCUPVER: 0.1.20.0
CABAL_REINIT_CONFIG: "y"
LC_ALL: "C.UTF-8"

Expand All @@ -36,7 +37,7 @@ env: &env
# version.
#STACKVER: "1.6.5"
#STACK_UPGRADE: "y"
#RESOLVER: "lts-12"
#RESOLVER: "lts-21"
STACK_YAML: "stack.yaml"

# ------------------------------------------------------------------------
Expand All @@ -62,45 +63,66 @@ env: &env
# If you have not committed packcheck.sh in your repo at PACKCHECK
# then it is automatically pulled from this URL.
PACKCHECK_GITHUB_URL: "https://raw.githubusercontent.com/composewell/packcheck"
PACKCHECK_GITHUB_COMMIT: "v0.6.0"
PACKCHECK_GITHUB_COMMIT: "3db46664f5eeadcd6fbe18b0ff6e9a31c41e4fbe"

# ubuntu seems to have better support than debian on CI systems
docker:
- image: debian:buster
- image: ubuntu:latest

#-----------------------------------------------------------------------------
# Common utility stuff, not to be modified usually
#-----------------------------------------------------------------------------

preinstall: &preinstall
run: |
# Check for PACKCHECK_GITHUB_COMMIT
if test -z "$PACKCHECK_GITHUB_COMMIT"
then
die "PACKCHECK_GITHUB_COMMIT is not specified."
fi
apt-get update
# required for https/cache save and restore
apt-get install -y ca-certificates
# NOTE: depends on specific debian version in the deb line below
# For ghc and cabal-install packages from haskell.org
# gnupg is required for apt-key to work
apt-get install -y gnupg
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys BA3CBA3FFE22B574
echo "deb http://downloads.haskell.org/debian buster main" >> /etc/apt/sources.list
apt-get update
# required for packcheck
apt-get install -y curl
#apt-get install -y gnupg
#apt-key adv --keyserver keyserver.ubuntu.com --recv-keys BA3CBA3FFE22B574
#echo "deb http://downloads.haskell.org/debian buster main" >> /etc/apt/sources.list
#apt-get update
# required for outbound https for stack and for stack setup
apt-get install -y netbase xz-utils make
apt-get install -y zlib1g-dev
# For ghcup to install ghc
if test -n "$GHCUPVER"
then
apt-get install -y gcc
apt-get install -y g++
fi
# libgmp required by ghc for linking
apt-get install -y libgmp-dev
apt-get install -y libtinfo-dev
# Required by cabal when git URL is specified in project file
apt-get install -y git
# Required for and by packcheck
apt-get install -y curl
# Get packcheck if needed
CURL=$(which curl)
PACKCHECK_URL=${PACKCHECK_GITHUB_URL}/${PACKCHECK_GITHUB_COMMIT}/packcheck.sh
if test ! -e "$PACKCHECK"; then $CURL -sL -o "$PACKCHECK" $PACKCHECK_URL; fi;
chmod +x $PACKCHECK
if test ! -e "$PACKCHECK"
then
if test -z "$PACKCHECK_GITHUB_COMMIT"
then
die "PACKCHECK_GITHUB_COMMIT is not specified."
fi
CURL=$(which curl)
PACKCHECK_URL=${PACKCHECK_GITHUB_URL}/${PACKCHECK_GITHUB_COMMIT}/packcheck.sh
$CURL -sL -o "$PACKCHECK" $PACKCHECK_URL
chmod +x $PACKCHECK
elif test ! -x "$PACKCHECK"
then
chmod +x $PACKCHECK
fi
restore: &restore
# Needs to happen after installing ca-certificates
Expand All @@ -115,121 +137,86 @@ save: &save
- ~/.ghc
- ~/.local
- ~/.stack
- ~/.ghcup

#-----------------------------------------------------------------------------
# Build matrix
#-----------------------------------------------------------------------------

jobs:
cabal-ghc-8-10-1:
cabal-ghc-9-8-1:
<<: *env
steps:
- checkout
- *preinstall
- *restore
- run: |
apt-get install -y ghc-8.10.1
apt-get install -y cabal-install-3.2
bash -c "$PACKCHECK cabal-v2"
- *save
cabal-ghc-8-8-3:
<<: *env
steps:
- checkout
- *preinstall
- *restore
- run: |
apt-get install -y ghc-8.8.3
apt-get install -y cabal-install-3.2
bash -c "$PACKCHECK cabal-v2"
bash -c "$PACKCHECK cabal GHCVER=9.8.1"
- *save
cabal-ghc-8-6-5:
cabal-ghc-9-6-3:
<<: *env
steps:
- checkout
- *preinstall
- *restore
- *preinstall
- run: |
apt-get install -y ghc-8.6.5
apt-get install -y cabal-install-3.2
bash -c "$PACKCHECK cabal-v2"
bash -c "$PACKCHECK cabal GHCVER=9.6.3"
- *save
cabal-ghc-8-4-4:
cabal-ghc-9-4-8:
<<: *env
steps:
- checkout
- *preinstall
- *restore
- *preinstall
- run: |
apt-get install -y ghc-8.4.4
apt-get install -y cabal-install-3.2
bash -c "$PACKCHECK cabal-v2"
bash -c "$PACKCHECK cabal GHCVER=9.4.8"
- *save
cabal-ghc-7-10-3:
cabal-ghc-9-2-8:
<<: *env
steps:
- checkout
- *preinstall
- *restore
- *preinstall
- run: |
apt-get install -y ghc-7.10.3
apt-get install -y cabal-install-3.2
bash -c "$PACKCHECK cabal-v2"
bash -c "$PACKCHECK cabal GHCVER=9.2.8"
- *save
stack-ghc-8-8:
cabal-ghc-9-0-1:
<<: *env
steps:
- checkout
- *preinstall
- *restore
- *preinstall
- run: |
apt-get install -y ghc-8.8.3
apt-get install -y cabal-install-3.2
bash -c "$PACKCHECK stack RESOLVER=lts-15"
bash -c "$PACKCHECK cabal GHCVER=9.0.1"
- *save
stack-ghc-8-4:
cabal-ghc-8-10-7:
<<: *env
steps:
- checkout
- *preinstall
- *restore
- *preinstall
- run: |
apt-get install -y ghc-8.4.4
apt-get install -y cabal-install-3.2
bash -c "$PACKCHECK stack RESOLVER=lts-12"
bash -c "$PACKCHECK cabal-v2 GHCVER=8.10.7"
- *save
coveralls-ghc-8-8-3:
stack-lts-21:
<<: *env
steps:
- checkout
- *preinstall
- *restore
- run:
environment:
CABAL_PROJECT: "cabal.project.coveralls"
# Please change the repo token to your repo token
COVERALLS_OPTIONS: "--repo-token=YvxdfMiOmfq0limz6nLd4DxiC1RBQJ4dA --coverage-mode=StrictlyFullLines --exclude-dir=test test"
command: |
apt-get install -y ghc-8.8.3
apt-get install -y cabal-install-3.2
# required by hpc-coveralls
apt-get install -y libcurl4-gnutls-dev
apt-get install -y git
bash -c "$PACKCHECK cabal-v2"
- *preinstall
- run: |
bash -c "$PACKCHECK stack RESOLVER=lts-21"
- *save

workflows:
version: 2
build:
jobs:
# Uncomment the configs that you want to enable
- cabal-ghc-8-10-1
#- cabal-ghc-8-8-3
#- cabal-ghc-8-6-5
#- cabal-ghc-8-4-4
#- cabal-ghc-7-10-3
#- stack-ghc-8-8
#- stack-ghc-8-4
# IMPORTANT: Please change the --repo-token to your repo token
# in COVERALLS_OPTIONS above before enabling this.
#- coveralls-ghc-8-8-3
- cabal-ghc-9-8-1
- cabal-ghc-9-6-3
- cabal-ghc-9-4-8
- cabal-ghc-9-2-8
- cabal-ghc-9-0-1
- cabal-ghc-8-10-7
- stack-lts-21
68 changes: 39 additions & 29 deletions .github/workflows/packcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ jobs:
# ------------------------------------------------------------------------
# Selecting tool versions
# ------------------------------------------------------------------------
GHCUPVER: 0.1.20.0
GHCVER: ${{ matrix.ghc_version }}
# RESOLVER: ${{ matrix.stack_resolver }}

Expand Down Expand Up @@ -84,37 +85,42 @@ jobs:
# If you have not committed packcheck.sh in your repo at PACKCHECK
# then it is automatically pulled from this URL.
PACKCHECK_GITHUB_URL: "https://raw.githubusercontent.com/composewell/packcheck"
PACKCHECK_GITHUB_COMMIT: "v0.6.0"
PACKCHECK_GITHUB_COMMIT: "3db46664f5eeadcd6fbe18b0ff6e9a31c41e4fbe"

# ------------------------------------------------------------------------
# Final build variables
# ------------------------------------------------------------------------
PACKCHECK_COMMAND: ${{ matrix.command }} ${{ matrix.pack_options }}

# ubuntu seems to have better support than debian on CI systems
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
# The reason we have name here is to force an additional config instead
# of adding to an existing config while adding additional configs.
# The name of the CI is built using the name and other info from CI,
# therefore, the "name" field is same for all tests here.
#
# The reason we have an explicit "name" field here is to force
# an additional config instead of adding to an existing config
# while adding additional configs.
# Look at <https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstrategymatrix>
# for more info about adding matrix elements.
# Adding any element to the list will increase the number of matrix
# elemets proportional to the cross product.
# elements proportional to the cross product.
include:
- name: ci
command: cabal-v2
command: cabal
runner: ubuntu-latest
ghc_version: 8.10.3
ghc_version: 9.8.1

# - name: ci
# command: stack
# runner: ubuntu-latest
- name: ci
command: stack
runner: ubuntu-latest

# - name: ci
# ghc_version: 8.8.3
# command: cabal-v2
# runner: macos-latest
- name: ci
ghc_version: 9.8.1
command: cabal
runner: macos-latest

- name: ci
command: hlint
Expand All @@ -126,13 +132,13 @@ jobs:
steps:
- uses: actions/checkout@v2

- uses: haskell/actions/setup@v1
if: ${{ matrix.name != 'hlint' }}
with:
ghc-version: ${{ matrix.ghc_version }}
enable-stack: true
stack-version: 'latest'
cabal-version: 'latest'
#- uses: haskell/actions/setup@v1
# if: ${{ matrix.name != 'hlint' }}
# with:
# ghc-version: ${{ matrix.ghc_version }}
# enable-stack: true
# stack-version: 'latest'
# cabal-version: 'latest'

- uses: actions/cache@v2
name: Cache common directories
Expand All @@ -142,22 +148,26 @@ jobs:
~/.ghc
~/.local
~/.stack
~/.ghcup
key: ${{ matrix.command }}-${{ matrix.ghc_version }}-${{ matrix.runner }}

- name: Download packcheck
run: |
# Check for PACKCHECK_GITHUB_COMMIT
if test -z "$PACKCHECK_GITHUB_COMMIT"
if test ! -e "$PACKCHECK"
then
if test -z "$PACKCHECK_GITHUB_COMMIT"
then
die "PACKCHECK_GITHUB_COMMIT is not specified."
fi
CURL=$(which curl)
PACKCHECK_URL=${PACKCHECK_GITHUB_URL}/${PACKCHECK_GITHUB_COMMIT}/packcheck.sh
$CURL -sL -o "$PACKCHECK" $PACKCHECK_URL
chmod +x $PACKCHECK
elif test ! -x "$PACKCHECK"
then
die "PACKCHECK_GITHUB_COMMIT is not specified."
chmod +x $PACKCHECK
fi
# Get packcheck if needed
CURL=$(which curl)
PACKCHECK_URL=${PACKCHECK_GITHUB_URL}/${PACKCHECK_GITHUB_COMMIT}/packcheck.sh
if test ! -e "$PACKCHECK"; then $CURL -sL -o "$PACKCHECK" $PACKCHECK_URL; fi;
chmod +x $PACKCHECK
- name: Run packcheck
run: |
bash -c "$PACKCHECK $PACKCHECK_COMMAND"
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ help | --help | -h : show this help message
Selecting tool versions
--------------------------------------------------
ENABLE_GHCJS : [y] Use GHCJS instead of GHC to build
GHCUPVER : [a.b.c.d] GHCUP version
GHCVER : [a.b.c] GHC version prefix (may not be enforced when using stack)
CABALVER : [a.b.c.d] Cabal version (prefix) to use
RESOLVER : Stack resolver to use for stack builds or cabal builds using stack
Expand Down
Loading

0 comments on commit 6d6e19a

Please sign in to comment.