diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 000000000..7fe002d3c --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,97 @@ +version: 2 +# 2.1 does not yet support local run +# unless with workaround. For simplicity just use it. +# https://github.com/CircleCI-Public/circleci-cli/issues/79 + +jobs: + build: + docker: + - image: circleci/node:8 + working_directory: ~/project + steps: + - checkout + - attach_workspace: + at: ~/project + # Download and cache dependencies + - restore_cache: + keys: + - v1-dependencies-{{ checksum "package-lock.json" }} + # fallback to using the latest cache if no exact match is found + - v1-dependencies- + - run: + name: Install npm dependencies + command: npm install + + - save_cache: + paths: + - node_modules + key: v1-dependencies-{{ checksum "package-lock.json" }} + + lint: + docker: + - image: circleci/node:8 + working_directory: ~/project + steps: + - checkout + - attach_workspace: + at: ~/project + - restore_cache: + keys: + - v1-dependencies-{{ checksum "package-lock.json" }} + # fallback to using the latest cache if no exact match is found + - v1-dependencies- + - run: + name: Linter + command: npm run lint + test: + docker: + - image: circleci/node:8 + working_directory: ~/project + steps: + - checkout + - attach_workspace: + at: ~/project + - restore_cache: + keys: + - v1-dependencies-{{ checksum "package-lock.json" }} + # fallback to using the latest cache if no exact match is found + - v1-dependencies- + - run: + name: Unit tests + command: npm run test + coverage: + docker: + - image: circleci/node:8 + working_directory: ~/project + steps: + - checkout + - attach_workspace: + at: ~/project + - restore_cache: + keys: + - v1-dependencies-{{ checksum "package-lock.json" }} + # fallback to using the latest cache if no exact match is found + - v1-dependencies- + - run: + name: Unit tests with coverage report + command: npm run test + environment: + SOLIDITY_COVERAGE: true + + # TODO(xinbenlv, #1839): run SOLC_NIGHTLY to be run but allow it to fail. + # TODO(xinbenlv, #1839): requires SLACK WEBHOOK to be setup by repo owner. + +workflows: + version: 2 + everything: + jobs: + - build + - lint: + requires: + - build + - test: + requires: + - build + - coverage: + requires: + - build diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 76e2c35bd..dd7c37637 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -37,12 +37,26 @@ git commit "Fix some bug #123" git push origin fix/some-bug-#123 ``` -4) Go to [github.com/OpenZeppelin/openzeppelin-contracts](https://github.com/OpenZeppelin/openzeppelin-contracts) in your web browser and issue a new pull request. +4) Run tests, linter etc. It can be done by running local continuous integration and make sure it pass + +```bash +npm test +npm linter +``` + +or you can simply run CircleCI locally +```bash +circleci local execute --job build +circleci local execute --job test +``` +*Note*: requires installing CircleCI and docker locally on your machine. + +5) Go to [github.com/OpenZeppelin/openzeppelin-contracts](https://github.com/OpenZeppelin/openzeppelin-contracts) in your web browser and issue a new pull request. *IMPORTANT* Read the PR template very carefully and make sure to follow all the instructions. These instructions refer to some very important conditions that your PR must meet in order to be accepted, such as making sure that all tests pass, JS linting tests pass, solidity linting tests pass, etc. -5) Maintainers will review your code and possibly ask for changes before your code is pulled in to the main repository. We'll check that all tests pass, review the coding style, and check for general code correctness. If everything is OK, we'll merge your pull request and your code will be part of OpenZeppelin. +6) Maintainers will review your code and possibly ask for changes before your code is pulled in to the main repository. We'll check that all tests pass, review the coding style, and check for general code correctness. If everything is OK, we'll merge your pull request and your code will be part of OpenZeppelin. *IMPORTANT* Please pay attention to the maintainer's feedback, since its a necessary step to keep up with the standards OpenZeppelin attains to.