name: Build & Test

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  build:

    runs-on: ubuntu-18.04
    strategy:
      matrix:
        ocaml-version: [ '4.11.0' ]

    steps:
    - uses: actions/checkout@v2
    - name: Setup OCaml ${{ matrix.ocaml-version }}
      uses: avsm/setup-ocaml@master
      with:
        ocaml-version: ${{ matrix.ocaml-version }}
    - name: Build
      run: |
        opam install -y dune core_kernel clap ppx_deriving ppx_deriving_yojson ppxlib yojson fileutils yaml
        eval $(opam env)
        dune build @install
        mkdir -p output
        dune install --prefix output
    - name: Prepare to test
      run: |
        sudo apt-get install -y lua5.3
        sudo ln -sf /usr/bin/lua{5.3,}
        mkdir -p test/out
    - name: Test
      run: ./test/run-test.py -b output/bin/moonsmith -n 2500 -t 2
