---
name: test

"on":
  pull_request:
  push:
    branches:
      - main
      - master

env:
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
  test:
    strategy:
      matrix:
        elixir: ["1.11.x", "1.12.x"]
        erlang: ["23.x", "24.x"]
        os: [ubuntu-latest]
    runs-on: ${{ matrix.os }}
    steps:
      - uses: erlef/setup-beam@v1
        with:
          elixir-version: ${{ matrix.elixir }}
          otp-version: ${{ matrix.erlang }}
      - uses: actions/checkout@v2
      - uses: actions/cache@v2
        with:
          path: |
            _build
            deps
          key: ${{ runner.os }}-erl${{ matrix.erlang }}-ex${{ matrix.elixir }}-${{ hashFiles('mix.lock') }}
          restore-keys: |
            ${{ runner.os }}-erl${{ matrix.erlang }}-ex${{ matrix.elixir }}-
            ${{ runner.os }}-erl${{ matrix.erlang }}-
      - name: Lint & test
        run: |
          mix "do" deps.get, deps.clean --unused, cotton.lint
          mix coveralls.github
