Skip to content

Commit

Permalink
Merge pull request #217 from omBratteng/add-github-actions
Browse files Browse the repository at this point in the history
Add GitHub actions
  • Loading branch information
danilowoz authored Sep 20, 2020
2 parents 2cf826e + 3784f2b commit c606eed
Show file tree
Hide file tree
Showing 4 changed files with 143 additions and 17 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Continuous Integration

on:
push:

jobs:
check:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: ['10', '12', '14']
name: "[v${{ matrix.node-version }}] lint and test"

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2-beta
with:
node-version: ${{ matrix.node-version }}

# Check if cache exists, based on the hash of the lockfile
- name: Cache node_modules
id: cache-node_modules
uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-node-${{matrix.node-version}}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-${{matrix.node-version}}-
${{ runner.os }}-node-
${{ runner.os }}-
# If there is no cache available, we run npm installation in CI mode
- name: Install dependencies
if: steps.cache-node_modules.outputs.cache-hit != 'true'
run: npm ci

- name: Lint
run: npm run lint

- name: Run tests
run: npm run test

# Build and check if it builds ok.
- name: Build
env:
BUNDLESIZE_GITHUB_TOKEN: ${{ secrets.BUNDLESIZE }}
run: npm run build
92 changes: 92 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: Release

on:
push:
branches:
- master

jobs:
prepare:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: ['14']
name: "[v${{ matrix.node-version }}] check"

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2-beta
with:
node-version: ${{ matrix.node-version }}

# Check if cache exists, based on the hash of the lockfile
- name: Cache node_modules
id: cache-node_modules
uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-node-${{matrix.node-version}}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-${{matrix.node-version}}-
${{ runner.os }}-node-
${{ runner.os }}-
# If there is no cache available, we run npm installation in CI mode
- name: Install dependencies
if: steps.cache-node_modules.outputs.cache-hit != 'true'
run: npm ci

- name: Lint
run: npm run lint

- name: Run tests
run: npm run test

build-and-release:
runs-on: ubuntu-latest
needs: prepare
strategy:
matrix:
node-version: ['14']
name: "[v${{ matrix.node-version }}] release"

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2-beta
with:
node-version: ${{ matrix.node-version }}

# Check if cache exists, based on the hash of the lockfile
- name: Cache node_modules
id: cache-node_modules
uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-node-${{matrix.node-version}}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-${{matrix.node-version}}-
${{ runner.os }}-node-
${{ runner.os }}-
# If there is no cache available, we run npm installation in CI mode
- name: Install dependencies
if: steps.cache-node_modules.outputs.cache-hit != 'true'
run: npm ci

# Build and check if it builds ok.
- name: Build
env:
BUNDLESIZE_GITHUB_TOKEN: ${{ secrets.BUNDLESIZE }}
run: npm run build

- name: Release
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npm run release
16 changes: 0 additions & 16 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"dev": "start-storybook -p 6006",
"build": "rm -fr ./dist ./native && rollup -c && npm run test:size",
"deploy:docs": "storybook-to-ghpages",
"test": "npm run test:tsc && npm run test:unit && npm run build",
"test": "npm run test:tsc && npm run test:unit",
"test:unit": "npm run test:unit:web && npm run test:unit:native",
"test:unit:web": "jest -c jest.web.config.js",
"test:unit:native": "jest -c jest.native.config.js",
Expand Down

0 comments on commit c606eed

Please sign in to comment.