From ea97bfa5579a0ec8c2c025ba76a6d83a7617b0c7 Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Tue, 23 Mar 2021 10:33:11 +1100 Subject: [PATCH 1/4] Setup bors --- .github/workflows/ci.yml | 2 ++ bors.toml | 3 +++ 2 files changed, 5 insertions(+) create mode 100644 bors.toml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9b52c88b90..f6156b38c1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,6 +4,8 @@ on: push: branches: - 'main' + - 'staging' + - 'trying' pull_request: jobs: diff --git a/bors.toml b/bors.toml new file mode 100644 index 0000000000..94f2a4384a --- /dev/null +++ b/bors.toml @@ -0,0 +1,3 @@ +status = ["build_and_test"] +block_labels = ["work-in-progress"] +delete_merged_branches = true From ee0c63eba327ee5d4e698e66c7a06ef8736d8206 Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Thu, 25 Mar 2021 15:49:07 +1100 Subject: [PATCH 2/4] Improve helper function for log name --- src/lib/waku.spec.ts | 3 ++- src/lib/waku_relay.spec.ts | 3 ++- src/test_utils/log_file.spec.ts | 21 +++++++++++++++++++++ src/test_utils/log_file.ts | 17 +++++++++++++++++ src/test_utils/nim_waku.ts | 7 ++----- 5 files changed, 44 insertions(+), 7 deletions(-) create mode 100644 src/test_utils/log_file.spec.ts diff --git a/src/lib/waku.spec.ts b/src/lib/waku.spec.ts index b476493bc1..89c9421a10 100644 --- a/src/lib/waku.spec.ts +++ b/src/lib/waku.spec.ts @@ -1,6 +1,7 @@ import { expect } from 'chai'; import { NOISE_KEY_1 } from '../test_utils/constants'; +import { makeLogFileName } from '../test_utils/log_file'; import { NimWaku } from '../test_utils/nim_waku'; import Waku from './waku'; @@ -19,7 +20,7 @@ describe('Waku', function () { ); const multiAddrWithId = localMultiaddr + '/p2p/' + peerId; - const nimWaku = new NimWaku(this.test!.title); + const nimWaku = new NimWaku(makeLogFileName(this)); await nimWaku.start({ staticnode: multiAddrWithId }); const nimPeers = await nimWaku.peers(); diff --git a/src/lib/waku_relay.spec.ts b/src/lib/waku_relay.spec.ts index 549b239b61..4a9c569fa7 100644 --- a/src/lib/waku_relay.spec.ts +++ b/src/lib/waku_relay.spec.ts @@ -2,6 +2,7 @@ import { expect } from 'chai'; import Pubsub from 'libp2p-interfaces/src/pubsub'; import { NOISE_KEY_1, NOISE_KEY_2 } from '../test_utils/constants'; +import { makeLogFileName } from '../test_utils/log_file'; import { NimWaku } from '../test_utils/nim_waku'; import Waku from './waku'; @@ -77,7 +78,7 @@ describe('Waku Relay', () => { ); const multiAddrWithId = localMultiaddr + '/p2p/' + peerId; - nimWaku = new NimWaku(this.test!.ctx!.currentTest!.title); + nimWaku = new NimWaku(makeLogFileName(this)); await nimWaku.start({ staticnode: multiAddrWithId }); await waku.relay.subscribe(); diff --git a/src/test_utils/log_file.spec.ts b/src/test_utils/log_file.spec.ts new file mode 100644 index 0000000000..8a89b984dd --- /dev/null +++ b/src/test_utils/log_file.spec.ts @@ -0,0 +1,21 @@ +import { expect } from 'chai'; + +import { makeLogFileName } from './log_file'; + +describe('This', function () { + describe('Is', function () { + it('A test', function () { + expect(makeLogFileName(this)).to.equal('This_Is_A_test'); + }); + }); + + describe('Is also', function () { + let testName: string; + beforeEach(function () { + testName = makeLogFileName(this); + }); + it('A test', function () { + expect(testName).to.equal('This_Is_also_A_test'); + }); + }); +}); diff --git a/src/test_utils/log_file.ts b/src/test_utils/log_file.ts index 7bed4f88a7..74dbae5111 100644 --- a/src/test_utils/log_file.ts +++ b/src/test_utils/log_file.ts @@ -1,3 +1,4 @@ +import { Context } from 'mocha'; import pTimeout from 'p-timeout'; import { Tail } from 'tail'; @@ -34,3 +35,19 @@ async function find(tail: Tail, line: string) { }); }); } + +function clean(str: string): string { + return str.replace(/ /g, '_').replace(/[':()]/g, ''); +} + +export function makeLogFileName(ctx: Context): string { + const unitTest = ctx!.currentTest ? ctx!.currentTest : ctx.test; + let name = clean(unitTest!.title); + let suite = unitTest!.parent; + + while (suite && suite.title) { + name = clean(suite.title) + '_' + name; + suite = suite.parent; + } + return name; +} diff --git a/src/test_utils/nim_waku.ts b/src/test_utils/nim_waku.ts index 805be37419..864e7b5162 100644 --- a/src/test_utils/nim_waku.ts +++ b/src/test_utils/nim_waku.ts @@ -37,12 +37,9 @@ export class NimWaku { private peerId?: PeerId; private logPath: string; - constructor(testName: string) { + constructor(logName: string) { this.portsShift = randomInt(0, 5000); - - const logFilePrefix = testName.replace(/ /g, '_').replace(/[':()]/g, ''); - - this.logPath = `${LOG_DIR}/${logFilePrefix}-nim-waku.log`; + this.logPath = `${LOG_DIR}/nim-waku_${logName}.log`; } async start(args: Args) { From c491b65edc3d8084d70a5251b2b99d46a4d2626b Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Thu, 25 Mar 2021 16:29:35 +1100 Subject: [PATCH 3/4] Handle nim-waku process exit & error --- src/test_utils/nim_waku.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/test_utils/nim_waku.ts b/src/test_utils/nim_waku.ts index 864e7b5162..5d6957b2f6 100644 --- a/src/test_utils/nim_waku.ts +++ b/src/test_utils/nim_waku.ts @@ -71,6 +71,16 @@ export class NimWaku { ], }); + this.process.on('exit', (signal) => { + if (signal != 0) { + console.log(`nim-waku process exited with ${signal}`); + } + }); + + this.process.on('error', (err) => { + console.log(`nim-waku process encountered an error: ${err}`); + }); + await this.waitForLog('RPC Server started'); } From cae1bb53dae272f335e13f9151b120da5fbd93c1 Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Thu, 25 Mar 2021 20:10:27 +1100 Subject: [PATCH 4/4] Increase nim-waku cache version due to CI issues --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f6156b38c1..3274dae342 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,7 +30,7 @@ jobs: path: | ./nim-waku/build/wakunode2 ./nim-waku/vendor/rln/target/debug - key: nim-waku-build-v2-${{ steps.nim-waku-head.outputs.ref }} + key: nim-waku-build-v3-${{ steps.nim-waku-head.outputs.ref }} # This would have been done part of npm pretest but it gives better # visibility in the CI if done as a separate step