---
name: test

'on': [pull_request, push]

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

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