-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updates aegir, fixes linting errors and updates project config & docs.
- Loading branch information
1 parent
018257f
commit c078e7d
Showing
12 changed files
with
155 additions
and
284 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,181 +1,25 @@ | ||
name: test & maybe release | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
|
||
check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: lts/* | ||
- uses: ipfs/aegir/actions/cache-node-modules@master | ||
- run: npm run --if-present lint | ||
- run: npm run --if-present dep-check | ||
|
||
test-node: | ||
needs: check | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [windows-latest, ubuntu-latest, macos-latest] | ||
node: [lts/*] | ||
fail-fast: true | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node }} | ||
- uses: ipfs/aegir/actions/cache-node-modules@master | ||
- run: npm run --if-present test:node | ||
- uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1 | ||
with: | ||
flags: node | ||
|
||
test-chrome: | ||
needs: check | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: lts/* | ||
- uses: ipfs/aegir/actions/cache-node-modules@master | ||
- run: npm run --if-present test:chrome | ||
- uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1 | ||
with: | ||
flags: chrome | ||
|
||
test-chrome-webworker: | ||
needs: check | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: lts/* | ||
- uses: ipfs/aegir/actions/cache-node-modules@master | ||
- run: npm run --if-present test:chrome-webworker | ||
- uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1 | ||
with: | ||
flags: chrome-webworker | ||
permissions: | ||
contents: write | ||
packages: write | ||
|
||
test-firefox: | ||
needs: check | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: lts/* | ||
- uses: ipfs/aegir/actions/cache-node-modules@master | ||
- run: npm run --if-present test:firefox | ||
- uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1 | ||
with: | ||
flags: firefox | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event_name == 'push' && github.sha || github.ref }} | ||
cancel-in-progress: true | ||
|
||
test-firefox-webworker: | ||
needs: check | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: lts/* | ||
- uses: ipfs/aegir/actions/cache-node-modules@master | ||
- run: npm run --if-present test:firefox-webworker | ||
- uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1 | ||
with: | ||
flags: firefox-webworker | ||
|
||
test-webkit: | ||
needs: check | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, macos-latest] | ||
node: [lts/*] | ||
fail-fast: true | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: lts/* | ||
- uses: ipfs/aegir/actions/cache-node-modules@master | ||
- run: npm run --if-present test:webkit | ||
- uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1 | ||
with: | ||
flags: webkit | ||
|
||
test-webkit-webworker: | ||
needs: check | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, macos-latest] | ||
node: [lts/*] | ||
fail-fast: true | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: lts/* | ||
- uses: ipfs/aegir/actions/cache-node-modules@master | ||
- run: npm run --if-present test:webkit-webworker | ||
- uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1 | ||
with: | ||
flags: webkit-webworker | ||
|
||
test-electron-main: | ||
needs: check | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: lts/* | ||
- uses: ipfs/aegir/actions/cache-node-modules@master | ||
- run: npx xvfb-maybe npm run --if-present test:electron-main | ||
- uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1 | ||
with: | ||
flags: electron-main | ||
|
||
test-electron-renderer: | ||
needs: check | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: lts/* | ||
- uses: ipfs/aegir/actions/cache-node-modules@master | ||
- run: npx xvfb-maybe npm run --if-present test:electron-renderer | ||
- uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1 | ||
with: | ||
flags: electron-renderer | ||
|
||
release: | ||
needs: [test-node, test-chrome, test-chrome-webworker, test-firefox, test-firefox-webworker, test-webkit, test-webkit-webworker, test-electron-main, test-electron-renderer] | ||
runs-on: ubuntu-latest | ||
if: github.event_name == 'push' && github.ref == 'refs/heads/master' | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: lts/* | ||
- uses: ipfs/aegir/actions/cache-node-modules@master | ||
- uses: ipfs/aegir/actions/docker-login@master | ||
with: | ||
docker-token: ${{ secrets.DOCKER_TOKEN }} | ||
docker-username: ${{ secrets.DOCKER_USERNAME }} | ||
- run: npm run --if-present release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.UCI_GITHUB_TOKEN || github.token }} | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
jobs: | ||
js-test-and-release: | ||
uses: pl-strflt/uci/.github/workflows/[email protected] | ||
secrets: | ||
DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }} | ||
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
UCI_GITHUB_TOKEN: ${{ secrets.UCI_GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
name: Semantic PR | ||
|
||
on: | ||
pull_request_target: | ||
types: | ||
- opened | ||
- edited | ||
- synchronize | ||
|
||
jobs: | ||
main: | ||
uses: pl-strflt/.github/.github/workflows/[email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name: Close and mark stale issue | ||
|
||
on: | ||
schedule: | ||
- cron: '0 0 * * *' | ||
|
||
permissions: | ||
issues: write | ||
pull-requests: write | ||
|
||
jobs: | ||
stale: | ||
uses: pl-strflt/.github/.github/workflows/[email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,116 +1,33 @@ | ||
# @chainsafe/libp2p-yamux <!-- omit in toc --> | ||
|
||
[![codecov](https://img.shields.io/codecov/c/github/ChainSafe/js-libp2p-yamux.svg?style=flat-square)](https://codecov.io/gh/ChainSafe/js-libp2p-yamux) | ||
[![CI](https://img.shields.io/github/actions/workflow/status/ChainSafe/js-libp2p-yamux/js-test-and-release.yml?branch=master\&style=flat-square)](https://github.com/ChainSafe/js-libp2p-yamux/actions/workflows/js-test-and-release.yml?query=branch%3Amaster) | ||
|
||
> Yamux stream multiplexer for libp2p | ||
## Table of contents <!-- omit in toc --> | ||
|
||
- [Install](#install) | ||
- [Browser `<script>` tag](#browser-script-tag) | ||
- [Usage](#usage) | ||
- [API](#api) | ||
- [Contribute](#contribute) | ||
- [API Docs](#api-docs) | ||
- [License](#license) | ||
- [Contribution](#contribution) | ||
|
||
## Install | ||
# Install | ||
|
||
```console | ||
$ npm i @chainsafe/libp2p-yamux | ||
``` | ||
|
||
### Browser `<script>` tag | ||
## Browser `<script>` tag | ||
|
||
Loading this module through a script tag will make it's exports available as `ChainsafeLibp2pYamux` in the global namespace. | ||
|
||
```html | ||
<script src="https://unpkg.com/@chainsafe/libp2p-yamux/dist/index.min.js"></script> | ||
``` | ||
|
||
## Usage | ||
|
||
```js | ||
import { yamux } from '@chainsafe/libp2p-yamux' | ||
import { pipe } from 'it-pipe' | ||
import { duplexPair } from 'it-pair/duplex' | ||
import all from 'it-all' | ||
|
||
// Connect two yamux muxers to demo basic stream multiplexing functionality | ||
|
||
const clientMuxer = yamux({ | ||
client: true, | ||
onIncomingStream: stream => { | ||
// echo data on incoming streams | ||
pipe(stream, stream) | ||
}, | ||
onStreamEnd: stream => { | ||
// do nothing | ||
} | ||
})() | ||
|
||
const serverMuxer = yamux({ | ||
client: false, | ||
onIncomingStream: stream => { | ||
// echo data on incoming streams | ||
pipe(stream, stream) | ||
}, | ||
onStreamEnd: stream => { | ||
// do nothing | ||
} | ||
})() | ||
|
||
// `p` is our "connections", what we use to connect the two sides | ||
// In a real application, a connection is usually to a remote computer | ||
const p = duplexPair() | ||
|
||
// connect the muxers together | ||
pipe(p[0], clientMuxer, p[0]) | ||
pipe(p[1], serverMuxer, p[1]) | ||
|
||
// now either side can open streams | ||
const stream0 = clientMuxer.newStream() | ||
const stream1 = serverMuxer.newStream() | ||
|
||
// Send some data to the other side | ||
const encoder = new TextEncoder() | ||
const data = [encoder.encode('hello'), encoder.encode('world')] | ||
pipe(data, stream0) | ||
|
||
// Receive data back | ||
const result = await pipe(stream0, all) | ||
|
||
// close a stream | ||
stream1.close() | ||
|
||
// close the muxer | ||
clientMuxer.close() | ||
``` | ||
|
||
## API | ||
|
||
This library implements the `StreamMuxerFactory`, `StreamMuxer` and `Stream` interfaces defined in [`@libp2p/interfaces/stream-muxer`](https://github.com/libp2p/js-libp2p-interfaces/tree/master/packages/libp2p-interfaces/src/stream-muxer). | ||
|
||
## Contribute | ||
|
||
The libp2p implementation in JavaScript is a work in progress. As such, there are a few things you can do right now to help out: | ||
|
||
- Go through the modules and **check out existing issues**. This is especially useful for modules in active development. Some knowledge of IPFS/libp2p 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. | ||
|
||
## API Docs | ||
# API Docs | ||
|
||
- <https://ChainSafe.github.io/js-libp2p-yamux> | ||
|
||
## License | ||
# License | ||
|
||
Licensed under either of | ||
|
||
- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>) | ||
- MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>) | ||
|
||
## Contribution | ||
# Contribution | ||
|
||
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.