CI for Ember apps (yarn)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# For more information, visit https://crunchingnumbers.live/2020/03/17/ci-with-github-actions-for-ember-apps/ | |
name: CI | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
env: | |
PERCY_PARALLEL_NONCE: ${{ github.run_id }}-${{ github.run_number }} | |
jobs: | |
check-nonce: | |
name: Check nonce | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest] | |
node-version: [12.x] | |
steps: | |
- name: Display nonce | |
run: echo ${{ env.PERCY_PARALLEL_NONCE }} | |
lint: | |
name: Lint files and dependencies | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest] | |
node-version: [12.x] | |
steps: | |
- name: Check out a copy of the repo | |
uses: actions/checkout@v2 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v1 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Get Yarn cache path | |
id: yarn-cache-dir-path | |
run: echo "::set-output name=dir::$(yarn cache dir)" | |
- name: Cache Yarn cache | |
id: cache-yarn-cache | |
uses: actions/cache@v1 | |
with: | |
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | |
key: ${{ runner.os }}-${{ matrix.node-version }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-${{ matrix.node-version }}-yarn- | |
- name: Cache node_modules | |
id: cache-node-modules | |
uses: actions/cache@v1 | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-${{ matrix.node-version }}-nodemodules-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-${{ matrix.node-version }}-nodemodules- | |
- name: Install dependencies | |
run: yarn install --frozen-lockfile | |
if: | | |
steps.cache-yarn-cache.outputs.cache-hit != 'true' || | |
steps.cache-node-modules.outputs.cache-hit != 'true' | |
- name: lint:dependency | |
run: yarn lint:dependency | |
- name: lint:hbs | |
run: yarn lint:hbs | |
- name: lint:js | |
run: yarn lint:js | |
test-partition-1: | |
name: Run tests - Partition 1 | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest] | |
node-version: [12.x] | |
steps: | |
- name: Check out a copy of the repo | |
uses: actions/checkout@v2 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v1 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Get Yarn cache path | |
id: yarn-cache-dir-path | |
run: echo "::set-output name=dir::$(yarn cache dir)" | |
- name: Cache Yarn cache | |
id: cache-yarn-cache | |
uses: actions/cache@v1 | |
with: | |
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | |
key: ${{ runner.os }}-${{ matrix.node-version }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-${{ matrix.node-version }}-yarn- | |
- name: Cache node_modules | |
id: cache-node-modules | |
uses: actions/cache@v1 | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-${{ matrix.node-version }}-nodemodules-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-${{ matrix.node-version }}-nodemodules- | |
- name: Install dependencies | |
run: yarn install --frozen-lockfile | |
if: | | |
steps.cache-yarn-cache.outputs.cache-hit != 'true' || | |
steps.cache-node-modules.outputs.cache-hit != 'true' | |
- name: Test Ember app | |
uses: percy/exec-action@v0.3.0 | |
with: | |
custom-command: yarn test --partition=1 | |
env: | |
PERCY_PARALLEL_NONCE: ${{ env.PERCY_PARALLEL_NONCE }} | |
PERCY_PARALLEL_TOTAL: 4 | |
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }} | |
test-partition-2: | |
name: Run tests - Partition 2 | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest] | |
node-version: [12.x] | |
steps: | |
- name: Check out a copy of the repo | |
uses: actions/checkout@v2 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v1 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Get Yarn cache path | |
id: yarn-cache-dir-path | |
run: echo "::set-output name=dir::$(yarn cache dir)" | |
- name: Cache Yarn cache | |
id: cache-yarn-cache | |
uses: actions/cache@v1 | |
with: | |
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | |
key: ${{ runner.os }}-${{ matrix.node-version }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-${{ matrix.node-version }}-yarn- | |
- name: Cache node_modules | |
id: cache-node-modules | |
uses: actions/cache@v1 | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-${{ matrix.node-version }}-nodemodules-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-${{ matrix.node-version }}-nodemodules- | |
- name: Install dependencies | |
run: yarn install --frozen-lockfile | |
if: | | |
steps.cache-yarn-cache.outputs.cache-hit != 'true' || | |
steps.cache-node-modules.outputs.cache-hit != 'true' | |
- name: Test Ember app | |
uses: percy/exec-action@v0.3.0 | |
with: | |
custom-command: yarn test --partition=2 | |
env: | |
PERCY_PARALLEL_NONCE: ${{ env.PERCY_PARALLEL_NONCE }} | |
PERCY_PARALLEL_TOTAL: 4 | |
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }} | |
test-partition-3: | |
name: Run tests - Partition 3 | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest] | |
node-version: [12.x] | |
steps: | |
- name: Check out a copy of the repo | |
uses: actions/checkout@v2 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v1 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Get Yarn cache path | |
id: yarn-cache-dir-path | |
run: echo "::set-output name=dir::$(yarn cache dir)" | |
- name: Cache Yarn cache | |
id: cache-yarn-cache | |
uses: actions/cache@v1 | |
with: | |
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | |
key: ${{ runner.os }}-${{ matrix.node-version }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-${{ matrix.node-version }}-yarn- | |
- name: Cache node_modules | |
id: cache-node-modules | |
uses: actions/cache@v1 | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-${{ matrix.node-version }}-nodemodules-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-${{ matrix.node-version }}-nodemodules- | |
- name: Install dependencies | |
run: yarn install --frozen-lockfile | |
if: | | |
steps.cache-yarn-cache.outputs.cache-hit != 'true' || | |
steps.cache-node-modules.outputs.cache-hit != 'true' | |
- name: Test Ember app | |
uses: percy/exec-action@v0.3.0 | |
with: | |
custom-command: yarn test --partition=3 | |
env: | |
PERCY_PARALLEL_NONCE: ${{ env.PERCY_PARALLEL_NONCE }} | |
PERCY_PARALLEL_TOTAL: 4 | |
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }} | |
test-partition-4: | |
name: Run tests - Partition 4 | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest] | |
node-version: [12.x] | |
steps: | |
- name: Check out a copy of the repo | |
uses: actions/checkout@v2 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v1 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Get Yarn cache path | |
id: yarn-cache-dir-path | |
run: echo "::set-output name=dir::$(yarn cache dir)" | |
- name: Cache Yarn cache | |
id: cache-yarn-cache | |
uses: actions/cache@v1 | |
with: | |
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | |
key: ${{ runner.os }}-${{ matrix.node-version }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-${{ matrix.node-version }}-yarn- | |
- name: Cache node_modules | |
id: cache-node-modules | |
uses: actions/cache@v1 | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-${{ matrix.node-version }}-nodemodules-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-${{ matrix.node-version }}-nodemodules- | |
- name: Install dependencies | |
run: yarn install --frozen-lockfile | |
if: | | |
steps.cache-yarn-cache.outputs.cache-hit != 'true' || | |
steps.cache-node-modules.outputs.cache-hit != 'true' | |
- name: Test Ember app | |
uses: percy/exec-action@v0.3.0 | |
with: | |
custom-command: yarn test --partition=4 | |
env: | |
PERCY_PARALLEL_NONCE: ${{ env.PERCY_PARALLEL_NONCE }} | |
PERCY_PARALLEL_TOTAL: 4 | |
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment