Skip to content

Commit

Permalink
Merge pull request #23 from luniehq/fabo/ci
Browse files Browse the repository at this point in the history
Fabo/added unit testing and linting
  • Loading branch information
faboweb authored Jun 27, 2019
2 parents bbe9a13 + ee00cc0 commit aaf0e2b
Show file tree
Hide file tree
Showing 11 changed files with 2,647 additions and 107 deletions.
144 changes: 144 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
version: 2.1

# reusable commands
commands:
yarn-install:
description: '[YARN] update and install'
steps:
- restore_cache:
keys:
- v4-dependencies-root-{{ checksum "package.json" }}
- v4-dependencies-root-

- run: yarn install
- save_cache:
paths:
- yarn.lock
- node_modules
key: v4-dependencies-root-{{ checksum "package.json" }}

jobs:
pendingUpdated:
docker:
- image: circleci/node:10.15.3
steps:
- checkout
- run: yarn add simsala
- run: node node_modules/simsala/src/cli.js check

lint:
docker:
- image: circleci/node:10.15.3
steps:
- checkout
- yarn-install
- run: yarn run lint

testUnit:
docker:
- image: circleci/node:10.15.3
steps:
- checkout
- yarn-install
# - run:
# name: Setup Code Climate test-reporter
# command: |
# # download test reporter as a static binary
# curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
# chmod +x ./cc-test-reporter
- run:
name: Test
command: |
# notify Code Climate of a pending test report using `before-build`
# ./cc-test-reporter before-build
yarn run test
# upload test report to Code Climate
# ./cc-test-reporter format-coverage -t lcov ./coverage/lcov.info
# ./cc-test-reporter upload-coverage
no_output_timeout: 120

security:
docker:
- image: circleci/node:10.15.3
steps:
- checkout
- run:
name: Audit
command: |
set +e
SUMMARY="$(yarn audit | grep Severity)"
VULNERABILITIES=".*(High|Critical).*"
if [[ $SUMMARY =~ $VULNERABILITIES ]]; then
echo "Unsafe dependencies found: $SUMMARY" >&2
exit 1
fi
echo "Your dependencies are secure enough: $SUMMARY"
exit 0
# Create release.
release:
docker:
- image: circleci/node:10.15.3
steps:
- checkout
- run: |
yarn add simsala
git config user.email "[email protected]"
git config user.name "Lunie Bot"
node node_modules/simsala/src/cli.js release-candidate --semver prerelease --owner luniehq --repository cosmos-js --token $GIT_BOT_TOKEN
# Push merges to master immediatly back to develop to stay in sync
mergeBack:
docker:
- image: circleci/node:10.15.3
steps:
- checkout
- run:
command: |
git remote add bot https://${GIT_BOT_TOKEN}@github.com/luniehq/lunie.git
git checkout develop
git pull
git merge origin/master
git push
workflows:
version: 2
build-and-deploy:
jobs:
# Static checks before
- pendingUpdated:
filters:
branches:
ignore:
- release
- master

- security:
filters:
branches:
ignore: release

- lint:
filters:
branches:
ignore: release

- testUnit:
filters:
branches:
ignore: release
releaseManually:
jobs:
- release:
filters:
branches:
only:
- release
mergeBack:
jobs:
- mergeBack:
filters:
branches:
only: master
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
/dist
/dist-zip
/lunie
/coverage
5 changes: 5 additions & 0 deletions .stylelintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
extends: "stylelint-config-standard",
color-no-invalid-hex: true,
font-family-no-duplicate-names: true,
}
36 changes: 32 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,44 @@
}
],
"scripts": {
"lint": "eslint --ext .js,.vue src",
"lint": "npm run lint:js && npm run lint:css",
"lint:js": "eslint --ext .js,.vue src",
"lint:css": "stylelint \"src/**/*.{css,vue}\"",
"prettier": "prettier \"src/**/*.{js,vue}\"",
"prettier:write": "npm run prettier -- --write",
"build": "cross-env NODE_ENV=production webpack --hide-modules",
"build:dev": "cross-env NODE_ENV=development webpack --hide-modules",
"build-zip": "node scripts/build-zip.js",
"watch": "npm run build -- --watch",
"watch:dev": "cross-env HMR=true npm run build:dev -- --watch"
"watch:dev": "cross-env HMR=true npm run build:dev -- --watch",
"test:unit": "jest --coverage",
"test": "npm run lint && npm run test:unit",
"log": "simsala log"
},
"husky": {
"hooks": {
"pre-commit": "pretty-quick --staged"
"pre-push": "lint-prepush"
}
},
"lint-prepush": {
"base": "develop",
"tasks": {
"*.{js,vue}": [
"eslint --fix",
"jest --bail --coverage --findRelatedTests",
"git add"
],
"*.{css,vue}": [
"stylelint --fix",
"git add"
]
}
},
"jest": {
"testMatch": [
"<rootDir>/test/unit/**/*spec.js"
]
},
"dependencies": {
"@lunie/cosmos-api": "^0.0.23",
"@lunie/cosmos-keys": "^0.1.0",
Expand Down Expand Up @@ -64,11 +88,15 @@
"eslint-plugin-vue": "^5.2.2",
"file-loader": "^1.1.11",
"husky": "^2.4.0",
"jest": "^24.8.0",
"lint-prepush": "^0.4.1",
"mini-css-extract-plugin": "^0.4.4",
"node-sass": "^4.9.3",
"prettier": "^1.17.1",
"pretty-quick": "^1.8.0",
"sass-loader": "^7.1.0",
"simsala": "^0.0.16",
"stylelint": "^10.1.0",
"stylelint-config-standard": "^18.3.0",
"vue-loader": "^15.4.2",
"vue-template-compiler": "^2.6.10",
"web-ext-types": "^2.1.0",
Expand Down
2 changes: 2 additions & 0 deletions pending/fabo_ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[Repository] [#23](https://github.com/cosmos/lunie/pull/23) Added JS and style linting @faboweb
[Repository] [#23](https://github.com/cosmos/lunie/pull/23) Added CircleCI configuration @faboweb
1 change: 1 addition & 0 deletions src/popup/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ body,
font-family: var(--sans);
color: var(--txt);
display: flex;

/* padding-top: 56px; */
flex-flow: column nowrap;
min-width: 0;
Expand Down
10 changes: 7 additions & 3 deletions src/popup/material-icons.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@
font-family: 'Material Icons';
font-style: normal;
font-weight: 400;
src: local('Material Icons'), local('MaterialIcons-Regular'), url('../fonts/MaterialIcons-Regular.woff2') format('woff2'),
url('../fonts/MaterialIcons-Regular.woff') format('woff'), url('../fonts/MaterialIcons-Regular.ttf') format('truetype');
src:
local('Material Icons'),
local('MaterialIcons-Regular'),
url('../fonts/MaterialIcons-Regular.woff2') format('woff2'),
url('../fonts/MaterialIcons-Regular.woff') format('woff'),
url('../fonts/MaterialIcons-Regular.ttf') format('truetype');
}

.mi,
.material-icons {
font-family: 'Material Icons';
font-family: 'Material Icons', sans-serif;
font-weight: normal;
font-style: normal;
font-size: 16px /* Preferred icon size */;
Expand Down
10 changes: 2 additions & 8 deletions src/popup/router/routes.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
import SessionWelcome from 'common/TmSessionWelcome';
import SessionExplore from 'common/TmSessionExplore';
import SessionSignUp from 'common/TmSessionSignUp';
import SessionSignIn from 'common/TmSessionSignIn';
import SessionHardware from 'common/TmSessionHardware';
import SessionImport from 'common/TmSessionImport';
import SessionAccountDelete from 'common/TmSessionAccountDelete';
import App from '../App';

export default [
{
path: '/',
component: SessionWelcome,
component: App,
},
];
12 changes: 12 additions & 0 deletions test/unit/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"env": {
"mocha": true
},
"globals": {
"expect": true,
"sinon": true,
"beforeAll": false,
"afterAll": false,
"jest": true
}
}
5 changes: 5 additions & 0 deletions test/unit/test.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
describe('TEST', () => {
it('TEST', () => {
expect(true).toBe(true);
});
});
Loading

0 comments on commit aaf0e2b

Please sign in to comment.