packages feed

streamly-0.8.0: .github/workflows/haskell.yml

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 }}
      GHCVER: ${{ matrix.ghc_version }}
      DISABLE_DOCS: ${{ matrix.disable_docs }}
      DISABLE_TEST: ${{ matrix.disable_test }}
      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_LOCAL_PATH: "./packcheck.sh"
      PACKCHECK_GITHUB_URL: "https://raw.githubusercontent.com/composewell/packcheck"
      PACKCHECK_GITHUB_COMMIT: "35efa99b2082d13722b8a0183ac6455df98e91b9"

      # Pull token from "secrets" setting of the github repo
      COVERALLS_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
      COVERAGE: ${{ matrix.coverage }}

    runs-on: ${{ matrix.runner }}
    strategy:
      fail-fast: false
      matrix:
        name:
          - 9.0.1
          - 8.10.4+stack
          - 8.10.4+macOS
          - 8.10.4+linux+coverage+cabal
          - 8.8.4
          - 8.8.4+inspection+fusion-plugin+Werror
          - 8.6.5+fusion-plugin
          - 8.6.5+streamk
          - 8.4.4+debug
        cabal_version: ["3.4"]
        include:
          - name: 9.0.1
            ghc_version: 9.0.1
            build: cabal-v2
            cabal_build_options: "--allow-newer=hsc2hs"
            disable_sdist_build: "y"
            runner: ubuntu-latest
          - name: 8.10.4+stack
            build: stack
            resolver: lts-18.0
            stack_yaml: stack.yaml
            sdist_options: "--ignore-check"
            stack_build_options: "--flag streamly-benchmarks:-opt"
            runner: ubuntu-latest
          - name: 8.10.4+macOS
            ghc_version: 8.10.4
            build: cabal-v2
            disable_sdist_build: "y"
            runner: macos-latest
          - name: 8.10.4+linux+coverage+cabal
            ghc_version: 8.10.4
            coverage: "y"
            runner: ubuntu-latest
          - name: 8.8.4+inspection+fusion-plugin+Werror
            ghc_version: 8.8.4
            build: cabal-v2
            cabal_project: cabal.project.Werror
            cabal_build_options: "--flag fusion-plugin --flag inspection"
            runner: ubuntu-latest
          - name: 8.8.4
            ghc_version: 8.8.4
            build: cabal
            cabal_project: cabal.project
            cabal_build_options: "--flag -opt"
            runner: ubuntu-latest
          - name: 8.6.5+streamk
            ghc_version: 8.6.5
            build: cabal-v2
            cabal_project: cabal.project
            cabal_build_options: "--flag streamk --flag -opt"
            runner: ubuntu-latest
          - name: 8.6.5+fusion-plugin
            ghc_version: 8.6.5
            build: cabal-v2
            cabal_project: cabal.project
            cabal_build_options: "--flag fusion-plugin"
            # haddock generation does not work with 8.6.5+fusion-plugin
            disable_docs: "y"
            runner: ubuntu-latest
          - name: 8.4.4+debug
            ghc_version: 8.4.4
            build: cabal-v2
            cabal_project: cabal.project
            cabal_build_options: "--flag debug --flag -opt"
            runner: ubuntu-latest

    steps:
    - uses: actions/checkout@v2

    - uses: haskell/actions/setup@v1
      with:
        ghc-version: ${{ matrix.ghc_version }}
        cabal-version: ${{ matrix.cabal_version }}

    - uses: actions/cache@v1
      name: Cache ~/.cabal
      with:
        path: ~/.cabal
        # Bump the key version to clear the cache
        key: ${{ runner.os }}-${{ matrix.ghc_version }}-cabal-v1

    - name: Download packcheck
      run: |
        # Get packcheck if needed
        CURL=$(which curl)
        PACKCHECK_URL=${PACKCHECK_GITHUB_URL}/${PACKCHECK_GITHUB_COMMIT}/packcheck.sh
        if test ! -e "$PACKCHECK_LOCAL_PATH"; then $CURL -sL -o "$PACKCHECK_LOCAL_PATH" $PACKCHECK_URL; fi;
        chmod +x $PACKCHECK_LOCAL_PATH

    - name: Run tests
      run: |
        if test -z "$COVERAGE"
        then
          export TOOLS_DIR=/opt
          # /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
          bash -c "$PACKCHECK_LOCAL_PATH $BUILD"
        else
          # 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
          hpc-coveralls --repo-token="$COVERALLS_TOKEN" --coverage-mode=StrictlyFullLines
        fi