name: CI Build

on:
  pull_request: {}
  push:
    branches:
      - main
    tags:
      - v*

jobs:
  test:
    name: Tests
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
      - uses: volta-cli/action@v1
        with:
          node-version: 12.x
      - run: yarn install --frozen-lockfile
      - run: yarn lint
      - run: yarn test:ember

  floating-dependencies:
    name: 'Floating Dependencies'
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
      - uses: volta-cli/action@v1
        with:
          node-version: 12.x
      - run: yarn install --no-lockfile
      - run: yarn test:ember

  try-scenarios:
    name: 'Try: ${{ matrix.ember-try-scenario }}'

    runs-on: ubuntu-latest

    needs: test

    strategy:
      fail-fast: false
      matrix:
        ember-try-scenario:
          - ember-lts-3.16
          - ember-lts-3.20
          - ember-release
          - ember-beta
          - ember-canary
          - ember-default-with-jquery
          - ember-classic
          - embroider-safe
          - embroider-optimized

    steps:
      - uses: actions/checkout@v2
      - uses: volta-cli/action@v1
        with:
          node-version: 12.x
      - name: install dependencies
        run: yarn install --frozen-lockfile
      - name: test
        run: node_modules/.bin/ember try:one ${{ matrix.ember-try-scenario }} --skip-cleanup

  automerge:
    needs: [test, floating-dependencies, try-scenarios]
    runs-on: ubuntu-latest
    steps:
      - uses: fastify/github-action-merge-dependabot@v2.0.0
        with:
          github-token: ${{secrets.GITHUB_TOKEN}}
