From a674e4a8f6bcf7c5c14aaf14e98a25a4f65db001 Mon Sep 17 00:00:00 2001 From: Vasco Santos Date: Wed, 2 Dec 2020 17:27:59 +0100 Subject: [PATCH] chore: minor fixes and github ci --- .github/workflows/main.yml | 67 ++++++++++++++++++++++++++++++++++++++ .travis.yml | 59 --------------------------------- package.json | 4 +-- src/transport-manager.js | 1 - src/upgrader.js | 6 ++-- tsconfig.json | 16 +-------- 6 files changed, 72 insertions(+), 81 deletions(-) create mode 100644 .github/workflows/main.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000000..0422d85a8a --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,67 @@ +name: ci +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: yarn + - run: yarn lint + - run: yarn build + - uses: gozala/typescript-error-reporter-action@v1.0.4 + - run: yarn aegir dep-check -- -i aegir + - uses: ipfs/aegir/actions/bundle-size@master + name: size + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + test-node: + needs: check + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest] + node: [12, 14] + fail-fast: true + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node }} + - run: yarn + - run: npx nyc --reporter=lcov npm run test:node -- --bail + - uses: codecov/codecov-action@v1 + test-chrome: + needs: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: yarn + - run: yarn aegir test -t browser -t webworker + test-firefox: + needs: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: yarn + - run: yarn aegir test -t browser -t webworker -- --browsers FirefoxHeadless + test-electron-main: + needs: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: yarn + - run: npx xvfb-maybe yarn aegir test -t electron-main --bail + test-electron-renderer: + needs: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: yarn + - run: npx xvfb-maybe yarn aegir test -t electron-renderer --bail \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index b4bbfc1855..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,59 +0,0 @@ -language: node_js -cache: npm -stages: - - check - - test - - cov - -node_js: - - 'lts/*' - - '14' - -os: - - linux - - osx - -script: npx nyc -s npm run test:node -- --bail -after_success: npx nyc report --reporter=text-lcov > coverage.lcov && npx codecov - -jobs: - include: - - stage: check - script: - - npx aegir build --bundlesize - # Remove pull libs once ping is async - - npx aegir dep-check -- -i pull-handshake -i pull-stream - - npm run lint - - npm run test:types - - - stage: test - name: chrome - addons: - chrome: stable - script: - - npx aegir test -t browser -t webworker - - - stage: test - name: firefox - addons: - firefox: latest - script: - - npx aegir test -t browser -t webworker -- --browsers FirefoxHeadless - - - stage: test - name: interop - script: - - cd node_modules/interop-libp2p - - npm install - - LIBP2P_JS=${TRAVIS_BUILD_DIR}/src/index.js npx aegir test -t node --bail - - - stage: test - if: type = pull_request - name: example - auto-relay - script: - - cd examples - - npm install - - npm run test -- auto-relay - -notifications: - email: false \ No newline at end of file diff --git a/package.json b/package.json index 8a3465f3bc..b66585d5de 100644 --- a/package.json +++ b/package.json @@ -71,7 +71,7 @@ "it-pipe": "^1.1.0", "it-protocol-buffers": "^0.2.0", "libp2p-crypto": "^0.18.0", - "libp2p-interfaces": "libp2p/js-libp2p-interfaces#feat/add-types", + "libp2p-interfaces": "libp2p/js-libp2p-interfaces#feat/add-types-with-post-install", "libp2p-utils": "^0.2.2", "mafmt": "^8.0.0", "merge-options": "^2.0.0", @@ -98,7 +98,7 @@ "devDependencies": { "@nodeutils/defaults-deep": "^1.1.0", "abortable-iterator": "^3.0.0", - "aegir": "^29.1.0", + "aegir": "^29.2.0", "chai-bytes": "^0.1.2", "chai-string": "^1.5.0", "delay": "^4.3.0", diff --git a/src/transport-manager.js b/src/transport-manager.js index f204222b7b..258a8a86b8 100644 --- a/src/transport-manager.js +++ b/src/transport-manager.js @@ -54,7 +54,6 @@ class TransportManager { throw errCode(new Error('There is already a transport with this key'), codes.ERR_DUPLICATE_TRANSPORT) } - // @ts-ignore const transport = new Transport({ ...transportOptions, libp2p: this.libp2p, diff --git a/src/upgrader.js b/src/upgrader.js index 9ef25a4780..8d00cb5210 100644 --- a/src/upgrader.js +++ b/src/upgrader.js @@ -7,7 +7,6 @@ const log = Object.assign(debug('libp2p:upgrader'), { const errCode = require('err-code') const Multistream = require('multistream-select') const { Connection } = require('libp2p-interfaces/src/connection') -const ConnectionStatus = require('libp2p-interfaces/src/connection/status') const PeerId = require('peer-id') const { pipe } = require('it-pipe') const mutableProxy = require('mutable-proxy') @@ -223,8 +222,7 @@ class Upgrader { let connection if (Muxer) { - // Create the muxer - // @ts-ignore + // @ts-ignore Create the muxer muxer = new Muxer({ // Run anytime a remote stream is created onStream: async muxedStream => { @@ -270,7 +268,7 @@ class Upgrader { // Wait for close to finish before notifying of the closure (async () => { try { - if (connection.stat.status === ConnectionStatus.OPEN) { + if (connection.stat.status === 'open') { await connection.close() } } catch (err) { diff --git a/tsconfig.json b/tsconfig.json index 48a9c8e8b8..5b9a618c43 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,21 +1,7 @@ { "extends": "./node_modules/aegir/src/config/tsconfig.aegir.json", "compilerOptions": { - "outDir": "dist", - "forceConsistentCasingInFileNames": true, - "noImplicitReturns": false, - "noImplicitAny": false, - "noImplicitThis": true, - "noFallthroughCasesInSwitch": true, - "noUnusedLocals": true, - "noUnusedParameters": false, - "strictFunctionTypes": true, - "strictNullChecks": true, - "strictPropertyInitialization": true, - "strictBindCallApply": true, - "strict": true, - "alwaysStrict": true, - "stripInternal": true + "outDir": "dist" }, "include": [ "src"