11: Setup bors r=D4nte a=D4nte



Co-authored-by: Franck Royer <franck@royer.one>
This commit is contained in:
bors[bot] 2021-03-25 09:36:22 +00:00 committed by GitHub
commit bfc1c45209
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 60 additions and 8 deletions

View File

@ -4,6 +4,8 @@ on:
push: push:
branches: branches:
- 'main' - 'main'
- 'staging'
- 'trying'
pull_request: pull_request:
jobs: jobs:
@ -28,7 +30,7 @@ jobs:
path: | path: |
./nim-waku/build/wakunode2 ./nim-waku/build/wakunode2
./nim-waku/vendor/rln/target/debug ./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 # This would have been done part of npm pretest but it gives better
# visibility in the CI if done as a separate step # visibility in the CI if done as a separate step

3
bors.toml Normal file
View File

@ -0,0 +1,3 @@
status = ["build_and_test"]
block_labels = ["work-in-progress"]
delete_merged_branches = true

View File

@ -1,6 +1,7 @@
import { expect } from 'chai'; import { expect } from 'chai';
import { NOISE_KEY_1 } from '../test_utils/constants'; import { NOISE_KEY_1 } from '../test_utils/constants';
import { makeLogFileName } from '../test_utils/log_file';
import { NimWaku } from '../test_utils/nim_waku'; import { NimWaku } from '../test_utils/nim_waku';
import Waku from './waku'; import Waku from './waku';
@ -19,7 +20,7 @@ describe('Waku', function () {
); );
const multiAddrWithId = localMultiaddr + '/p2p/' + peerId; const multiAddrWithId = localMultiaddr + '/p2p/' + peerId;
const nimWaku = new NimWaku(this.test!.title); const nimWaku = new NimWaku(makeLogFileName(this));
await nimWaku.start({ staticnode: multiAddrWithId }); await nimWaku.start({ staticnode: multiAddrWithId });
const nimPeers = await nimWaku.peers(); const nimPeers = await nimWaku.peers();

View File

@ -2,6 +2,7 @@ import { expect } from 'chai';
import Pubsub from 'libp2p-interfaces/src/pubsub'; import Pubsub from 'libp2p-interfaces/src/pubsub';
import { NOISE_KEY_1, NOISE_KEY_2 } from '../test_utils/constants'; 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 { NimWaku } from '../test_utils/nim_waku';
import Waku from './waku'; import Waku from './waku';
@ -77,7 +78,7 @@ describe('Waku Relay', () => {
); );
const multiAddrWithId = localMultiaddr + '/p2p/' + peerId; const multiAddrWithId = localMultiaddr + '/p2p/' + peerId;
nimWaku = new NimWaku(this.test!.ctx!.currentTest!.title); nimWaku = new NimWaku(makeLogFileName(this));
await nimWaku.start({ staticnode: multiAddrWithId }); await nimWaku.start({ staticnode: multiAddrWithId });
await waku.relay.subscribe(); await waku.relay.subscribe();

View File

@ -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');
});
});
});

View File

@ -1,3 +1,4 @@
import { Context } from 'mocha';
import pTimeout from 'p-timeout'; import pTimeout from 'p-timeout';
import { Tail } from 'tail'; 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;
}

View File

@ -37,12 +37,9 @@ export class NimWaku {
private peerId?: PeerId; private peerId?: PeerId;
private logPath: string; private logPath: string;
constructor(testName: string) { constructor(logName: string) {
this.portsShift = randomInt(0, 5000); this.portsShift = randomInt(0, 5000);
this.logPath = `${LOG_DIR}/nim-waku_${logName}.log`;
const logFilePrefix = testName.replace(/ /g, '_').replace(/[':()]/g, '');
this.logPath = `${LOG_DIR}/${logFilePrefix}-nim-waku.log`;
} }
async start(args: Args) { async start(args: Args) {
@ -74,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'); await this.waitForLog('RPC Server started');
} }