diff --git a/.github/workflows/js-test-and-release.yml b/.github/workflows/js-test-and-release.yml index 2c7a14b..2e3db88 100644 --- a/.github/workflows/js-test-and-release.yml +++ b/.github/workflows/js-test-and-release.yml @@ -3,7 +3,7 @@ name: test & maybe release on: push: branches: - - master + - main pull_request: workflow_dispatch: @@ -16,10 +16,189 @@ concurrency: cancel-in-progress: true jobs: - js-test-and-release: - uses: pl-strflt/uci/.github/workflows/js-test-and-release.yml@v0.0 - secrets: - DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }} - DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - UCI_GITHUB_TOKEN: ${{ secrets.UCI_GITHUB_TOKEN }} + 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 + - run: npm run --if-present doc-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@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4 + with: + flags: node + files: .coverage/*,packages/*/.coverage/* + + 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@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4 + with: + flags: chrome + files: .coverage/*,packages/*/.coverage/* + + 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@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4 + with: + flags: chrome-webworker + files: .coverage/*,packages/*/.coverage/* + + 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@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4 + with: + flags: firefox + files: .coverage/*,packages/*/.coverage/* + + 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@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4 + with: + flags: firefox-webworker + files: .coverage/*,packages/*/.coverage/* + + 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@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4 + with: + flags: webkit + files: .coverage/*,packages/*/.coverage/* + + 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@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4 + with: + flags: webkit-webworker + files: .coverage/*,packages/*/.coverage/* + + 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@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4 + with: + flags: electron-main + files: .coverage/*,packages/*/.coverage/* + + 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@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4 + with: + flags: electron-renderer + files: .coverage/*,packages/*/.coverage/* + + 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/main' + permissions: + id-token: write + contents: write + pull-requests: write + 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 }} diff --git a/README.md b/README.md index cd15acf..56efaa3 100644 --- a/README.md +++ b/README.md @@ -1,31 +1,15 @@ -# @libp2p/interop - [![libp2p.io](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](http://libp2p.io/) [![Discuss](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg?style=flat-square)](https://discuss.libp2p.io) [![codecov](https://img.shields.io/codecov/c/github/libp2p/interop.svg?style=flat-square)](https://codecov.io/gh/libp2p/interop) -[![CI](https://img.shields.io/github/actions/workflow/status/libp2p/interop/js-test-and-release.yml?branch=master\&style=flat-square)](https://github.com/libp2p/interop/actions/workflows/js-test-and-release.yml?query=branch%3Amaster) +[![CI](https://img.shields.io/github/actions/workflow/status/libp2p/interop/js-test-and-release.yml?branch=main\&style=flat-square)](https://github.com/libp2p/interop/actions/workflows/js-test-and-release.yml?query=branch%3Amain) > Interoperability Tests for libp2p -## Table of contents - -- [Install](#install) -- [Usage](#usage) - - [Running the tests](#running-the-tests) -- [License](#license) -- [Contribution](#contribution) - -## Install - -```console -$ npm i @libp2p/interop -``` +# About -This repository will be used for interop tests. +This repository holds interop tests for testing compatibility between different libp2p implementations. -## Usage - -### Running the tests +## Example - How to run the tests Create a js file that configures the different types of daemon: @@ -63,13 +47,19 @@ main().catch(err => { For an example, see the js-libp2p interop test runner. -## License +# Install + +```console +$ npm i @libp2p/interop +``` + +# License Licensed under either of - Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) - MIT ([LICENSE-MIT](LICENSE-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. diff --git a/package.json b/package.json index 57edf63..7228f25 100644 --- a/package.json +++ b/package.json @@ -11,13 +11,13 @@ "bugs": { "url": "https://github.com/libp2p/interop/issues" }, + "publishConfig": { + "access": "public", + "provenance": true + }, "keywords": [ "libp2p" ], - "engines": { - "node": ">=16.0.0", - "npm": ">=7.0.0" - }, "type": "module", "types": "./dist/src/index.d.ts", "files": [ @@ -35,12 +35,13 @@ "eslintConfig": { "extends": "ipfs", "parserOptions": { + "project": true, "sourceType": "module" } }, "release": { "branches": [ - "master" + "main" ], "plugins": [ [ @@ -130,7 +131,8 @@ "dep-check": "aegir dep-check", "build": "aegir build --bundle false", "postbuild": "cp src/resources/keys/*.key dist/src/resources/keys", - "release": "aegir release" + "release": "aegir release", + "docs": "aegir docs" }, "dependencies": { "@libp2p/daemon-client": "^7.0.0", @@ -141,8 +143,8 @@ "it-all": "^3.0.1", "it-first": "^3.0.1", "it-handshake": "^4.1.2", - "it-protobuf-stream": "^1.0.0", "it-pipe": "^3.0.0", + "it-protobuf-stream": "^1.0.0", "it-stream-types": "^2.0.1", "multiformats": "^12.0.1", "p-defer": "^4.0.0", @@ -153,7 +155,7 @@ "uint8arrays": "^4.0.2" }, "devDependencies": { - "aegir": "^40.0.8", + "aegir": "^41.1.11", "protons": "^7.0.2" }, "peerDependencies": { diff --git a/src/index.ts b/src/index.ts index 1dceb1d..ee08027 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,3 +1,47 @@ +/** + * @packageDocumentation + * + * This repository holds interop tests for testing compatibility between different libp2p implementations. + * + * @example How to run the tests + * + * Create a js file that configures the different types of daemon: + * + * ```js + * import { interopTests } from '@libp2p/interop' + * import type { Daemon, DaemonFactory } from '@libp2p/interop' + * + * async function createGoPeer (options: SpawnOptions): Promise { + * // your implementation here + * } + * + * async function createJsPeer (options: SpawnOptions): Promise { + * // your implementation here + * } + * + * async function main () { + * const factory: DaemonFactory = { + * async spawn (options: SpawnOptions) { + * if (options.type === 'go') { + * return createGoPeer(options) + * } + * + * return createJsPeer(options) + * } + * } + * + * interopTests(factory) + * } + * + * main().catch(err => { + * console.error(err) + * process.exit(1) + * }) + * ``` + * + * For an example, see the js-libp2p interop test runner. + */ + import { connectTests } from './connect.js' import { dhtTests } from './dht/index.js' import { pubsubTests } from './pubsub/index.js' @@ -6,7 +50,7 @@ import { streamTests } from './streams/index.js' import type { DaemonClient } from '@libp2p/daemon-client' export interface Daemon { - stop: () => Promise + stop(): Promise client: DaemonClient } @@ -30,7 +74,7 @@ export interface SpawnOptions { } export interface DaemonFactory { - spawn: (options: SpawnOptions) => Promise + spawn(options: SpawnOptions): Promise } export async function interopTests (factory: DaemonFactory): Promise { diff --git a/typedoc.json b/typedoc.json new file mode 100644 index 0000000..f599dc7 --- /dev/null +++ b/typedoc.json @@ -0,0 +1,5 @@ +{ + "entryPoints": [ + "./src/index.ts" + ] +}