Skip to content
This repository has been archived by the owner on Jan 14, 2022. It is now read-only.

Commit

Permalink
Merge branch '2.2.0' into 823-search-box-auto-capitalization
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal Tuleja committed Dec 7, 2018
2 parents bbe9e93 + 77a5609 commit 11fc314
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8.11.2
8.14.0
60 changes: 34 additions & 26 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,35 @@ pipeline {
stages {
stage ('Build dependencies') {
steps {
script {
cache_file = restoreCache("package.json")
sh 'npm install'
saveCache(cache_file, './node_modules', 10)
nvm(getNodejsVersion()) {
sh 'npm ci'
}
}
}
stage ('Run ESLint') {
steps {
sh 'npm run eslint'
nvm(getNodejsVersion()) {
sh 'npm run eslint'
}
}
}
stage ('Build bundles') {
steps {
sh 'npm run build'
nvm(getNodejsVersion()) {
sh 'npm run build'
}
}
}
stage ('Build candles') {
steps {
// marketwatcher needs to be enabled to builds candles
sh '''
cp ./test/known.test.json ./known.json
redis-cli -n $REDIS_DB flushdb
grunt candles:build
'''
nvm(getNodejsVersion()) {
// marketwatcher needs to be enabled to builds candles
sh '''
cp ./test/known.test.json ./known.json
redis-cli -n $REDIS_DB flushdb
grunt candles:build
'''
}
}
}
stage ('Start Lisk') {
Expand Down Expand Up @@ -65,29 +69,33 @@ pipeline {
}
stage ('Start Explorer') {
steps {
sh '''
cd $WORKSPACE/$BRANCH_NAME
LISK_PORT=$( docker-compose port lisk 4000 |cut -d ":" -f 2 )
cd -
LISK_PORT=$LISK_PORT node app.js -p $EXPLORER_PORT &>/dev/null &
sleep 20
'''
nvm(getNodejsVersion()) {
sh '''
cd $WORKSPACE/$BRANCH_NAME
LISK_PORT=$( docker-compose port lisk 4000 |cut -d ":" -f 2 )
cd -
LISK_PORT=$LISK_PORT node app.js -p $EXPLORER_PORT &>/dev/null &
sleep 20
'''
}
}
}
stage ('Run API tests') {
steps {
sh '''
sed -i -r -e "s/6040/$EXPLORER_PORT/" test/node.js
npm run test
'''
nvm(getNodejsVersion()) {
sh '''
sed -i -r -e "s/6040/$EXPLORER_PORT/" test/node.js
npm run test
'''
}
}
}
// stage ('Run E2E tests') {
// steps {
// wrap([$class: 'Xvfb']) {
// sh '''
// npm run e2e -- --params.baseURL http://localhost:$EXPLORER_PORT
// '''
// nvm(getNodejsVersion()) {
// sh 'npm run e2e -- --params.baseURL http://localhost:$EXPLORER_PORT'
// }
// }
// }
// }
Expand Down
2 changes: 1 addition & 1 deletion config.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ config.cacheTTL = 20;
// Collect logs (true - enabled, false - disabled)
config.log.enabled = true;
// Output for logs - can be device file or ordinary path
config.log.file = './logs/explorer.log';
config.log.output = ['/dev/stdout', './logs/explorer.log'];
// Log level - (trace, debug, info, warn, error)
config.log.level = 'info';

Expand Down
39 changes: 26 additions & 13 deletions utils/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,22 @@ const flatstr = require('flatstr');
const newConsole = require('console').Console;
const config = require('../config');

const output = fs.createWriteStream(config.log.file, { flags: 'a' });
const myConsole = new newConsole(output, output);
const defaultOutput = '/dev/stdout';

if (!Array.isArray(config.log.output)) {
if (typeof config.log.output === 'string') {
config.log.output = [config.log.output];
} else if (typeof config.log.file === 'string') {
config.log.output = [config.log.file];
} else {
config.log.output = [defaultOutput];
}
}

const logOutputs = config.log.output.map((outputPath) => {
const fileOutput = fs.createWriteStream(outputPath, { flags: 'a' });
return new newConsole(fileOutput, fileOutput);
});

const levels = {
trace: 0,
Expand All @@ -35,25 +49,24 @@ const logger = {};
logger.doLog = function doLog(level, msg, extra) {
if (config.log.enabled) {
const timestamp = Date.now();

// const stringMsg = typeof msg === 'string' ? msg : JSON.stringify(msg);
// const parsedMsg = stringMsg.replace(/(\r\n|\n|\r)/gm, ' ');
let outputString;

if (extra) {
const stringExtra = typeof extra === 'string' ? extra : JSON.stringify(extra);
const parsedExtra = stringExtra.replace(/(\r\n|\n|\r)/gm, ' ');
myConsole.log(flatstr(safeStringify({
level,
timestamp,
message: `${msg} ${parsedExtra}`,
})));
outputString = `${msg} ${parsedExtra}`;
} else {
myConsole.log(flatstr(safeStringify({
outputString = msg;
}

logOutputs.map((logOutput) => {
logOutput.log(flatstr(safeStringify({
level,
timestamp,
message: msg,
message: outputString,
})));
}
return logOutput;
});
}
};

Expand Down

0 comments on commit 11fc314

Please sign in to comment.