name: CI

on:
  pull_request:
  push:
    # filtering branches here prevents duplicate builds from pull_request and push
    branches:
      - master
  schedule:
    - cron: '0 3 * * 0' # every Sunday at 3am

env:
  CI: true

jobs:
  tests:
    if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')"
    name: Base Tests
    timeout-minutes: 5
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node:
          - '12'
          - '14'
    steps:
      - uses: actions/checkout@v2
      - uses: volta-cli/action@v1
        with:
          node-version: ${{ matrix.node }}

      - run: npm ci

      - name: Test with ${{ matrix.node }}
        run: npm run test:ember

  floating-dependencies:
    if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')"
    name: Floating Dependencies
    timeout-minutes: 5
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node:
          - '12'
          - '14'

    steps:
      - uses: actions/checkout@v2
      - uses: volta-cli/action@v1
        with:
          node-version: ${{ matrix.node }}

      - run: npm install --no-package-lock
      - name: Test with Node ${{ matrix.node }}
        run: npm run test:ember

  try-scenarios:
    if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')"
    name: 'Compatibility'
    timeout-minutes: 5
    runs-on: ubuntu-latest
    needs: tests

    strategy:
      fail-fast: true
      matrix:
        ember-try-scenario:
          - ember-lts-3.16
          - ember-lts-3.20
          - ember-release
          - ember-beta
          - ember-canary
          - ember-classic
    steps:
      - uses: actions/checkout@v2
      - uses: volta-cli/action@v1
        with:
          node-version: 12.x
      - name: install dependencies
        run: npm ci
      - name: test
        run: node_modules/.bin/ember try:one ${{ matrix.ember-try-scenario }} --skip-cleanup
