name: spec

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

jobs:
  test:
    strategy:
      fail-fast: false
      matrix:
        lua-version: ["5.4", "5.3", "5.2", "5.1", "luajit"]
        strict: ["std.strict", ""]

    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2

      - uses: luarocks/gh-actions-lua@v10
        with:
          luaVersion: ${{ matrix.lua-version }}

      - uses: luarocks/gh-actions-luarocks@v5

      - name: install
        run: |
          sudo apt-get install -y libyaml-dev
          luarocks install ansicolors
          luarocks install ldoc
          luarocks install luacov
          luarocks install specl
          luarocks install std._debug
          luarocks install typecheck
          test -n "${{ matrix.strict }}" && luarocks install std.strict || true

      - name: build
        run: |
          luarocks make --force

      - name: test
        run: |
          specl -vfreport --coverage spec/*_spec.yaml
          bash <(curl -s https://codecov.io/bash) -f luacov.report.out
