actions / setup-haskell

Set up your GitHub Actions workflow with a specific version of Haskell (GHC and Cabal)
MIT License
71 stars 30 forks source link

include a more fully featured example template? (heres mine!) #52

Open cartazio opened 4 years ago

cartazio commented 4 years ago

i think this might be a helpful template for folks

on: [push, pull_request]
name: build
# adjust THISPACKAGE to be your package name and then have fun
env:
      THISPACKAGE: ralist
      CONFIG: --enable-tests --enable-benchmarks
defaults:
  run:
    shell: bash
jobs:
  build:
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false # windows fails bench marking so i need to enable this for now
      matrix:
        ghc:  ['7.10.3','8.0.2','8.2.2','8.4.4','8.6.5', '8.8.3','8.10.2','latest'] # ['7.0.4','7.2.2','7.4.2','7.6.3','7.8.4',
        cabal: ['3.2.0.0'] # ,'latest'
        os: [ubuntu-latest] #, macOS-latest, windows-latest]
        include:
          - os: macOS-latest
            ghc: latest
            cabal: latest
          - os: ubuntu-latest
            ghc: latest
            cabal: latest
          - os: windows-latest
            ghc: '8.10.2.2'
            cabal: '3.2.0.0'
            # 8.10.2.2 is a bug fix for a bad windows packaging
            # i hope that actions/setup-haskell upstream does a fix to ghc latest to point to this
    name: GHC${{ matrix.ghc }},cabal${{matrix.cabal}},${{matrix.os}}
    # double curly brace is a javascript splice or something??
    steps:
      - uses: actions/checkout@v2
      - name: Setup Haskell
        # uses: actions/setup-haskell@v1.1.4 # the .3 is a bug fix? as is .4
        # the v1 tag tracks the most recent release for the setup-haskell plugin,
        # less ci bump exhaustion this way
        uses: actions/setup-haskell@v1 # had to bump to .3 then .4, i'm tired :). I'd rather track close, but eh
        with:
          ghc-version: ${{ matrix.ghc }}
          cabal-version: ${{ matrix.cabal }}
      - run: cabal update
      - run: cabal clean
      - run: cabal configure $CONFIG
      - run: cabal freeze $CONFIG
      - uses: actions/cache@v2
        name: windows caching
        with:
          path: |
            c:\sr
            dist-newstyle
          key: ${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze') }}
          # restore keys is a fall back when the freeze plan is different
          restore-keys: |
            ${{ runner.os }}-${{ matrix.ghc }}-
        if:  matrix.os == 'windows-latest'
      - uses: actions/cache@v2
        name: ubuntu-linux and osx caching
        with:
          path: |
            ~/.cabal/store
            dist-newstyle
          key: ${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze') }}
          # restore keys is a fall back when the freeze plan is different
          restore-keys: |
            ${{ runner.os }}-${{ matrix.ghc }}-
        if:  matrix.os != 'windows-latest'
      - run: cabal build  --only-dependencies
      - run: cabal build
      - run: cabal test
      - run: cabal bench
      - run: cabal check
      - run: cabal sdist -o `pwd`
      - run: cabal v1-install ${THISPACKAGE}*.tar.gz