# This file is auto-generated
#
# To regenerate it run
#
#     make github-actions
#
name: Quick jobs
on:
  push:
    branches:
      - master
  pull_request:
  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: Set PATH
        # https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#adding-a-system-path
        run: |
          echo "$HOME/.cabal/bin" >> $GITHUB_PATH
      - uses: actions/cache@v1
        with:
          path: ~/.cabal/store
          key: linux-store-meta
      - name: ghcup
        run: |
          ghcup config set cache true
          ghcup install ghc recommended
          ghcup set ghc recommended
      - 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 -B lexer
          make -B spdx
          make -B templates
          make -B github-actions
          make -B 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
      - 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: ghcup
        run: |
          ghcup config set cache true
          ghcup install ghc recommended
          ghcup set ghc recommended
      - 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
