Skip to content
This repository has been archived by the owner on Dec 31, 2020. It is now read-only.

Commit

Permalink
Add size-limit and Use circleci instead of travis for ci (#675)
Browse files Browse the repository at this point in the history
  • Loading branch information
pustovalov authored and FredyC committed Jun 10, 2019
1 parent 74fa4d7 commit 4904b62
Show file tree
Hide file tree
Showing 8 changed files with 2,752 additions and 58 deletions.
106 changes: 106 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
version: 2.1

executors:
my-executor:
docker:
- image: circleci/node:11
environment:
CI: true
working_directory: ~/mobx-react

jobs:
# mobx-react build
build:
executor: my-executor
steps:
- checkout

- restore_cache:
name: restore .cache/yarn
keys:
- yarn-cache-{{ arch }}
- restore_cache:
name: restore node_modules
keys:
- node-modules-{{ arch }}-{{ .Branch }}-{{ checksum "yarn.lock" }}
- node-modules-{{ arch }}-{{ .Branch }}
- node-modules-{{ arch }}

- run: yarn install --frozen-lockfile --cache-folder ~/.cache/yarn

- save_cache:
name: cache .cache/yarn
key: yarn-cache-{{ arch }}
paths:
- ~/.cache/yarn
- save_cache:
name: cache node_modules
key: node-modules-{{ arch }}-{{ .Branch }}-{{ checksum "yarn.lock" }}
paths:
- node_modules

- run: yarn build

- persist_to_workspace:
root: .
paths:
- ./*

test-mobx-react:
executor: my-executor
steps:
- attach_workspace:
at: .

- run: yarn test:ci
- store_test_results:
path: ./test-results

- persist_to_workspace:
root: .
paths:
- ./coverage

test-size:
executor: my-executor
steps:
- attach_workspace:
at: .

- run: yarn size

# upload coverage
upload-coveralls:
executor: my-executor
steps:
- attach_workspace:
at: .

# only run coveralls if the token is present (it is not present for fork PRs for security reasons)
- run:
name: upload coveralls
command: |
if [[ -v COVERALLS_REPO_TOKEN ]]
then
cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js
echo "Coveralls info uploaded"
else
echo "Warning - Coveralls info could NOT be uploaded since the COVERALLS_REPO_TOKEN was not available"
fi
workflows:
version: 2
build-and-test:
jobs:
- build

- test-mobx-react:
requires:
- build
- test-size:
requires:
- build

- upload-coveralls:
requires:
- test-mobx-react
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
/.source.*
yarn-error.log
.DS_Store
coverage

# files generated by V5
/custom.*
/index.*
/native.*
/native.*
8 changes: 8 additions & 0 deletions .size-limit.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[
{
"path": "dist/mobx-react.js",
"limit": "4 KB",
"webpack": false,
"running": false
}
]
9 changes: 0 additions & 9 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# mobx-react

[![Build Status](https://travis-ci.org/mobxjs/mobx-react.svg?branch=master)](https://travis-ci.org/mobxjs/mobx-react)
[![CircleCI](https://circleci.com/gh/mobxjs/mobx-react.svg?style=svg)](https://circleci.com/gh/mobxjs/mobx-react)
[![Join the chat at https://gitter.im/mobxjs/mobx](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/mobxjs/mobx?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![CDNJS](https://img.shields.io/cdnjs/v/mobx-react.svg)](https://cdnjs.com/libraries/mobx-react)

Expand Down
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
},
"scripts": {
"prettier": "prettier --write \"**/*.js\" \"**/*.ts\"",
"test": "jest && npm run test:ts",
"test": "jest && yarn test:ts",
"test:ts": "tsc -p test/ts",
"test:travis": "npm run build && jest && npm run test:ts",
"test:ci": "jest -i --coverage && yarn test:ts",
"size": "size-limit",
"build": "yarn bundle && shx cp src/index.d.ts dist/mobx-react.d.ts && shx cp dist/mobx-react.module.js dist/mobx-react.rn.module.js && sed -i 's/\"react-dom\"/\"react-native\"/g' dist/mobx-react.rn.module.js",
"bundle": "microbundle --jsx React.createElement --external mobx,react,react-dom,mobx-react-lite --globals react-dom=ReactDOM,react=React,mobx-react-lite=mobxReactLite --name mobxReact",
"watch": "jest --watch"
Expand All @@ -45,6 +46,7 @@
"@types/react": "^16.0.13",
"@types/react-dom": "^16.0.1",
"babel-jest": "^24.1.0",
"coveralls": "^3.0.3",
"create-react-class": "^15.6.2",
"husky": "^1.0.0",
"jest": "^24.0.0",
Expand All @@ -61,6 +63,7 @@
"request": "^2.83.0",
"shelljs": "^0.8.3",
"shx": "^0.3.2",
"size-limit": "^1.3.2",
"typescript": "^2.6.0"
},
"dependencies": {
Expand Down Expand Up @@ -91,4 +94,4 @@
"pre-commit": "lint-staged"
}
}
}
}
14 changes: 5 additions & 9 deletions src/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,10 @@ const hoistBlackList = {
}

export function copyStaticProperties(base, target) {
const protoProps = Object.getOwnPropertyNames(Object.getPrototypeOf(base));
const protoProps = Object.getOwnPropertyNames(Object.getPrototypeOf(base))
Object.getOwnPropertyNames(base).forEach(key => {
if (!hoistBlackList[key] && !protoProps.includes(key)) {
Object.defineProperty(
target,
key,
Object.getOwnPropertyDescriptor(base, key)
);
}
});
if (!hoistBlackList[key] && !protoProps.includes(key)) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(base, key))
}
})
}
Loading

0 comments on commit 4904b62

Please sign in to comment.