Skip to content

Commit

Permalink
chore: automatic release (#170)
Browse files Browse the repository at this point in the history
* add automatic release

* remove yarn file

* ignore lockfile

* release should wait for CI

* delete old publish and fix branch name

* fix szntax error

* fix lint

* change when tests are run
  • Loading branch information
mpetrunic authored Apr 19, 2022
1 parent 14f0f39 commit 88c1f7c
Show file tree
Hide file tree
Showing 11 changed files with 116 additions and 4,031 deletions.
7 changes: 7 additions & 0 deletions .github/.dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
- package-ecosystem: "yarn"
allow:
- dependency-type: "production"
commit-message:
prefix: "chore: "
24 changes: 24 additions & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: "Semantic PR"

on:
pull_request_target:
types:
- opened
- edited
- synchronize

jobs:
main:
name: Validate PR title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
types: |
fix
feat
chore
validateSingleCommit: true #single commit can ovveride squash merge commit message
validateSingleCommitMatchesPrTitle: false
91 changes: 0 additions & 91 deletions .github/workflows/publish.yml

This file was deleted.

28 changes: 0 additions & 28 deletions .github/workflows/test.yml

This file was deleted.

68 changes: 68 additions & 0 deletions .github/workflows/test_and_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Tests

on:
push:
branches:
- master
pull_request:
branches:
- '**'

jobs:
tests:
name: tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
node: [15, 16]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2-beta
with:
node-version: ${{matrix.node}}
- run: yarn install
- run: yarn build
- name: Lint
run: yarn lint
- name: Check Types
run: yarn run check-types
- name: Unit tests
run: yarn test:unit
- name: E2e tests
run: yarn test:e2e

maybe-release:
name: release
runs-on: ubuntu-latest
needs: tests
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
steps:
- uses: google-github-actions/release-please-action@v3
id: release
with:
release-type: node
package-name: release-please-action
changelog-types: '[{"type":"feat","section":"Features","hidden":false},{"type":"fix","section":"Bug Fixes","hidden":false},{"type":"chore","section":"Miscellaneous","hidden":false}]'

- uses: actions/checkout@v3
if: ${{ steps.release.outputs.release_created }}

- uses: actions/setup-node@v3
with:
cache: 'yarn'
node-version: 16
registry-url: 'https://registry.npmjs.org'
if: ${{ steps.release.outputs.release_created }}

- run: yarn install --ignore-scripts
if: ${{ steps.release.outputs.release_created }}

- run: yarn build
if: ${{ steps.release.outputs.release_created }}

- run: yarn publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}}
if: ${{ steps.release.outputs.release_created }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
yarn.lock

# Runtime data
pids
Expand Down
2 changes: 1 addition & 1 deletion src/enr/enr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class ENR extends Map<ENRKey, ENRValue> {
return enr;
}
static decode(encoded: Buffer): ENR {
const decoded = (RLP.decode(encoded) as unknown) as Buffer[];
const decoded = RLP.decode(encoded) as unknown as Buffer[];
return ENR.decodeFromValues(decoded);
}
static decodeTxt(encoded: string): ENR {
Expand Down
2 changes: 1 addition & 1 deletion src/kademlia/bucket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class Bucket extends (EventEmitter as { new (): BucketEventEmitter }) {
clear(): void {
this.nodes = [];
this.pending = undefined;
clearTimeout((this.pendingTimeoutId as unknown) as NodeJS.Timeout);
clearTimeout(this.pendingTimeoutId as unknown as NodeJS.Timeout);
}

/**
Expand Down
24 changes: 12 additions & 12 deletions src/message/decode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export function decode(data: Buffer): Message {
}

function decodePing(data: Buffer): IPingMessage {
const rlpRaw = (RLP.decode(data.slice(1)) as unknown) as Buffer[];
const rlpRaw = RLP.decode(data.slice(1)) as unknown as Buffer[];
if (!Array.isArray(rlpRaw) || rlpRaw.length !== 2) {
throw new Error(ERR_INVALID_MESSAGE);
}
Expand All @@ -62,7 +62,7 @@ function decodePing(data: Buffer): IPingMessage {
}

function decodePong(data: Buffer): IPongMessage {
const rlpRaw = (RLP.decode(data.slice(1)) as unknown) as Buffer[];
const rlpRaw = RLP.decode(data.slice(1)) as unknown as Buffer[];
if (!Array.isArray(rlpRaw) || rlpRaw.length !== 4) {
throw new Error(ERR_INVALID_MESSAGE);
}
Expand All @@ -82,14 +82,14 @@ function decodePong(data: Buffer): IPongMessage {
}

function decodeFindNode(data: Buffer): IFindNodeMessage {
const rlpRaw = (RLP.decode(data.slice(1)) as unknown) as Buffer[];
const rlpRaw = RLP.decode(data.slice(1)) as unknown as Buffer[];
if (!Array.isArray(rlpRaw) || rlpRaw.length !== 2) {
throw new Error(ERR_INVALID_MESSAGE);
}
if (!Array.isArray(rlpRaw[1])) {
throw new Error(ERR_INVALID_MESSAGE);
}
const distances = ((rlpRaw[1] as unknown) as Buffer[]).map((x) => (x.length ? x.readUIntBE(0, x.length) : 0));
const distances = (rlpRaw[1] as unknown as Buffer[]).map((x) => (x.length ? x.readUIntBE(0, x.length) : 0));
return {
type: MessageType.FINDNODE,
id: toBigIntBE(rlpRaw[0]),
Expand All @@ -98,7 +98,7 @@ function decodeFindNode(data: Buffer): IFindNodeMessage {
}

function decodeNodes(data: Buffer): INodesMessage {
const rlpRaw = (RLP.decode(data.slice(1)) as unknown) as RLP.Decoded;
const rlpRaw = RLP.decode(data.slice(1)) as unknown as RLP.Decoded;
if (!Array.isArray(rlpRaw) || rlpRaw.length !== 3 || !Array.isArray(rlpRaw[2])) {
throw new Error(ERR_INVALID_MESSAGE);
}
Expand All @@ -111,7 +111,7 @@ function decodeNodes(data: Buffer): INodesMessage {
}

function decodeTalkReq(data: Buffer): ITalkReqMessage {
const rlpRaw = (RLP.decode(data.slice(1)) as unknown) as RLP.Decoded;
const rlpRaw = RLP.decode(data.slice(1)) as unknown as RLP.Decoded;
if (!Array.isArray(rlpRaw) || rlpRaw.length !== 3) {
throw new Error(ERR_INVALID_MESSAGE);
}
Expand All @@ -124,7 +124,7 @@ function decodeTalkReq(data: Buffer): ITalkReqMessage {
}

function decodeTalkResp(data: Buffer): ITalkRespMessage {
const rlpRaw = (RLP.decode(data.slice(1)) as unknown) as RLP.Decoded;
const rlpRaw = RLP.decode(data.slice(1)) as unknown as RLP.Decoded;
if (!Array.isArray(rlpRaw) || rlpRaw.length !== 2) {
throw new Error(ERR_INVALID_MESSAGE);
}
Expand All @@ -136,21 +136,21 @@ function decodeTalkResp(data: Buffer): ITalkRespMessage {
}

function decodeRegTopic(data: Buffer): IRegTopicMessage {
const rlpRaw = (RLP.decode(data.slice(1)) as unknown) as Buffer[];
const rlpRaw = RLP.decode(data.slice(1)) as unknown as Buffer[];
if (!Array.isArray(rlpRaw) || rlpRaw.length !== 4 || !Array.isArray(rlpRaw[2])) {
throw new Error(ERR_INVALID_MESSAGE);
}
return {
type: MessageType.REGTOPIC,
id: toBigIntBE(rlpRaw[0]),
topic: rlpRaw[1],
enr: ENR.decodeFromValues((rlpRaw[2] as unknown) as Buffer[]),
enr: ENR.decodeFromValues(rlpRaw[2] as unknown as Buffer[]),
ticket: rlpRaw[3],
};
}

function decodeTicket(data: Buffer): ITicketMessage {
const rlpRaw = (RLP.decode(data.slice(1)) as unknown) as Buffer[];
const rlpRaw = RLP.decode(data.slice(1)) as unknown as Buffer[];
if (!Array.isArray(rlpRaw) || rlpRaw.length !== 3) {
throw new Error(ERR_INVALID_MESSAGE);
}
Expand All @@ -163,7 +163,7 @@ function decodeTicket(data: Buffer): ITicketMessage {
}

function decodeRegConfirmation(data: Buffer): IRegConfirmationMessage {
const rlpRaw = (RLP.decode(data.slice(1)) as unknown) as Buffer[];
const rlpRaw = RLP.decode(data.slice(1)) as unknown as Buffer[];
if (!Array.isArray(rlpRaw) || rlpRaw.length !== 2) {
throw new Error(ERR_INVALID_MESSAGE);
}
Expand All @@ -175,7 +175,7 @@ function decodeRegConfirmation(data: Buffer): IRegConfirmationMessage {
}

function decodeTopicQuery(data: Buffer): ITopicQueryMessage {
const rlpRaw = (RLP.decode(data.slice(1)) as unknown) as Buffer[];
const rlpRaw = RLP.decode(data.slice(1)) as unknown as Buffer[];
if (!Array.isArray(rlpRaw) || rlpRaw.length !== 2) {
throw new Error(ERR_INVALID_MESSAGE);
}
Expand Down
3 changes: 2 additions & 1 deletion src/transport/udp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import { IRemoteInfo, ITransportService, TransportEventEmitter } from "./types";
*/
export class UDPTransportService
extends (EventEmitter as { new (): TransportEventEmitter })
implements ITransportService {
implements ITransportService
{
public multiaddr: Multiaddr;
private socket!: dgram.Socket;
private srcId: string;
Expand Down
Loading

0 comments on commit 88c1f7c

Please sign in to comment.