-
-
Save ijlee2/030df226d02e32f6e4311591f58d87f8 to your computer and use it in GitHub Desktop.
CI for Ember apps (npm)
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: Cache npm cache (Linux or Mac) | |
id: cache-npm-cache-posix | |
uses: actions/cache@v1 | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-${{ matrix.node-version }}-npm-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-${{ matrix.node-version }}-npm- | |
if: startsWith(matrix.os, 'ubuntu') || startsWith(matrix.os, 'macos') | |
- name: Cache npm cache (Windows) | |
id: cache-npm-cache-windows | |
uses: actions/cache@v1 | |
with: | |
path: ~/AppData/Roaming/npm-cache | |
key: ${{ runner.os }}-${{ matrix.node-version }}-npm-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-${{ matrix.node-version }}-npm- | |
if: startsWith(matrix.os, 'windows') | |
- name: Cache node_modules | |
id: cache-node-modules | |
uses: actions/cache@v1 | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-${{ matrix.node-version }}-nodemodules-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-${{ matrix.node-version }}-nodemodules- | |
- name: Install dependencies | |
run: npm install | |
if: | | |
( | |
steps.cache-npm-cache-posix && | |
steps.cache-npm-cache-posix.outputs.cache-hit != 'true' | |
) || | |
( | |
steps.cache-npm-cache-windows && | |
steps.cache-npm-cache-windows.outputs.cache-hit != 'true' | |
) || | |
steps.cache-node-modules.outputs.cache-hit != 'true' | |
- name: lint:dependency | |
run: npm run lint:dependency | |
- name: lint:hbs | |
run: npm run lint:hbs | |
- name: lint:js | |
run: npm run 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: Cache npm cache (Linux or Mac) | |
id: cache-npm-cache-posix | |
uses: actions/cache@v1 | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-${{ matrix.node-version }}-npm-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-${{ matrix.node-version }}-npm- | |
if: startsWith(matrix.os, 'ubuntu') || startsWith(matrix.os, 'macos') | |
- name: Cache npm cache (Windows) | |
id: cache-npm-cache-windows | |
uses: actions/cache@v1 | |
with: | |
path: ~/AppData/Roaming/npm-cache | |
key: ${{ runner.os }}-${{ matrix.node-version }}-npm-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-${{ matrix.node-version }}-npm- | |
if: startsWith(matrix.os, 'windows') | |
- name: Cache node_modules | |
id: cache-node-modules | |
uses: actions/cache@v1 | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-${{ matrix.node-version }}-nodemodules-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-${{ matrix.node-version }}-nodemodules- | |
- name: Install dependencies | |
run: npm install | |
if: | | |
( | |
steps.cache-npm-cache-posix && | |
steps.cache-npm-cache-posix.outputs.cache-hit != 'true' | |
) || | |
( | |
steps.cache-npm-cache-windows && | |
steps.cache-npm-cache-windows.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: npm run 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: Cache npm cache (Linux or Mac) | |
id: cache-npm-cache-posix | |
uses: actions/cache@v1 | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-${{ matrix.node-version }}-npm-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-${{ matrix.node-version }}-npm- | |
if: startsWith(matrix.os, 'ubuntu') || startsWith(matrix.os, 'macos') | |
- name: Cache npm cache (Windows) | |
id: cache-npm-cache-windows | |
uses: actions/cache@v1 | |
with: | |
path: ~/AppData/Roaming/npm-cache | |
key: ${{ runner.os }}-${{ matrix.node-version }}-npm-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-${{ matrix.node-version }}-npm- | |
if: startsWith(matrix.os, 'windows') | |
- name: Cache node_modules | |
id: cache-node-modules | |
uses: actions/cache@v1 | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-${{ matrix.node-version }}-nodemodules-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-${{ matrix.node-version }}-nodemodules- | |
- name: Install dependencies | |
run: npm install | |
if: | | |
( | |
steps.cache-npm-cache-posix && | |
steps.cache-npm-cache-posix.outputs.cache-hit != 'true' | |
) || | |
( | |
steps.cache-npm-cache-windows && | |
steps.cache-npm-cache-windows.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: npm run 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: Cache npm cache (Linux or Mac) | |
id: cache-npm-cache-posix | |
uses: actions/cache@v1 | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-${{ matrix.node-version }}-npm-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-${{ matrix.node-version }}-npm- | |
if: startsWith(matrix.os, 'ubuntu') || startsWith(matrix.os, 'macos') | |
- name: Cache npm cache (Windows) | |
id: cache-npm-cache-windows | |
uses: actions/cache@v1 | |
with: | |
path: ~/AppData/Roaming/npm-cache | |
key: ${{ runner.os }}-${{ matrix.node-version }}-npm-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-${{ matrix.node-version }}-npm- | |
if: startsWith(matrix.os, 'windows') | |
- name: Cache node_modules | |
id: cache-node-modules | |
uses: actions/cache@v1 | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-${{ matrix.node-version }}-nodemodules-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-${{ matrix.node-version }}-nodemodules- | |
- name: Install dependencies | |
run: npm install | |
if: | | |
( | |
steps.cache-npm-cache-posix && | |
steps.cache-npm-cache-posix.outputs.cache-hit != 'true' | |
) || | |
( | |
steps.cache-npm-cache-windows && | |
steps.cache-npm-cache-windows.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: npm run 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: Cache npm cache (Linux or Mac) | |
id: cache-npm-cache-posix | |
uses: actions/cache@v1 | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-${{ matrix.node-version }}-npm-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-${{ matrix.node-version }}-npm- | |
if: startsWith(matrix.os, 'ubuntu') || startsWith(matrix.os, 'macos') | |
- name: Cache npm cache (Windows) | |
id: cache-npm-cache-windows | |
uses: actions/cache@v1 | |
with: | |
path: ~/AppData/Roaming/npm-cache | |
key: ${{ runner.os }}-${{ matrix.node-version }}-npm-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-${{ matrix.node-version }}-npm- | |
if: startsWith(matrix.os, 'windows') | |
- name: Cache node_modules | |
id: cache-node-modules | |
uses: actions/cache@v1 | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-${{ matrix.node-version }}-nodemodules-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-${{ matrix.node-version }}-nodemodules- | |
- name: Install dependencies | |
run: npm install | |
if: | | |
( | |
steps.cache-npm-cache-posix && | |
steps.cache-npm-cache-posix.outputs.cache-hit != 'true' | |
) || | |
( | |
steps.cache-npm-cache-windows && | |
steps.cache-npm-cache-windows.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: npm run 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