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

jobs:
{% for job in macosJobs %}
  validate-macos-{{ mangleVersion job.version }}:
    name: validate.sh macos ghc-{{job.version}}
    runs-on: macos-latest
{% for needs in job.needs %}
    needs: validate-macos-{{ mangleVersion needs }}
{% endfor %}
    steps:
      - name: System info
        run: |
          uname -a
      - name: Install Autotools
        run: |
          brew install automake
      - name: Install GHC
        run: |
          cd $(mktemp -d)
          curl -sLO {{job.ghcUrl}}
          tar -xJf ghc-*.tar.xz
          cd ghc-*
          ./configure --prefix=/opt/ghc/{{job.version}}
          sudo make install
      - name: Install Cabal
        run: |
          cd $(mktemp -d)
          curl -sLO https://downloads.haskell.org/~cabal/cabal-install-3.0.0.0/cabal-install-3.0.0.0-x86_64-apple-darwin17.7.0.tar.xz
          tar -xJf cabal-install-*.tar.xz
          sudo mkdir -p /opt/cabal/3.0/bin
          sudo cp cabal /opt/cabal/3.0/bin/cabal
          sudo chmod 755 /opt/cabal/3.0/bin/cabal
      - name: Set PATH
        run: |
          echo "/opt/ghc/{{ job.version }}/bin" >> $GITHUB_PATH
          echo "/opt/cabal/3.0/bin" >> $GITHUB_PATH
          echo "$HOME/.cabal/bin" >> $GITHUB_PATH
      - name: Update Hackage index
        run: cabal v2-update
      - name: Install cabal-plan
        run: |
          cd $(mktemp -d)
{# aeson +fast, so we don't wait for -O2 #}
          cabal v2-install cabal-plan --constraint='cabal-plan ^>=0.6.2.0' --constraint='aeson +fast' --constraint='cabal-plan +exe'
      - uses: actions/checkout@v2
{% for step in job.steps %}
      - name: Validate {{step}}
        run: sh validate.sh -j 2 -w ghc-{{job.version}} -v {{job.flags}} -s {{step}}
{% endfor %}
{% endfor %}
