# This file is auto-generated
#
# To regenerate it run
#
#     make github-actions
#
name: Quick jobs
on:
  push:
    branches:
      - master
      - "3.4"
  pull_request:
    branches:
      - master
      - "3.4"
  release:
    types:
      - created

jobs:
  meta:
    name: Meta checks
    runs-on: ubuntu-18.04
    # This job is not run in a container, any recent GHC should be fine
    steps:
      - name: Install GHC
        run: |
          echo "$HOME/.cabal/bin" >> $GITHUB_PATH
          ghcup install ghc --set 8.10.4
      - uses: actions/cache@v1
        with:
          path: ~/.cabal/store
          key: linux-store-meta
      - name: Update Hackage index
        run: cabal v2-update
      - name: Install alex
        run: cabal v2-install alex --constraint='alex ==3.2.6'
      - uses: actions/checkout@v2
      - name: Regenerate files
        run: |
          make lexer
          make gen-extra-source-files
          make spdx
          make templates
          make github-actions
          make cabal-install-cabal
      - name: Check that diff is clean
        run: |
          git status > /dev/null
          git diff-files -p --exit-code
  doctest:
    name: Doctest Cabal
    runs-on: ubuntu-18.04
    steps:
      - name: Set PATH
        run: |
          echo "$HOME/.cabal/bin" >> $GITHUB_PATH
          echo "/opt/cabal/3.2/bin" >> $GITHUB_PATH
          echo "/opt/ghc/8.10.4/bin" >> $GITHUB_PATH
      - name: Install cabal-env
        run: |
          mkdir -p $HOME/.cabal/bin
          curl -sL https://github.com/phadej/cabal-extras/releases/download/preview-20191225/cabal-env-snapshot-20191225-x86_64-linux.xz > cabal-env.xz
          echo "1b567d529c5f627fd8c956e57ae8f0d9f11ee66d6db34b7fb0cb1c370b4edf01  cabal-env.xz" | sha256sum -c -
          xz -d < cabal-env.xz > $HOME/.cabal/bin/cabal-env
          rm -f cabal-env.xz
          chmod a+x $HOME/.cabal/bin/cabal-env
      - uses: actions/cache@v1
        with:
          path: ~/.cabal/store
          key: linux-store-doctest
      - name: Update Hackage index
        run: cabal v2-update
      - name: Install doctest
        run: cabal v2-install doctest
      - name: Install libraries
        run: |
          cabal-env --transitive QuickCheck
          cabal-env array bytestring containers deepseq directory filepath pretty process time binary unix text parsec mtl
          cat $HOME/.ghc/*/environments/default
      - uses: actions/checkout@v2
      - name: Doctest
        run: make doctest
