hledger/.github/workflows/ci.yml
2020-03-06 00:32:12 -08:00

162 lines
5.8 KiB
YAML

# Github Actions config
# Based on https://gist.github.com/mstksg/11f753d891cee5980326a8ea8c865233
# ("Currently not working for cabal-install >= 3")
# Based on https://raw.githubusercontent.com/commercialhaskell/stack/stable/doc/travis-complex.yml
# ref:
# https://help.github.com/en/actions
# https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners#supported-runners-and-hardware-resources
# https://github.com/actions/cache
# https://help.github.com/en/actions/configuring-and-managing-workflows/caching-dependencies-to-speed-up-workflows
# https://github.com/sdras/awesome-actions
# http://www.btellez.com/posts/triggering-github-actions-with-webhooks.html
name: hledger CI
on:
push:
branches: [ master ]
# pull_request:
# branches: [ master ]
# schedule:
# - cron: "0 23 * * *"
jobs:
build:
strategy:
matrix:
# os runners: https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners#supported-runners-and-hardware-resources
os: [ubuntu-latest, macos-latest, windows-latest]
# use this to specify what resolvers and ghc to use
plan:
# - { build: stack, resolver: "--resolver lts-9" } # ghc-8.0.2
# - { build: stack, resolver: "--resolver lts-11" } # ghc-8.2.2
# - { build: stack, resolver: "--resolver lts-12" } # ghc-8.4.4
## - { build: stack, resolver: "--resolver lts-13" } redundant because lts-14 checks ghc-8.6 already
# - { build: stack, resolver: "--resolver lts-14" } # ghc-8.6.5
- { build: stack, resolver: "--resolver lts-15" } # ghc-8.8.2
# - { build: stack, resolver: "--resolver nightly" }
# - { build: stack, resolver: "" }
# - { build: cabal, ghc: 8.0.2, cabal-install: "2.0" } # setup-haskell only supports cabal-install 2.0 and higher
# - { build: cabal, ghc: 8.2.2, cabal-install: "2.0" }
# - { build: cabal, ghc: 8.4.4, cabal-install: "2.2" }
# - { build: cabal, ghc: 8.6.5, cabal-install: "2.4" }
# - { build: cabal, ghc: 8.8.1, cabal-install: "2.4" } # currently not working for >= 3.0
# use this to include any dependencies from OS package managers
include: []
# - os: macos-latest
# brew: anybrewdeps
# - os: ubuntu-latest
# apt-get: happy libblas-dev liblapack-dev
# exclude:
# - os: macos-latest
# plan:
# build: cabal
runs-on: ${{ matrix.os }}
steps:
# cache these directories
- uses: actions/cache@v1
name: Cache ~/.stack
with:
path: ~/.stack
key: ${{ runner.os }}-stack
#key: ${{ runner.os }}-${{ matrix.resolver }}-stack
- uses: actions/cache@v1 # https://github.com/marketplace/actions/cache
name: Cache ~/.local/bin
with:
path: ~/.local/bin
key: ${{ runner.os }}-local-bin
# check out the current branch tip
- uses: actions/checkout@v2 # https://github.com/marketplace/actions/checkout
# install stack
- if: matrix.os == 'ubuntu-latest'
run: |
stack --version
cabal --version
- if: matrix.os == 'macos-latest'
run: |
brew install haskell-stack
stack --version
- if: matrix.os == 'windows-latest'
run: |
curl -skL -ostack.zip http://www.stackage.org/stack/windows-x86_64
7z x stack.zip stack.exe
stack --version
# install cabal
# - name: Setup cabal-install
# uses: actions/setup-haskell@v1
# with:
# ghc-version: ${{ matrix.plan.ghc }}
# cabal-version: ${{ matrix.plan.cabal-install }}
# if: matrix.plan.build == 'cabal'
# - name: Install OS packages
# uses: mstksg/get-package@v1 # https://github.com/marketplace/actions/get-package
# with:
# apt-get: ${{ matrix.apt-get }}
# brew: ${{ matrix.brew }}
- name: Install haskell dependencies
run: |
set -ex
case "$BUILD" in
stack)
stack --no-terminal --install-ghc $ARGS test --bench --only-dependencies
;;
cabal)
cabal --version
cabal update
PACKAGES=$(stack --install-ghc query locals | grep '^ *path' | sed 's@^ *path:@@')
cabal install --only-dependencies --enable-tests --enable-benchmarks --force-reinstalls --ghc-options=-O0 --reorder-goals --max-backjumps=-1 $CABALARGS $PACKAGES
;;
esac
set +ex
env:
ARGS: ${{ matrix.plan.resolver }}
BUILD: ${{ matrix.plan.build }}
- name: Build
run: |
set -ex
case "$BUILD" in
stack)
stack --no-terminal $ARGS test --bench --no-run-benchmarks --haddock --no-haddock-deps
;;
cabal)
PACKAGES=$(stack --install-ghc query locals | grep '^ *path' | sed 's@^ *path:@@')
cabal install --enable-tests --enable-benchmarks --force-reinstalls --ghc-options=-O0 --reorder-goals --max-backjumps=-1 $CABALARGS $PACKAGES
ORIGDIR=$(pwd)
for dir in $PACKAGES
do
cd $dir
cabal check || [ "$CABALVER" == "1.16" ]
cabal sdist
PKGVER=$(cabal info . | awk '{print $2;exit}')
SRC_TGZ=$PKGVER.tar.gz
cd dist
tar zxfv "$SRC_TGZ"
cd "$PKGVER"
cabal configure --enable-tests --ghc-options -O0
cabal build
if [ "$CABALVER" = "1.16" ] || [ "$CABALVER" = "1.18" ]; then
cabal test
else
cabal test --show-details=streaming --log=/dev/stdout
fi
cd $ORIGDIR
done
;;
esac
set +ex
env:
ARGS: ${{ matrix.plan.resolver }}
BUILD: ${{ matrix.plan.build }}