streamly/.github/workflows/haskell.yml
2024-04-30 00:22:45 +05:30

261 lines
9.4 KiB
YAML

name: Haskell CI
on:
push:
branches:
- master
pull_request:
jobs:
build:
name: GHC ${{matrix.name}}
env:
# packcheck environment variables
LC_ALL: C.UTF-8
BUILD: ${{ matrix.build }}
# For updating see: https://downloads.haskell.org/~ghcup/
GHCUP_VERSION: 0.1.20.0
DOCSPEC_URL: https://github.com/phadej/cabal-extras/releases/download/cabal-docspec-0.0.0.20210111/cabal-docspec-0.0.0.20210111.xz
DOCSPEC_OPTIONS: "--timeout 60 --check-properties --property-variables xs"
GHCUP_GHC_OPTIONS: ${{ matrix.ghcup_ghc_options }}
GHCVER: ${{ matrix.ghc_version }}
CABALVER: ${{ matrix.cabal_version }}
DISABLE_DOCS: ${{ matrix.disable_docs }}
ENABLE_DOCSPEC: ${{ matrix.enable_docspec }}
DISABLE_TEST: ${{ matrix.disable_test }}
DISABLE_BENCH: ${{ matrix.disable_bench }}
DISABLE_DIST_CHECKS: ${{ matrix.disable_dist_checks }}
SDIST_OPTIONS: ${{ matrix.sdist_options }}
DISABLE_SDIST_BUILD: ${{ matrix.disable_sdist_build }}
# Cabal options
CABAL_REINIT_CONFIG: y
# Github has machines with 2 CPUS and 6GB memory so the cabal jobs
# default (ncpus) is good, this can be checked from the packcheck
# output in case it changes.
CABAL_BUILD_OPTIONS: ${{ matrix.cabal_build_options }} --flag limit-build-mem
CABAL_BUILD_TARGETS: ${{ matrix.cabal_build_targets }}
CABAL_PROJECT: ${{ matrix.cabal_project }}
CABAL_CHECK_RELAX: y
# Stack options
STACK_UPGRADE: "y"
RESOLVER: ${{ matrix.resolver }}
STACK_YAML: ${{ matrix.stack_yaml }}
STACK_BUILD_OPTIONS: ${{ matrix.stack_build_options }}
# packcheck location and revision
PACKCHECK: "./packcheck.sh"
PACKCHECK_GITHUB_URL: "https://raw.githubusercontent.com/composewell/packcheck"
PACKCHECK_GITHUB_COMMIT: "101c73b53473ddfb763d65058b80123991cfeb4f"
# Pull token from "secrets" setting of the github repo
COVERALLS_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
COVERAGE: ${{ matrix.coverage }}
# hlint
HLINT_VERSION: 3.6.1
HLINT_OPTIONS: "lint"
HLINT_TARGETS: "core/src src test benchmark"
# Subdir
SUBDIR: ${{ matrix.subdir }}
runs-on: ${{ matrix.runner }}
continue-on-error: ${{ matrix.ignore_error }}
strategy:
fail-fast: true
matrix:
# The order is important to optimize fail-fast.
name:
- 9.8.1-Werror
# - 9.8.1-docspec
# - 8.10.7-coverage
# Note: if cabal.project is not specified benchmarks and tests won't
# run. But we need at least one test where we test without
# cabal.project because that is how hackage would build it.
include:
- name: head
ghc_version: head
# The URL may change, to find a working URL go to https://gitlab.haskell.org/ghc/ghc/-/jobs/
# Find a debian10/11/12 job, click on a passed/failed status, at the
# end of the output you will find the tar.xz name, put that tar
# name after "raw/", and put the job name after "job=".
# Also see https://github.com/mpickering/ghc-artefact-nix/blob/master/gitlab-artifact.nix
#
# May also use ghcup for installing ghc head version, use the
# version "LatestNightly", and the following config:
# ghcup config add-release-channel https://ghc.gitlab.haskell.org/ghcup-metadata/ghcup-nightlies-0.0.7.yaml
ghcup_ghc_options: "-u https://gitlab.haskell.org/ghc/ghc/-/jobs/artifacts/master/raw/ghc-x86_64-linux-deb10-int_native-validate.tar.xz?job=x86_64-linux-deb10-int_native-validate"
runner: ubuntu-latest
build: cabal
cabal_version: 3.10.2.0
cabal_project: cabal.project.ghc-head
disable_sdist_build: "y"
ignore_error: true
# Note: use linux for warning build for convenient dev testing
- name: 9.8.1-Werror
ghc_version: 9.8.1
runner: ubuntu-latest
build: cabal
cabal_version: 3.10.1.0
disable_sdist_build: "y"
cabal_project: cabal.project.Werror
ignore_error: false
#- name: 9.8.1-docspec
# ghc_version: 9.8.1
# runner: ubuntu-latest
# build: cabal
# cabal_version: 3.10.1.0
# cabal_project: cabal.project.doctest
# disable_test: "y"
# disable_bench: "y"
# disable_docs: "y"
# enable_docspec: "y"
# disable_sdist_build: "y"
# ignore_error: false
- name: 9.8.1-fusion-inspection
ghc_version: 9.8.1
runner: ubuntu-latest
build: cabal
cabal_version: 3.10.1.0
disable_sdist_build: "y"
cabal_project: cabal.project
cabal_build_options: "--flag fusion-plugin --flag inspection"
ignore_error: false
- name: 9.6.3-macos
ghc_version: 9.6.3
runner: macos-latest
build: cabal
cabal_version: 3.10.1.0
disable_sdist_build: "y"
cabal_project: cabal.project
ignore_error: false
- name: 9.4.7
ghc_version: 9.4.7
runner: ubuntu-latest
build: cabal
cabal_version: 3.8.1.0
disable_sdist_build: "y"
cabal_project: cabal.project
ignore_error: false
- name: 9.2.8
ghc_version: 9.2.8
runner: ubuntu-latest
build: cabal
cabal_project: cabal.project
cabal_version: 3.6.2.0
disable_sdist_build: "y"
ignore_error: false
- name: 9.0.2-streamly-sdist
ghc_version: 9.0.2
runner: ubuntu-latest
build: cabal
cabal_version: 3.6.2.0
cabal_project: cabal.project.streamly
ignore_error: true
- name: 9.0.2-streamly-core-sdist
ghc_version: 9.0.2
runner: ubuntu-latest
build: cabal
cabal_version: 3.6.2.0
subdir: core
ignore_error: false
- name: 8.10.7-streamly-sdist-stack
runner: ubuntu-latest
build: stack
resolver: lts-20.13
stack_yaml: stack.yaml
sdist_options: "--ignore-check"
stack_build_options: "--flag streamly-benchmarks:-opt"
cabal_version: 3.6.2.0
ignore_error: false
# - name: 8.10.7-coverage
# ghc_version: 8.10.7
# runner: ubuntu-latest
# coverage: "y"
# cabal_version: 3.6.2.0
# ignore_error: false
- name: 8.8.4
ghc_version: 8.8.4
runner: ubuntu-latest
build: cabal
cabal_version: 3.6.2.0
cabal_project: cabal.project
disable_sdist_build: "y"
disable_docs: "y"
ignore_error: false
- name: 8.6.5-debug-unoptimized
ghc_version: 8.6.5
runner: ubuntu-latest
build: cabal
cabal_version: 3.6.2.0
cabal_project: cabal.project
cabal_build_options: "--flag debug --flag -opt"
disable_sdist_build: "y"
disable_docs: "y"
ignore_error: false
# - name: hlint
# build: hlint
# runner: ubuntu-latest
# ignore_error: true
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v1
name: Cache common directories
with:
path: |
~/.local
~/.cabal
~/.stack
~/.ghcup
# Bump the key version to clear the cache
key: ${{ runner.os }}-${{ matrix.ghc_version }}-cabal-v2
- name: Download packcheck
run: |
if test ! -e "$PACKCHECK"
then
if test -z "$PACKCHECK_GITHUB_COMMIT"
then
die "PACKCHECK_GITHUB_COMMIT is not specified."
fi
PACKCHECK_URL=${PACKCHECK_GITHUB_URL}/${PACKCHECK_GITHUB_COMMIT}/packcheck.sh
curl --fail -sL -o "$PACKCHECK" $PACKCHECK_URL || exit 1
chmod +x $PACKCHECK
elif test ! -x "$PACKCHECK"
then
chmod +x $PACKCHECK
fi
- name: Run tests
run: |
if test -n "$COVERAGE"
then
# Run tests with coverage
cabal update
# Build hpc-coveralls if needed
sudo apt-get install -y libcurl4-gnutls-dev
export PATH=$HOME/.cabal/bin:$PATH
which hpc-coveralls 2>/dev/null || cabal install --project-file cabal.project.hpc-coveralls hpc-coveralls
# Run tests and upload results to coveralls.io
bin/test.sh --coverage --raw
# XXX Uncomment this and fix it properly later
# hpc-coveralls --repo-token="$COVERALLS_TOKEN" --coverage-mode=StrictlyFullLines
else
# /usr/local/opt/curl/bin for macOS
export PATH=$HOME/.local/bin:$HOME/.ghcup/bin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/opt/curl/bin
if test -n "$SUBDIR"
then
mv "$PACKCHECK" "$SUBDIR/packcheck.sh"
# This is required as dist-newstyle will be created on the top level
# directory as it is considered the working dir.
rm cabal.project
cd "$SUBDIR"
fi
bash -c "$PACKCHECK $BUILD"
fi