name: Wordsmith CI

on:
  push:
    branches: [main]
  pull_request:
    branches: "*"

jobs:
  check_format:
    strategy:
      fail-fast: false
      matrix:
        crystal_version:
          - latest
        experimental:
          - false
    continue-on-error: ${{ matrix.experimental }}
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - uses: crystal-lang/install-crystal@v1
        with:
          crystal: ${{matrix.crystal_version}}
      - name: Install shards
        run: shards install
      - name: Format
        run: crystal tool format --check
      - name: Lint
        run: ./bin/ameba

  specs:
    strategy:
      fail-fast: false
      matrix:
        crystal_version:
          - 1.4.0
          - 1.5.0
          - latest
        experimental:
          - false
    continue-on-error: ${{ matrix.experimental }}
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: crystal-lang/install-crystal@v1
        with:
          crystal: ${{matrix.crystal_version}}
      - name: Install dependencies
        run: shards install
      - name: Run tests
        run: crystal spec
