hledger/.github/workflows/ci.yml
2020-03-06 03:30:14 -08:00

184 lines
6.6 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/configuring-and-managing-workflows/caching-and-storing-workflow-data
# 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
# https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners#supported-runners-and-hardware-resources
# https://github.com/actions/setup-haskell
# https://github.com/actions/upload-artifact
# https://sevenzip.osdn.jp/chm/cmdline/commands/index.htm
name: hledger CI
on:
push:
branches: [ master ]
paths:
- 'stack*'
- 'hledger-lib'
- 'hledger'
- 'hledger-ui'
- 'hledger-web'
- '.github/workflows/*'
- '!**.md'
- '!**.1'
- '!**.5'
- '!**.info'
- '!**.txt'
pull_request:
branches: [ master ]
paths:
- 'stack*'
- 'hledger-lib'
- 'hledger'
- 'hledger-ui'
- 'hledger-web'
- '.github/workflows/*'
- '!**.md'
- '!**.1'
- '!**.5'
- '!**.info'
- '!**.txt'
# schedule:
# - cron: "0 23 * * *"
jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
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 dirs
- name: Cache ~/.stack
uses: actions/cache@v1 # https://github.com/marketplace/actions/cache
with:
path: ~/.stack
key: ${{ runner.os }}-stack
#key: ${{ runner.os }}-${{ matrix.resolver }}-stack
- name: Cache ~/.local/bin
uses: actions/cache@v1
with:
path: ~/.local/bin
key: ${{ runner.os }}-local-bin
- name: Cache .stack-work
uses: actions/cache@v1
with:
path: .stack-work
key: ${{ runner.os }}-stack-work
- name: Cache hledger-lib/.stack-work
uses: actions/cache@v1
with:
path: hledger-lib/.stack-work
key: ${{ runner.os }}-hledger-lib-stack-work
- name: Cache hledger/.stack-work
uses: actions/cache@v1
with:
path: hledger/.stack-work
key: ${{ runner.os }}-hledger-stack-work
- name: Cache hledger-ui/.stack-work
uses: actions/cache@v1
with:
path: hledger-ui/.stack-work
key: ${{ runner.os }}-hledger-ui-stack-work
- name: Cache hledger-web/.stack-work
uses: actions/cache@v1
with:
path: hledger-web/.stack-work
key: ${{ runner.os }}-hledger-web-stack-work
# check out the current branch tip
- name: Check out
uses: actions/checkout@v2 # https://github.com/marketplace/actions/checkout
- name: Install stack (ubuntu)
if: matrix.os == 'ubuntu-latest'
# curl -L https://get.haskellstack.org/stable/linux-x86_64.tar.gz | tar xz --wildcards --strip-components=1 -C $INSTALLDIR '*/stack'
# mkdir -p ~/.local/bin
# export PATH=~/.local/bin:$PATH
# if [[ ! -x ~/.local/bin/stack ]]; then curl -L https://www.stackage.org/stack/linux-x86_64 | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack'; chmod a+x ~/.local/bin/stack; fi
run: |
stack --version
# - if [[ ! -x ~/.local/bin/shelltest ]]; then stack install shelltestrunner-1.9; fi
# - shelltest --version
- name: Install stack (mac)
if: matrix.os == 'macos-latest'
# curl --insecure -L https://get.haskellstack.org/stable/osx-x86_64.tar.gz | tar xz --strip-components=1 --include '*/stack' -C $INSTALLDIR
run: |
brew install haskell-stack
stack --version
- name: Install stack (windows)
if: matrix.os == 'windows-latest'
run: |
curl -skL -o stack.zip http://www.stackage.org/stack/windows-x86_64
7z x stack.zip -oC:\Windows stack.exe
stack --version
- name: Install haskell deps
run: |
stack --install-ghc $ARGS test --bench --only-dependencies
# stack --no-terminal --install-ghc $ARGS test --bench --only-dependencies
env:
ARGS: ${{ matrix.plan.resolver }}
# BUILD: ${{ matrix.plan.build }}
- name: Build hledger
run: |
stack $ARGS install --ghc-options=-Werror --test --bench --no-run-benchmarks --haddock --no-haddock-deps
# stack --no-terminal $ARGS test --bench --no-run-benchmarks --haddock --no-haddock-deps
env:
ARGS: ${{ matrix.plan.resolver }}
# BUILD: ${{ matrix.plan.build }}
# run hledger-lib/hledger functional tests, skipping the ones for addons
#- COLUMNS=80 stack exec -- shelltest --execdir -j16 tests -x /bin -x /addons
# - name: Zip exes (windows)
# if: matrix.os == 'windows-latest'
# run: |
# #cd `stack path --local-bin`
# 7z a hledger.zip %HOME%/.local/bin/hledger %HOME%/.local/bin/hledger-web
# - name: Upload zip file (windows)
# if: matrix.os == 'windows-latest'
# uses: actions/upload-artifact@v1
# with:
# name: hledger.zip
# path: hledger.zip