Skip to content
This repository has been archived by the owner on Sep 20, 2023. It is now read-only.

Commit

Permalink
Enable hoisting and integration tests (#1041)
Browse files Browse the repository at this point in the history
* Sync @babel/core

* Sync @babel/preset-env

* Sync @babel/register

* Sync nodemon

* Sync EnvKey

* Sync bignumber.js

* Sync @babel/cli

* Sync chai-bignumber

* Sync ajv

* Sync sequelize

* Sync cors

* Sync webpack

* Sync express

* Sync dotenv

* Sync react-scripts

* Sync redux

* Add package-lock for mobile

* Sync react

* Sync form-data

* Sync logplease

* Sync moment

* Sync babel-loader

* Sync html-webpack-plugin

* Sync reeact-dom

* Sync react-router-dom

* Update root package lock

* Remove relative imports from origin-contracts

* Sync web3

* Update docker ignore

* Use single image for origin-box

* Add missing package locks

* Update to always use --ci

* Add --progress flag

* Update lock files

* Add root package lock

* Add Dockerfile

* Update lockfiles for hoist

* Update packages

* Update lock files

* Hoisted package lock

* Fixes

* Ganache-core upgrade

* Fixes

* Remove debug console log

* Put call back

* Travis test

* Test should be matrix

* Unset CI for hoist

* CI test

* Test workaround

* Test CI

* Test  --abort-on-container-exit flag

* Add stderr redirect

* Container fixes

* Add tests package

* Fix syntax

* Fix Ganache version

* Pin web3 to beta.34 everywhere

* Add linting to tests

* Sync deps

* Update command to start integration tests

* Fix paths in docker compose

* Move tests to top level directory

* Add compose test file

* Add chai, mocha, eslint as top level dependencies

* Fix script copy

* Mount more directories inside containers for development

* Fix env vars for origin container update

* Update sequelize versions

* Add first integration test for origin-box

* Add Docker caching

* Add missing docker file reference

* Delay for event-listener to process blocks

* Use assert.equal

* Only cache origin container

* Remove relative import for origin-js test

* Add --cache-from argument

* Remove debugging log

* Try parallel tests

* Add --quiet-pull flag

* Fix --quiet flag

* CI test

* Linting fixes

* Make linting work with dev only dependencies

* Minor fixes

* Improve efficiency of unit test install

* Fix path

* Fix filter

* Separate out unit tests

* Add mocha

* Remove caching

* TravisCI tweaks

* Remove unused faucet

* Test links

* Convert to package again

* Remove prepare step

* Revert "Remove prepare step"

This reverts commit 5088cf5.

* Fix import

* Make postinstall script work

* Fix package locks

* Rename test folder

* Remove unncessary contract build

* Fixes for volume paths

* Lock file change

* Rename files

* Rename container

* Revert "Remove unncessary contract build"

This reverts commit 37b60e6.

* Rename test

* Fix import

* Move integration tests to the top of TravisCI file so they run first

* Documentation

* Fixes for contracts

* Add wait for event listener

* Fix timing

* Update docs

* Increase time for event-listener

* Updates to deployment containers

* Remove unnecessary contract compile

* Remove build step for contracts when NODE_ENV=production

* Move lerna to production dependencies

* Make ipfs-proxy handle ctrl+c

* Update lockfile

* Revert experimental package files

* Sync packages

* More package syncing

* Package lock for discovery

* Remove stray blank line

* Update dockerignore

* Remove unused import

* Change license to MIT

* Fix duplicate volume entry

* Package upgrades

* Add todo

* Increase wait for event-listener
  • Loading branch information
Tom Linton committed Dec 6, 2018
1 parent 6dc7bf4 commit d001796
Show file tree
Hide file tree
Showing 81 changed files with 7,114 additions and 189,241 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
@@ -1,3 +1,6 @@
**/node_modules

# build folders
origin-dapp/build
origin-js/dist
origin-messaging/dist
71 changes: 0 additions & 71 deletions .eslintrc

This file was deleted.

60 changes: 60 additions & 0 deletions .eslintrc.js
@@ -0,0 +1,60 @@
module.exports = {
'root': true,
'parser': 'babel-eslint',
'parserOptions': {
'ecmaVersion': 6,
'sourceType': 'module',
'ecmaFeatures': {
'jsx': true,
'impliedStrict': true
}
},
'env': {
'browser': true,
'node': true,
'es6': true,
'mocha': true
},
'extends': [
'eslint:recommended'
],
'rules': {
'computed-property-spacing': [
'error'
],
'jsx-quotes': [
'error'
],
'key-spacing': [
'error'
],
'no-case-declarations': [
'off'
],
'no-console': [
'off'
],
'no-var': [
'error'
],
'object-curly-spacing': [
'error',
'always'
],
'prefer-const': [
'error'
],
'quotes': [
'error',
'single',
{
'avoidEscape': true,
'allowTemplateLiterals': true
}
],
'semi': [
'error',
'never'
]
}
}
105 changes: 31 additions & 74 deletions .travis.yml
@@ -1,54 +1,53 @@
---
git:
depth: 3
depth: 1
matrix:
include:
- name: "origin-bridge tests"
language: python
python: 3.6
# Run integration tests using docker compose
- name: "integration tests"
language: minimal
sudo: true
before_script:
- cd origin-bridge
- pip install -r requirements.txt
# Setting required for Elasticsearch to run
- sudo sysctl -w vm.max_map_count=262144
script:
- pytest --flakes --codestyle
- docker-compose -f docker-compose.yml -f docker-compose.test.yml up --exit-code-from origin-tests

- name: "origin-contracts tests"
- name: "javascript linting"
language: node_js
node_js: 10
cache:
npm: true
directories:
- origin-contracts/node_modules
- node_modules
before_cache:
- rm -rf origin-contracts/node_modules/.cache
- rm -rf node_modules/.cache
install:
- npm install --ignore-scripts
- npm run bootstrap -- --scope origin-contracts
- npm install --loglevel notice --dev-only --ignore-scripts
script:
- npm run test --prefix origin-contracts
- npm run lint

- name: "origin-bridge unit tests"
language: python
python: 3.6
before_script:
- cd origin-bridge
- pip install -r requirements.txt
script:
- pytest --flakes --codestyle

- name: "origin-dapp tests"
- name: "origin-contracts unit tests"
language: node_js
node_js: 10
install:
- npm install --ignore-scripts
- npm run bootstrap -- --scope origin-dapp
- npm run bootstrap -- --scope origin-contracts
script:
- npm run lint --prefix origin-dapp
- npm run test --prefix origin-contracts

- name: "origin-discovery tests"
- name: "origin-discovery unit tests"
language: node_js
node_js: 10
cache:
npm: true
directories:
- origin-contracts/node_modules
- origin-js/node_modules
- origin-discovery/node_modules
before_cache:
- rm -rf origin-contracts/node_modules/.cache
- rm -rf origin-js/node_modules/.cache
- rm -rf origin-discovery/node_modules/.cache
addons:
postgresql: 9.6
services:
Expand All @@ -60,67 +59,25 @@ matrix:
- lerna run migrate --scope origin-discovery
install:
- npm install --ignore-scripts
- npm run bootstrap -- --scope origin-contracts
- npm run bootstrap -- --scope origin
- npm run bootstrap -- --scope origin-discovery
- npm run bootstrap -- --scope origin-contracts --scope origin --scope origin-discovery
script:
- npm run lint --prefix origin-discovery
- npm run test --prefix origin-discovery

- name: "origin-js tests"
- name: "origin-js unit tests"
language: node_js
node_js: 10
cache:
npm: true
directories:
- origin-contracts/node_modules
- origin-js/node_modules
before_cache:
- rm -rf origin-contracts/node_modules/.cache
- rm -rf origin-js/node_modules/.cache
install:
- npm install --ignore-scripts
- npm run bootstrap -- --scope origin-contracts
- npm run bootstrap -- --scope origin
- npm run bootstrap -- --scope origin-contracts --scope origin
script:
- npm run lint --prefix origin-js
- npm run test --prefix origin-js

- name: "origin-messaging tests"
language: node_js
node_js: 10
install:
- npm install --ignore-scripts
- npm run bootstrap -- --scope origin-messaging
script:
- npm run lint --prefix origin-messaging

- name: "origin-notifications tests"
- name: "origin-token-transfer unit tests"
language: node_js
node_js: 10
install:
- npm install --ignore-scripts
- npm run bootstrap -- --scope origin-notifications
script:
- npm run lint --prefix origin-notifications

- name: "origin-token-transfer tests"
language: node_js
node_js: 10
cache:
npm: true
directories:
- origin-token-transfer/client/node_modules
- origin-token-transfer/server/node_modules
before_cache:
- rm -rf origin-token-transfer/client/node_modules/.cache
- rm -rf origin-token-transfer/server/node_modules/.cache
install:
- npm install --ignore-scripts
- npm run bootstrap -- --scope origin-token-transfer-client
- npm run bootstrap -- --scope origin-token-transfer-server
- npm run bootstrap -- --scope origin-token-transfer-client --scope origin-token-transfer-server
script:
- npm run lint --prefix origin-token-transfer/server
- npm run test --prefix origin-token-transfer/server
- npm run lint --prefix origin-token-transfer/client
- npm run test --prefix origin-token-transfer/client
6 changes: 4 additions & 2 deletions DEVELOPMENT.md
@@ -1,6 +1,4 @@
![origin_github_banner](https://user-images.githubusercontent.com/673455/37314301-f8db9a90-2618-11e8-8fee-b44f38febf38.png)
[![origin_license](https://img.shields.io/badge/license-MIT-6e3bea.svg?style=flat-square&colorA=111d28)](https://github.com/OriginProtocol/origin/blob/master/origin-dapp/LICENSE)
[![origin_travis_banner](https://img.shields.io/travis/OriginProtocol/origin-dapp/master.svg?style=flat-square&colorA=111d28)](https://travis-ci.org/OriginProtocol/origin-dapp)

Head to https://www.originprotocol.com/developers to learn more about what we're building and how to get involved.

Expand All @@ -10,6 +8,10 @@ Origin has two development setups. One is the "light" version and consists of on

The more full featured development environment uses Docker Compose to orchestrate several containers and provides access to the full suite of Origin feaetures, include messaging, browser notifications, and attestation services.

## About the Origin repository

Origin uses a monorepo setup that is managed by `lerna`. The `--hoist` flag of `lerna` is used to pull common depdencies to the root of the monorepo on installation.

## Using NPM & Lerna

1. Check out the repository from GitHub and make sure you have installed all the necessary dependencies:
Expand Down
42 changes: 42 additions & 0 deletions Dockerfile
@@ -0,0 +1,42 @@
FROM node:10

WORKDIR /app

# Copy utility scripts
COPY ./development/scripts/* /usr/local/bin/

COPY ./scripts/ ./scripts/

# Copy all package files for dependency installs, this is done here to allow
# Docker to cache the npm install steps if none of the dependencies have changed
COPY ./lerna.json ./
COPY ./package*.json ./
COPY ./ipfs-proxy/package*.json ./ipfs-proxy/
COPY ./origin-dapp/package*.json ./origin-dapp/
COPY ./origin-discovery/package*.json ./origin-discovery/
COPY ./origin-js/package*.json ./origin-js/
COPY ./origin-messaging/package*.json ./origin-messaging/
COPY ./origin-notifications/package*.json ./origin-notifications/
COPY ./origin-tests/package*.json ./origin-tests/

# Complete contracts source needs to be available so that `truffle compile contracts`
# which is calleed by the prepare script can succeed
COPY ./origin-contracts ./origin-contracts

# Running of postinstall script requires --unsafe-perm
RUN npm install --unsafe-perm

# Copy all the source files for the packages
COPY ./ipfs-proxy ./ipfs-proxy
COPY ./origin-dapp ./origin-dapp
COPY ./origin-discovery ./origin-discovery
COPY ./origin-js ./origin-js
COPY ./origin-messaging ./origin-messaging
COPY ./origin-notifications ./origin-notifications
COPY ./origin-tests ./origin-tests

RUN ln -s ../../node_modules/scrypt origin-js/node_modules/scrypt
RUN ln -s ../../node_modules/got origin-js/node_modules/got

# Build origin-js for event-listener
RUN npm run build --prefix origin-js
33 changes: 33 additions & 0 deletions TESTING.md
@@ -0,0 +1,33 @@
![origin_github_banner](https://user-images.githubusercontent.com/673455/37314301-f8db9a90-2618-11e8-8fee-b44f38febf38.png)

Head to https://www.originprotocol.com/developers to learn more about what we're building and how to get involved.

# Testing

This describes Origin's automated test setup. Linting, unit testing, and integration testing is run by TravisCI on each push or pull request.

## Linting

Linting is handled by `eslint`. The root of the repository contains a base eslint config in `.eslintrc.js` which can be imported and extended by the Origin packages. For an example of extending this base config to support React see `origin-dapp/.eslintrc.js`.

## Unit Testing

Each package implements its own unit tests that should be runnable by using `lerna run test --scope <package_name>` from root or `npm run test` from within the package directory.

## Integration Testing

Integration testing is provided by the `origin-tests` package. It uses the Docker Compose setup to run Origin components and then executes tests against those services. The available services and their addresses are:

```
- ipfs-proxy on http://ipfs-proxy:9999 (also localhost)
- origin-bridge on http://origin-bridge:5000 (also localhost)
- origin-dapp on http://origin-dapp:3000 (also localhost)
- origin-discovery (event-listener)
- origin-discovery (apollo server on http://localhost:4000)
- origin-messaging on http://origin-messaging:9012 (also localhost)
- origin-notifications on http://origin-notifications:3456 (also localhost)
- ipfs at http://origin:5002 (gateway) and http://origin:8080 (api)
- ganache at http://origin:8545 (also localhost)
- postgresql at postgres://origin:origin@postgres/origin
- elasticsearch on http://elasticearch:9200 (also localhost)
```

0 comments on commit d001796

Please sign in to comment.