From f03c9c004ec4999333b2fff73700dcd169bf7b30 Mon Sep 17 00:00:00 2001 From: Vasco Santos Date: Wed, 28 Apr 2021 22:36:21 +0200 Subject: [PATCH] chore: add github actions and remove travis --- .github/workflows/main.yml | 32 ++++++++++++++++++++++++++++++++ .travis.yml | 31 ------------------------------- src/enr/enr.ts | 12 ++++++------ src/keypair/index.ts | 2 +- src/libp2p/discv5.ts | 2 +- src/service/service.ts | 2 +- types/multiaddr/index.d.ts | 5 +++-- yarn.lock | 15 +++++---------- 8 files changed, 49 insertions(+), 52 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 00000000..1a1f7aa0 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,32 @@ +name: ci +on: + push: + branches: + - master + pull_request: + branches: + - '**' + +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: yarn install --frozen-lockfile + - run: yarn check-types + - run: yarn lint + test-node: + needs: check + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [windows-latest, ubuntu-latest, macos-latest] + node: [14] + fail-fast: false + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node }} + - run: yarn install --frozen-lockfile + - run: yarn test diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index fe42e718..00000000 --- a/.travis.yml +++ /dev/null @@ -1,31 +0,0 @@ -language: node_js -node_js: - - "lts/*" - -cache: - yarn: true - -before_install: - - | - if ! git diff --name-only $TRAVIS_COMMIT_RANGE | grep -qvE '(.md)|(.html)|^(LICENSE)|^(docs)|(.github)' - then - echo "Only docs were updated, not running CI!" - travis_terminate 0 - fi - -install: - - yarn install --frozen-lockfile - -jobs: - include: - - stage: Check types - name: Check types - script: yarn check-types - - - stage: Lint - name: Lint - script: yarn lint - - - stage: Test - name: Test - script: yarn test diff --git a/src/enr/enr.ts b/src/enr/enr.ts index 8ebb934d..1c8d7bb2 100644 --- a/src/enr/enr.ts +++ b/src/enr/enr.ts @@ -2,8 +2,8 @@ import { Multiaddr, protocols } from "multiaddr"; import base64url from "base64url"; import { toBigIntBE } from "bigint-buffer"; import * as RLP from "rlp"; -import PeerId = require("peer-id"); -import muConvert = require("multiaddr/src/convert"); +import PeerId from "peer-id"; +import muConvert from "multiaddr/src/convert"; import { ERR_INVALID_ID, ERR_NO_SIGNATURE, MAX_RECORD_SIZE } from "./constants"; import * as v4 from "./v4"; @@ -131,7 +131,7 @@ export class ENR extends Map { get tcp(): number | undefined { const raw = this.get("tcp"); if (raw) { - return muConvert.toString(protocols.names.tcp.code, toNewUint8Array(raw)) as number; + return Number(muConvert.toString(protocols.names.tcp.code, toNewUint8Array(raw))); } else { return undefined; } @@ -148,7 +148,7 @@ export class ENR extends Map { get udp(): number | undefined { const raw = this.get("udp"); if (raw) { - return muConvert.toString(protocols.names.udp.code, toNewUint8Array(raw)) as number; + return Number(muConvert.toString(protocols.names.udp.code, toNewUint8Array(raw))); } else { return undefined; } @@ -182,7 +182,7 @@ export class ENR extends Map { get tcp6(): number | undefined { const raw = this.get("tcp6"); if (raw) { - return muConvert.toString(protocols.names.tcp.code, raw) as number; + return Number(muConvert.toString(protocols.names.tcp.code, raw)); } else { return undefined; } @@ -199,7 +199,7 @@ export class ENR extends Map { get udp6(): number | undefined { const raw = this.get("udp6"); if (raw) { - return muConvert.toString(protocols.names.udp.code, raw) as number; + return Number(muConvert.toString(protocols.names.udp.code, raw)); } else { return undefined; } diff --git a/src/keypair/index.ts b/src/keypair/index.ts index 40a8dadf..36daa12f 100644 --- a/src/keypair/index.ts +++ b/src/keypair/index.ts @@ -1,4 +1,4 @@ -import PeerId = require("peer-id"); +import PeerId from "peer-id"; import { keys } from "libp2p-crypto"; const { keysPBM, supportedKeys } = keys; diff --git a/src/libp2p/discv5.ts b/src/libp2p/discv5.ts index 75293ae4..5d0ad539 100644 --- a/src/libp2p/discv5.ts +++ b/src/libp2p/discv5.ts @@ -1,5 +1,5 @@ import { EventEmitter } from "events"; -import PeerId = require("peer-id"); +import PeerId from "peer-id"; import { Multiaddr } from "multiaddr"; import { randomBytes } from "libp2p-crypto"; diff --git a/src/service/service.ts b/src/service/service.ts index 7b70bf2d..506f3f23 100644 --- a/src/service/service.ts +++ b/src/service/service.ts @@ -2,7 +2,7 @@ import { EventEmitter } from "events"; import debug from "debug"; import { Multiaddr } from "multiaddr"; import isIp = require("is-ip"); -import PeerId = require("peer-id"); +import PeerId from "peer-id"; import { UDPTransportService } from "../transport"; import { MAX_PACKET_SIZE } from "../packet"; diff --git a/types/multiaddr/index.d.ts b/types/multiaddr/index.d.ts index 33aa270e..e5b38cda 100644 --- a/types/multiaddr/index.d.ts +++ b/types/multiaddr/index.d.ts @@ -1,3 +1,4 @@ + /* eslint-disable @typescript-eslint/no-explicit-any */ declare module "multiaddr/src/ip" { @@ -5,6 +6,6 @@ declare module "multiaddr/src/ip" { } declare module "multiaddr/src/convert" { - export function toString(protocol: any, buf: Uint8Array): string | number; + export function toString(protocol: any, buf: Uint8Array): string; export function toBytes(protocol: any, str: string | number): Uint8Array; -} +} \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 878e0252..ce347551 100644 --- a/yarn.lock +++ b/yarn.lock @@ -204,7 +204,7 @@ resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-5.2.7.tgz#315d570ccb56c53452ff8638738df60726d5b6ea" integrity sha512-NYrtPht0wGzhwe9+/idPaBB+TqkY9AhTvOLMkThm0IoEfLaiVQZwBwyJ5puCkO3AUCWrmcoePjp2mbFocKy4SQ== -"@types/node@*": +"@types/node@*", "@types/node@>=13.7.0": version "15.0.1" resolved "https://registry.yarnpkg.com/@types/node/-/node-15.0.1.tgz#ef34dea0881028d11398be5bf4e856743e3dc35a" integrity sha512-TMkXt0Ck1y0KKsGr9gJtWGjttxlZnnvDtphxUOSd0bfaR6Q1jle+sPvrzNR1urqYTWMinoKvjKfXUGsumaO1PA== @@ -214,11 +214,6 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-12.20.11.tgz#980832cd56efafff8c18aa148c4085eb02a483f4" integrity sha512-gema+apZ6qLQK7k7F0dGkGCWQYsL0qqKORWOQO6tq46q+x+1C0vbOiOqOwRVlh4RAdbQwV/j/ryr3u5NOG1fPQ== -"@types/node@^13.7.0": - version "13.13.51" - resolved "https://registry.yarnpkg.com/@types/node/-/node-13.13.51.tgz#a424c5282f99fc1ca41f11b727b6aea80668bcba" - integrity sha512-66/xg5I5Te4oGi5Jws11PtNmKkZbOPZWyBZZ/l5AOrWj1Dyw+6Ge/JhYTq/2/Yvdqyhrue8RL+DGI298OJ0xcg== - "@typescript-eslint/eslint-plugin@^2.7.0": version "2.34.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.34.0.tgz#6f8ce8a46c7dea4a6f1d171d2bb8fbae6dac2be9" @@ -2558,9 +2553,9 @@ progress@^2.0.0: integrity sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA== protobufjs@^6.10.2: - version "6.10.2" - resolved "https://registry.yarnpkg.com/protobufjs/-/protobufjs-6.10.2.tgz#b9cb6bd8ec8f87514592ba3fdfd28e93f33a469b" - integrity sha512-27yj+04uF6ya9l+qfpH187aqEzfCF4+Uit0I9ZBQVqK09hk/SQzKa2MUqUpXaVa7LOFRg1TSSr3lVxGOk6c0SQ== + version "6.11.0" + resolved "https://registry.yarnpkg.com/protobufjs/-/protobufjs-6.11.0.tgz#b890a2d3f64c62f0395e1e000d39ff91634bafb7" + integrity sha512-i4usrGD86mtOLnoTwUsVXphDY7yHM2rDiV3JU4Ix43BOtHi0DHy5rSCciX8MRHSYHaxnoc0TcpwEBlrNUAxvQQ== dependencies: "@protobufjs/aspromise" "^1.1.2" "@protobufjs/base64" "^1.1.2" @@ -2573,7 +2568,7 @@ protobufjs@^6.10.2: "@protobufjs/pool" "^1.1.0" "@protobufjs/utf8" "^1.1.0" "@types/long" "^4.0.1" - "@types/node" "^13.7.0" + "@types/node" ">=13.7.0" long "^4.0.0" pseudomap@^1.0.2: