name: test
on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - "**/*"
jobs:
  test-client:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node: [12, 14, 16]
        ember:
          - ember-lts-3.20
          - ember-lts-3.24
          - ember-release
          - ember-beta
          - ember-canary
          - ember-default-with-jquery
          - ember-classic
          - embroider-safe
          - embroider-optimized

    name: Build
    steps:
      - name: Check out a copy of the repo
        uses: actions/checkout@v2
 
      - name: Use Node.js ${{ env.NODE_VERSION }}
        uses: actions/setup-node@v2-beta
        with:
          node-version: ${{ matrix.node }}
 
      - name: Get Yarn cache path
        id: yarn-cache-dir-path
        run: echo "::set-output name=dir::$(yarn cache dir)"
 
      - name: Cache Yarn cache and node_modules
        id: cache-dependencies
        uses: actions/cache@v2
        with:
          path: |
            ${{ steps.yarn-cache-dir-path.outputs.dir }}
            node_modules
          key: 1-${{ runner.os }}-${{ env.NODE_VERSION }}-${{ hashFiles('**/yarn.lock') }}
          restore-keys: ${{ runner.os }}-${{ env.NODE_VERSION }}-
 
      - name: Install dependencies
        run: yarn install --frozen-lockfile
        if: steps.cache-dependencies.outputs.cache-hit != 'true'
 
      - name: Test Ember
        run: yarn ember try:one ${{matrix.ember}} --- ember test
  lint:
    runs-on: ubuntu-latest
    name: Lint
    steps:
      - name: Check out a copy of the repo
        uses: actions/checkout@v2
 
      - name: Use Node.js ${{ env.NODE_VERSION }}
        uses: actions/setup-node@v2-beta
        with:
          node-version: 16
 
      - name: Get Yarn cache path
        id: yarn-cache-dir-path
        run: echo "::set-output name=dir::$(yarn cache dir)"
 
      - name: Cache Yarn cache and node_modules
        id: cache-dependencies
        uses: actions/cache@v2
        with:
          path: |
            ${{ steps.yarn-cache-dir-path.outputs.dir }}
            node_modules
          key: 1-${{ runner.os }}-${{ env.NODE_VERSION }}-${{ hashFiles('**/yarn.lock') }}
          restore-keys: ${{ runner.os }}-${{ env.NODE_VERSION }}-
 
      - name: Install dependencies
        run: yarn install --frozen-lockfile
        if: steps.cache-dependencies.outputs.cache-hit != 'true'
 
      - name: Lint
        run: yarn lint

