Skip to content

Commit

Permalink
add yarn test in pre commit and github workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
sujinleeme committed Mar 17, 2021
1 parent 4c5f0c4 commit fea0ffc
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 5 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/master_deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: MasterDeployCI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:
runs-on: ubuntu-20.04
strategy:
matrix:
node-version: [12.x]
steps:
- uses: actions/checkout@v2

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

# See: https://github.com/actions/cache/blob/main/examples.md#node---yarn
- name: Get Yarn cache directory
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- name: Use Yarn cache
uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}

# `--prefer-offline` gives cache priority
- name: Install dependencies
run: yarn install --prefer-offline --frozen-lockfile

- name: Execute Test
run: yarn test:coverage

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}

- name: Pre deploy
run: yarn predeploy

- name: Deploy to GH Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./build
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# 🖌 React JSON Editor

![CI/CD](https://github.com/sujinleeme/react-json-editor/actions/workflows/master_deploy.yml/badge.svg)
[![Codecov](https://img.shields.io/codecov/c/github/sujinleeme/react-json-editor)](https://codecov.io/gh/sujinleeme/react-json-editor)
![License](https://img.shields.io/github/license/sujinleeme/react-json-editor)

![alt text](./demo.png "demo")

- Download / Upload JSON file
Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"bugs": {
"url": "https://github.com/sujinleeme/react-json-editor/issues"
},
"homepage": "http://sujinleeme.github.io/react-json-editor",
"homepage": "/react-json-editor/",
"dependencies": {
"@fluentui/react": "^7.158.1",
"@monaco-editor/react": "^4.0.9",
Expand All @@ -39,8 +39,8 @@
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"test:coverage": "test -- --coverage",
"test": "CI=true react-scripts test",
"test:coverage": "yarn test --coverage",
"eject": "react-scripts eject",
"format": "prettier --write src/**/*.ts{,x}",
"lint": "tsc --noEmit && eslint src/**/*.ts{,x}",
Expand All @@ -49,7 +49,8 @@
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
"pre-commit": "lint-staged && yarn test",
"pre-push": "lint-staged && yarn test"
}
},
"lint-staged": {
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
"noEmit": true,
"jsx": "react-jsx"
},
"include": ["src/**/*", "dirty-json.d.ts"]
"include": ["src/**/*", "types/dirty-json.d.ts"]
}

0 comments on commit fea0ffc

Please sign in to comment.