Skip to content

Instantly share code, notes, and snippets.

@ijlee2

ijlee2/ci.yml

Last active Nov 6, 2020
Embed
What would you like to do?
GitHub Actions workflow for Ember addons (npm)
# The workflow template is designed for Ember addons.
#
# It assumes certain dependencies and scripts in package.json. If
# they don't apply to your project, feel free to remove irrelevant
# code in the workflow. These can be inferred from the job name.
#
# {
# "scripts": {
# "build": "ember build --environment=production",
# "build:test": "ember build --environment=test",
# "lint": "npm-run-all --aggregate-output --continue-on-error --parallel lint:*",
# "lint:dependency": "ember dependency-lint",
# "lint:hbs": "ember-template-lint .",
# "lint:js": "eslint .",
# "start": "ember serve",
# "test": "npm-run-all lint:* test:*",
# "test:ember": "percy exec -- ember exam --query=nolint --split=2 --parallel=1",
# "test:ember-compatibility": "ember try:one"
# },
# "devDependencies": {
# "@percy/ember" (test-app)
# "ember-a11y-testing" (test-app)
# "ember-cli-dependency-lint" (lint)
# "ember-exam" (test-app, test-compatibility)
# "ember-template-lint" (lint)
# "ember-try" (test-compatibility)
# "eslint" (lint)
# "npm-run-all" (lint, test-app)
# },
# }
#
# For more information, please visit:
#
# - https://crunchingnumbers.live/2020/03/17/ci-with-github-actions-for-ember-apps/
# - https://crunchingnumbers.live/2020/08/31/ci-with-github-actions-for-ember-apps-part-2/
#
# Author: Isaac J. Lee (GitHub: @ijlee2)
# Created at: August 31, 2020
# Updated at: November 5, 2020
#
name: CI
on:
push:
branches:
- main
pull_request:
schedule:
# Run the workflow every Monday at 6 am CST
- cron: '0 11 * * MON'
env:
NODE_VERSION: 14
PERCY_PARALLEL_NONCE: ${{ github.run_id }}-${{ github.run_number }}
PERCY_PARALLEL_TOTAL: 2
jobs:
build-app:
name: Build app for testing
runs-on: ubuntu-latest
timeout-minutes: 7
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: ${{ env.NODE_VERSION }}
- name: Cache npm cache and node_modules
id: cache-dependencies
uses: actions/cache@v2
with:
path: |
~/.npm
node_modules
key: ${{ runner.os }}-${{ env.NODE_VERSION }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.os }}-${{ env.NODE_VERSION }}-
- name: Install dependencies
run: npm install
if: steps.cache-dependencies.outputs.cache-hit != 'true'
- name: Build app
run: npm run build:test
- name: Upload app
uses: actions/upload-artifact@v2
with:
name: dist
path: dist
lint:
name: Lint files and dependencies
runs-on: ubuntu-latest
timeout-minutes: 7
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: ${{ env.NODE_VERSION }}
- name: Cache npm cache and node_modules
id: cache-dependencies
uses: actions/cache@v2
with:
path: |
~/.npm
node_modules
key: ${{ runner.os }}-${{ env.NODE_VERSION }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.os }}-${{ env.NODE_VERSION }}-
- name: Install dependencies
run: npm install
if: steps.cache-dependencies.outputs.cache-hit != 'true'
- name: Lint
run: npm run lint
test-app:
name: Test app
needs: [build-app]
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
partition:
- 1
- 2
timeout-minutes: 7
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: ${{ env.NODE_VERSION }}
- name: Cache npm cache and node_modules
id: cache-dependencies
uses: actions/cache@v2
with:
path: |
~/.npm
node_modules
key: ${{ runner.os }}-${{ env.NODE_VERSION }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.os }}-${{ env.NODE_VERSION }}-
- name: Install dependencies
run: npm install
if: steps.cache-dependencies.outputs.cache-hit != 'true'
- name: Download app
uses: actions/download-artifact@v2
with:
name: dist
path: dist
- name: Test
uses: percy/exec-action@v0.3.1
with:
custom-command: npm run test:ember --partition=${{ matrix.partition }} --path=dist
env:
PERCY_PARALLEL_NONCE: ${{ env.PERCY_PARALLEL_NONCE }}
PERCY_PARALLEL_TOTAL: ${{ env.PERCY_PARALLEL_TOTAL }}
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}
test-compatibility:
name: Test compatibility
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
scenario:
- 'ember-lts-3.16'
- 'ember-lts-3.20'
- 'ember-release'
- 'ember-beta'
- 'ember-canary'
partition:
- 1
- 2
timeout-minutes: 7
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: ${{ env.NODE_VERSION }}
- name: Cache npm cache and node_modules
id: cache-dependencies
uses: actions/cache@v2
with:
path: |
~/.npm
node_modules
key: ${{ runner.os }}-${{ env.NODE_VERSION }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.os }}-${{ env.NODE_VERSION }}-
- name: Install dependencies
run: npm install
if: steps.cache-dependencies.outputs.cache-hit != 'true'
# Test compatibility without Percy
- name: Test
run: npm run test:ember-compatibility ${{ matrix.scenario }} --- npm run test:ember --partition=${{ matrix.partition }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.