Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
chore: allow tests to run in parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain committed Feb 21, 2020
1 parent f88e09d commit 9785a6a
Show file tree
Hide file tree
Showing 12 changed files with 242 additions and 76 deletions.
99 changes: 50 additions & 49 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ branches:
stages:
- check
- test
- tag
- release-rc
- test-external

node_js:
- '10'
Expand All @@ -35,6 +36,10 @@ addons:
- dpkg
chrome: stable

before_install:
# prevents windows error: npm ERR! ... git-sh-setup: file not found
- if [ "$TRAVIS_OS_NAME" = "windows" ]; then export PATH=/c/PROGRA~1/Git/usr/bin:/c/PROGRA~1/Git/mingw64/libexec/git-core:$PATH ; fi

script: npx nyc -s npx aegir test -t node --timeout 10000 --bail
after_success:
- npx nyc report --reporter=text-lcov > coverage.lcov && npx codecov
Expand Down Expand Up @@ -118,46 +123,6 @@ jobs:
script:
- npm run test:interop:electron-renderer -- --bail --timeout 10000

- stage: test
name: external - ipfs-webui
script:
- E2E_IPFSD_TYPE=js npm run test:external -- https://github.com/ipfs-shipyard/ipfs-webui.git --deps=ipfs@github:ipfs/js-ipfs#"${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}"

- stage: test
name: external - ipfs-companion
script:
- npm run test:external -- https://github.com/ipfs-shipyard/ipfs-companion.git --deps=ipfs@github:ipfs/js-ipfs#"${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}"

- stage: test
name: external - npm-on-ipfs
script:
- npm run test:external -- https://github.com/ipfs-shipyard/npm-on-ipfs.git --deps=ipfs@github:ipfs/js-ipfs#"${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}"

- stage: test
name: external - peer-base
script:
- npm run test:external -- https://github.com/achingbrain/peer-base.git --branch upgrade-to-latest-ipfs-rc --deps=ipfs@github:ipfs/js-ipfs#"${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}"

- stage: test
name: external - service-worker-gateway
script:
- npm run test:external -- https://github.com/ipfs-shipyard/service-worker-gateway.git --deps=ipfs@github:ipfs/js-ipfs#"${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}"

- stage: test
name: external - orbit-db
script:
- npm run test:external -- https://github.com/orbitdb/orbit-db.git --deps=ipfs@github:ipfs/js-ipfs#"${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}"

- stage: test
name: external - ipfs-log
script:
- npm run test:external -- https://github.com/orbitdb/ipfs-log.git --deps=ipfs@github:ipfs/js-ipfs#"${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}"

- stage: test
name: external - sidetree
script:
- npm run test:external -- https://github.com/decentralized-identity/sidetree.git --deps=ipfs@github:ipfs/js-ipfs#"${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}"

- stage: test
name: example - browser-add-readable-stream
script:
Expand Down Expand Up @@ -302,15 +267,51 @@ jobs:
- npm install
- npm run test -- traverse-ipld-graphs

- stage: tag
# only run on changes to master
if: branch = master AND type = push AND fork = false
name: update-last-successful-build
- stage: release-rc
name: release rc
script:
- echo "//registry.npmjs.org/:_authToken=\${NPM_TOKEN}" > .npmrc
- npm run release:rc -- --yes

- stage: test-external
name: external - ipfs-webui
script:
- E2E_IPFSD_TYPE=js npm run test:external -- https://github.com/ipfs-shipyard/ipfs-webui.git --deps=ipfs@github:ipfs/js-ipfs#"${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}"

- stage: test-external
name: external - ipfs-companion
script:
- npm run test:external -- https://github.com/ipfs-shipyard/ipfs-companion.git --deps=ipfs@github:ipfs/js-ipfs#"${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}"

- stage: test-external
name: external - npm-on-ipfs
script:
- npm run test:external -- https://github.com/ipfs-shipyard/npm-on-ipfs.git --deps=ipfs@github:ipfs/js-ipfs#"${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}"

- stage: test-external
name: external - peer-base
script:
- npm run test:external -- https://github.com/achingbrain/peer-base.git --branch upgrade-to-latest-ipfs-rc --deps=ipfs@github:ipfs/js-ipfs#"${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}"

- stage: test-external
name: external - service-worker-gateway
script:
- npm run test:external -- https://github.com/ipfs-shipyard/service-worker-gateway.git --deps=ipfs@github:ipfs/js-ipfs#"${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}"

- stage: test-external
name: external - orbit-db
script:
- git config --global user.email "[email protected]"
- git config --global user.name "Travis CI"
- git remote set-url origin https://$TRAVIS_GITHUB_USER:[email protected]/ipfs/js-ipfs.git
- npx aegir update-last-successful-build
- npm run test:external -- https://github.com/orbitdb/orbit-db.git --deps=ipfs@github:ipfs/js-ipfs#"${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}"

- stage: test-external
name: external - ipfs-log
script:
- npm run test:external -- https://github.com/orbitdb/ipfs-log.git --deps=ipfs@github:ipfs/js-ipfs#"${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}"

- stage: test-external
name: external - sidetree
script:
- npm run test:external -- https://github.com/decentralized-identity/sidetree.git --deps=ipfs@github:ipfs/js-ipfs#"${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}"

notifications:
email: false
3 changes: 3 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Contributor Code of Conduct

The `js-ipfs` project follows the [`IPFS Community Code of Conduct`](https://github.com/ipfs/community/blob/master/code-of-conduct.md)
5 changes: 5 additions & 0 deletions LICENSE-APACHE
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
19 changes: 19 additions & 0 deletions LICENSE-MIT
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
130 changes: 130 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
<p align="center">
<a href="https://js.ipfs.io" title="JS IPFS">
<img src="https://ipfs.io/ipfs/Qme6KJdKcp85TYbLxuLV7oQzMiLremD7HMoXLZEmgo6Rnh/js-ipfs-sticker.png" alt="IPFS in JavaScript logo" width="244" />
</a>
</p>

<h3 align="center">The JavaScript implementation of the IPFS protocol.</h3>

<p align="center">
<a href="http://protocol.ai"><img src="https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat" /></a>
<a href="http://ipfs.io/"><img src="https://img.shields.io/badge/project-IPFS-blue.svg?style=flat" /></a>
</p>

<p align="center">
<a href="https://riot.im/app/#/room/#ipfs-dev:matrix.org"><img src="https://img.shields.io/badge/matrix-%23ipfs%3Amatrix.org-blue.svg?style=flat" /> </a>
<a href="http://webchat.freenode.net/?channels=%23ipfs"><img src="https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat" /></a>
<a href="https://discord.gg/24fmuwR"><img src="https://img.shields.io/discord/475789330380488707?color=blueviolet&label=discord&style=flat" /></a>
<a href="https://github.com/ipfs/team-mgmt/blob/master/MGMT_JS_CORE_DEV.md"><img src="https://img.shields.io/badge/team-mgmt-blue.svg?style=flat" /></a>
</p>

<p align="center">
<a href="https://github.com/ipfs/interface-ipfs-core"><img src="https://img.shields.io/badge/interface--ipfs--core-API%20Docs-blue.svg"></a>
<a href="https://travis-ci.com/ipfs/js-ipfs?branch=master"><img src="https://badgen.net/travis/ipfs/js-ipfs?branch=master" /></a>
<a href="https://codecov.io/gh/ipfs/js-ipfs"><img src="https://badgen.net/codecov/c/github/ipfs/js-ipfs" /></a>
<br>
</p>

> **Upgrading from <=0.40 to 0.41?** See the [release notes](https://github.com/ipfs/js-ipfs/issues/2656) for the list of API changes and the [migration guide](https://gist.github.com/alanshaw/04b2ddc35a6fff25c040c011ac6acf26).
### Project status - `Alpha` <!-- omit in toc -->

We've come a long way, but this project is still in Alpha, lots of development is happening, API might change, beware of the Dragons 🐉.

**Want to get started?** Check our [examples folder](/examples) to learn how to spawn an IPFS node in Node.js and in the Browser.

**Please read this:** The [DHT](https://en.wikipedia.org/wiki/Distributed_hash_table), a fundamental piece for automatic content and peer discovery is not yet complete. There are multiple applications that can be built without this service but nevertheless it is fundamental to getting that magic IPFS experience. The current status is that implementation is done and merged and we're working on performance issues. Expect the DHT to be available in a release very soon.

[**`Weekly Core Implementations Call`**](https://github.com/ipfs/team-mgmt/issues/992)

## Tech Lead <!-- omit in toc -->

[David Dias](https://github.com/daviddias)

## Lead Maintainer <!-- omit in toc -->

[Alan Shaw](https://github.com/alanshaw)

## Table of Contents <!-- omit in toc -->

- [Structure](#structure)
- [Development](#development)
- [Clone and install dependencies](#clone-and-install-dependencies)
- [Run tests](#run-tests)
- [Lint](#lint)
- [Build a dist version](#build-a-dist-version)
- [Contribute](#contribute)
- [Want to hack on IPFS?](#want-to-hack-on-ipfs)
- [License](#license)

## Structure

This project is broken into several modules, their purposes are:

* [`/packages/ipfs`](./packages/ipfs) The core implementation
* [`/packages/ipfs-http-client`](./packages/ipfs-http-client) A client for the RPC-over-HTTP API presented by both js-ipfs and go-ipfs
* [`/packages/interface-ipfs-core`](./packages/interface-ipfs-core) Tests to ensure adherance of an implementation to the spec

## Development

### Clone and install dependencies

```sh
> git clone https://github.com/ipfs/js-ipfs.git
> cd js-ipfs
> npm install
```

### Run tests

```sh
# run all the unit tests
> npm test

# run individual tests (findprovs)
> npm run test -- --grep findprovs

# run just IPFS tests in Node.js
> npm run test:node

# run just IPFS tests in a browser
> npm run test:browser

# run just IPFS tests in a webworker
> npm run test:webworker
```

More granular test suites can be run from each submodule.

Please see the `package.json` in each submodule for available commands.

### Lint

**Conforming to linting rules is a prerequisite to commit to js-ipfs.**

```sh
> npm run lint
```

### Build a dist version

```sh
> npm run build
```

## Contribute

IPFS implementation in JavaScript is a work in progress. As such, there's a few things you can do right now to help out:

- Go through the modules below and **check out existing issues**. This would be especially useful for modules in active development. Some knowledge of IPFS may be required, as well as the infrastructure behind it - for instance, you may need to read up on p2p and more complex operations like muxing to be able to help technically.
- **Perform code reviews**. More eyes will help (a) speed the project along, (b) ensure quality, and (c) reduce possible future bugs.
- Take a look at go-ipfs and some of the planning repositories or issues: for instance, the [libp2p spec](https://github.com/ipfs/specs/pull/19). Contributions here that would be most helpful are **top-level comments** about how it should look based on our understanding. Again, the more eyes the better.
- **Add tests**. There can never be enough tests.

### Want to hack on IPFS?

[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md)

## License

[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fipfs%2Fjs-ipfs.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fipfs%2Fjs-ipfs?ref=badge_large)
3 changes: 2 additions & 1 deletion packages/interface-ipfs-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
},
"scripts": {
"lint": "aegir lint",
"clean": "rm -rf ./dist"
"clean": "rm -rf ./dist",
"test": "exit 0"
},
"files": [
"src/",
Expand Down
11 changes: 6 additions & 5 deletions packages/interface-ipfs-core/src/utils/echo-http-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
const http = require('http')
const URL = require('url').URL || self.URL

const defaultPort = 11080

// Create a mock of remote HTTP server that can return arbitrary text in response
// or redirect to other URL. Used in tests of ipfs.addFromURL etc
// It needs to be available to tests run in browsers:
// start it from Node via .aegir.js/hooks/browser/pre|post (example in js-ipfs)
module.exports.createServer = () => {
if (!process.env.ECHO_SERVER_PORT) {
throw new Error('ECHO_SERVER_PORT env var is required')
}

const handler = (req, res) => {
// Relaxed CORS to enable use in tests in web browser with fetch
res.setHeader('Access-Control-Allow-Origin', '*')
Expand Down Expand Up @@ -45,7 +47,7 @@ module.exports.createServer = () => {

server.start = (opts) => new Promise((resolve, reject) => {
server.once('error', reject)
server.listen(Object.assign({ port: defaultPort, host: '127.0.0.1' }, opts), () => {
server.listen(Object.assign({ port: process.env.ECHO_SERVER_PORT, host: '127.0.0.1' }, opts), () => {
server.removeListener('error', reject)
resolve()
})
Expand All @@ -62,7 +64,6 @@ module.exports.createServer = () => {
return server
}

module.exports.defaultPort = defaultPort
module.exports.url = `http://127.0.0.1:${module.exports.defaultPort}`
module.exports.url = `http://127.0.0.1:${process.env.ECHO_SERVER_PORT}`
module.exports.echoUrl = (text) => `${module.exports.url}/echo/${encodeURIComponent(text)}`
module.exports.redirectUrl = (url) => `${module.exports.url}/302/${encodeURI(url)}`
8 changes: 7 additions & 1 deletion packages/ipfs-http-client/.aegir.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,19 @@ const server = createServer({
ipfsBin: require('go-ipfs-dep').path()
})
const echoServer = EchoServer.createServer()
const webpack = require('webpack')

module.exports = {
bundlesize: { maxSize: '90kB' },
webpack: {
resolve: {
mainFields: ['browser', 'main']
}
},
...(process.env.NODE_ENV === 'test' ? {
plugins: [
new webpack.EnvironmentPlugin(['DEBUG', 'ECHO_SERVER_PORT'])
]
} : {})
},
karma: {
files: [{
Expand Down
20 changes: 10 additions & 10 deletions packages/ipfs-http-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
"url": "git+https://github.com/ipfs/js-ipfs.git"
},
"scripts": {
"test": "aegir test",
"test:node": "aegir test -t node",
"test:browser": "aegir test -t browser",
"test:webworker": "aegir test -t webworker",
"test:electron-main": "aegir test -t electron-main",
"test:electron-renderer": "aegir test -t electron-renderer",
"test:chrome": "aegir test -t browser -t webworker -- --browsers ChromeHeadless",
"test:firefox": "aegir test -t browser -t webworker -- --browsers FirefoxHeadless",
"test": "ECHO_SERVER_PORT=37490 aegir test",
"test:node": "ECHO_SERVER_PORT=37491 aegir test -t node",
"test:browser": "ECHO_SERVER_PORT=37492 aegir test -t browser",
"test:webworker": "ECHO_SERVER_PORT=37493 aegir test -t webworker",
"test:electron-main": "ECHO_SERVER_PORT=37494 aegir test -t electron-main",
"test:electron-renderer": "ECHO_SERVER_PORT=37495 aegir test -t electron-renderer",
"test:chrome": "ECHO_SERVER_PORT=37496 aegir test -t browser -t webworker -- --browsers ChromeHeadless",
"test:firefox": "ECHO_SERVER_PORT=37497 aegir test -t browser -t webworker -- --browsers FirefoxHeadless",
"lint": "aegir lint",
"build": "aegir build",
"coverage": "npx nyc -r html npm run test:node -- --bail",
Expand All @@ -46,7 +46,7 @@
"debug": "^4.1.0",
"form-data": "^3.0.0",
"ipfs-block": "^0.8.1",
"ipfs-utils": "^0.7.1",
"ipfs-utils": "^0.7.2",
"ipld-dag-cbor": "^0.15.1",
"ipld-dag-pb": "^0.18.2",
"ipld-raw": "^4.0.1",
Expand All @@ -69,7 +69,7 @@
"async": "^3.1.0",
"browser-process-platform": "^0.1.1",
"go-ipfs-dep": "0.4.23-3",
"interface-ipfs-core": "^0.131.7",
"interface-ipfs-core": "^0.132.0",
"ipfsd-ctl": "^3.0.0",
"it-all": "^1.0.1",
"it-concat": "^1.0.0",
Expand Down
Loading

0 comments on commit 9785a6a

Please sign in to comment.