# This file was autogenerated by create-github-actions-setup-for-ember-addons.
#
# You can upgrade the GitHub Actions workflow to the latest blueprints used
# by Create GitHub Actions setup for Ember Addons by running it again:
#
# - `yarn create github-actions-setup-for-ember-addons` if using yarn and
# - `npm init github-actions-setup-for-ember-addons` if using NPM.
#
# See https://github.com/jelhan/create-github-actions-setup-for-ember-addon for
# details.
#
# The following lines contain the configuration used in the last run. Please do
# not change them. Doing so could break upgrade flow.
#
<%- configurationDump.trim().replace(/^/mg, "#$ ") %>
#

name: CI

on:
  push:
    branches:
      - master
  pull_request:

env:
  NODE_VERSION: '<%- nodeVersion %>'

jobs:
  lint:
    name: Lint
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
      with:
        fetch-depth: 1

    - uses: actions/setup-node@v2-beta
      with:
        node-version: '${{ env.NODE_VERSION }}'

    - name: Get package manager's global cache path
      id: global-cache-dir-path
      run: echo "::set-output name=dir::$(<%
        if (packageManager === 'npm') {
          %>npm config get cache<%
        } else {
          %>yarn cache dir<%
        } %>)"

    - name: Cache package manager's global cache and node_modules
      id: cache-dependencies
      uses: actions/cache@v2
      with:
        path: |
          ${{ steps.global-cache-dir-path.outputs.dir }}
          node_modules
        key: ${{ runner.os }}-${{ matrix.node-version }}-${{
          hashFiles('**/<%
            if (packageManager === 'npm') {
              %>package-lock.json<%
            } else {
              %>yarn.lock<%
            } %>'
          ) }}
        restore-keys: |
          ${{ runner.os }}-${{ matrix.node-version }}-

    - name: Install Dependencies
      run: <%
        if (packageManager === 'npm') {
          %>npm ci<%
        } else {
          %>yarn install --frozen-lockfile<%
        } %>
      if: |
        steps.cache-dependencies.outputs.cache-hit != 'true'

    - name: Lint
      run: <% if (packageManager === 'npm') { %>npm run-script<% } else { %>yarn<% } %> lint


  test:
    name: Tests
    runs-on: ${{ matrix.os }}
    needs: lint

    strategy:
      matrix:
        os: [ubuntu-latest]
        browser: [<%- browsers.join(', ') %>]

    steps:
    - uses: actions/checkout@v2
      with:
        fetch-depth: 1

    - uses: actions/setup-node@v2-beta
      with:
        node-version: '${{ env.NODE_VERSION }}'

    - name: Get package manager's global cache path
      id: global-cache-dir-path
      run: echo "::set-output name=dir::$(<%
        if (packageManager === 'npm') {
          %>npm config get cache<%
        } else {
          %>yarn cache dir<%
        } %>)"

    - name: Cache package manager's global cache and node_modules
      id: cache-dependencies
      uses: actions/cache@v2
      with:
        path: |
          ${{ steps.global-cache-dir-path.outputs.dir }}
          node_modules
        key: ${{ runner.os }}-${{ matrix.node-version }}-${{
          hashFiles('**/<%
            if (packageManager === 'npm') {
              %>package-lock.json<%
            } else {
              %>yarn.lock<%
            } %>'
          ) }}
        restore-keys: |
          ${{ runner.os }}-${{ matrix.node-version }}-

    - name: Install Dependencies
      run: <%
        if (packageManager === 'npm') {
          %>npm ci<%
        } else {
          %>yarn install --frozen-lockfile<%
        } %>
      if: |
        steps.cache-dependencies.outputs.cache-hit != 'true'

    - name: Test
      run: <% if (packageManager === 'npm') { %>npm run-script<% } else { %>yarn<% } %> test:ember --launch ${{ matrix.browser }}


  floating-dependencies:
    name: Floating Dependencies
    runs-on: ${{ matrix.os }}
    needs: lint

    strategy:
      matrix:
        os: [ubuntu-latest]
        browser: [<%- browsers.join(', ') %>]

    steps:
    - uses: actions/checkout@v2
      with:
        fetch-depth: 1

    - uses: actions/setup-node@v2-beta
      with:
        node-version: '${{ env.NODE_VERSION }}'

    - name: Get package manager's global cache path
      id: global-cache-dir-path
      run: echo "::set-output name=dir::$(<%
        if (packageManager === 'npm') {
          %>npm config get cache<%
        } else {
          %>yarn cache dir<%
        } %>)"

    - name: Cache package manager's global cache and node_modules
      id: cache-dependencies
      uses: actions/cache@v2
      with:
        path: |
          ${{ steps.global-cache-dir-path.outputs.dir }}
          node_modules
        key: ${{ runner.os }}-${{ matrix.node-version }}-floating-deps
        restore-keys: |
          ${{ runner.os }}-${{ matrix.node-version }}-

    - name: Install Dependencies
      run: <%
        if (packageManager === 'npm') {
          %>npm install --no-package-lock<%
        } else {
          %>yarn install --no-lockfile --non-interactive<%
        } %>

    - name: Test
      run: <% if (packageManager === 'npm') { %>npm run-script<% } else { %>yarn<% } %> test:ember --launch ${{ matrix.browser }}


  try-scenarios:
    name: Tests - ${{ matrix.ember-try-scenario }}
    runs-on: ubuntu-latest
    continue-on-error: true
    needs: test

    strategy:
      fail-fast: true
      matrix:
        ember-try-scenario: [<%
          emberTryScenarios
            .forEach(function({ scenario }, index, requiredEmberTryScenarios) {
              const isLastElement = requiredEmberTryScenarios.length - 1 === index; %>
          <%- scenario %><% if (!isLastElement) { %>,<% }
            }); %>
        ]

    steps:
    - uses: actions/checkout@v2
      with:
        fetch-depth: 1

    - uses: actions/setup-node@v2-beta
      with:
        node-version: '${{ env.NODE_VERSION }}'

    - name: Get package manager's global cache path
      id: global-cache-dir-path
      run: echo "::set-output name=dir::$(<%
        if (packageManager === 'npm') {
          %>npm config get cache<%
        } else {
          %>yarn cache dir<%
        } %>)"

    - name: Cache package manager's global cache and node_modules
      id: cache-dependencies
      uses: actions/cache@v2
      with:
        path: |
          ${{ steps.global-cache-dir-path.outputs.dir }}
          node_modules
        key: ${{ runner.os }}-${{ matrix.node-version }}-${{
          hashFiles('**/<%
            if (packageManager === 'npm') {
              %>package-lock.json<%
            } else {
              %>yarn.lock<%
            } %>'
          ) }}
        restore-keys: |
          ${{ runner.os }}-${{ matrix.node-version }}-

    - name: Install Dependencies
      run: <%
        if (packageManager === 'npm') {
          %>npm ci<%
        } else {
          %>yarn install --frozen-lockfile<%
        } %>
      if: |
        steps.cache-dependencies.outputs.cache-hit != 'true'

    - name: Test
      env:
        EMBER_TRY_SCENARIO: ${{ matrix.ember-try-scenario }}
      run: node_modules/.bin/ember try:one $EMBER_TRY_SCENARIO
