From 92a5b1ca55f6d86adeed74a5ff3c68326fc68f9a Mon Sep 17 00:00:00 2001 From: Julian Simioni Date: Sat, 1 Sep 2018 15:47:49 +0300 Subject: [PATCH 1/4] Allow configuring logs as JSON By setting a flag on the console logger, we can easily convert all outgoing logs with pelias-logger to a JSON format. Many of our log statements already use structured formats, and by printing them in JSON, they can all be readily parsed by almost any log-reading system (like Kibana, Honeycomb, Splunk, etc). In my testing, Winston essentialy checks if the flag is set to any truthy value so `true`, "true", 3, "maybe" and anything else except `null` and `false` will enable this feature. Since it's quite robust and handles any valid value, it does not seem necessary to add any validation ourselves. --- index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/index.js b/index.js index 95a2352..3772739 100644 --- a/index.js +++ b/index.js @@ -15,6 +15,7 @@ function CreateLogger( name, loggerOpts ){ transports: [ new winston.transports.Console( { colorize: pkgConfig.colorize, + json: pkgConfig.json, timestamp: pkgConfig.timestamp, level: pkgConfig.level, label: name From 20b33f4b4069998cf8215f641895c60bb5085c00 Mon Sep 17 00:00:00 2001 From: Julian Simioni Date: Wed, 29 Aug 2018 03:25:53 +0300 Subject: [PATCH 2/4] feat(release): replace semantic-release dep with Travis build stages This change moves semantic-release out of dev-dependencies, but keeps its functionality by calling semantic-release as usual in a `release` TravisCI build stage. There are several advantages to this method: 1.) semantic-release is run only after all builds succeed. Our previous approach could have theoretically run semantic-release when some Node.js versions failed with the current code 2.) semantic-release (and it's many dependencies) are removed from `node_modules`. This increases the speed of `npm install` in all cases, and reduces the size of our Docker images by 20MB (from 284MB to 264MB)! Since the only time semantic-release is needed is on TravisCI anyway, it seems pointless that every installation of Pelias should include it. 3.) Because semantic-release is not in `package.json`, Greenkeeper will not attempt to update it. Semantic release updates _very_ frequently, and each update attempt seems to have a decent chance of experiencing a random TravisCI failure, causing unwanted notifications. There are probably downsides to this approach. For example, we should consider pinning the major version of semantic release during install. Additionally, and for obvious reasons, we can't fully test this change until it's merged to the `production` branch. We should consider testing it first on a lower priority repository. If this change _does_ work well, we should consider adopting it everywhere. --- .travis.yml | 7 +++++-- package.json | 3 +-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5aec453..e83588f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,8 +11,11 @@ matrix: script: npm run travis before_install: - npm i -g npm -after_success: - - npx semantic-release branches: except: - /^v\d+\.\d+\.\d+$/ +jobs: + include: + - stage: release + node_js: 10 + script: npx semantic-release diff --git a/package.json b/package.json index 22db30d..ce44279 100644 --- a/package.json +++ b/package.json @@ -12,8 +12,7 @@ "author": "mapzen", "main": "index.js", "devDependencies": { - "precommit-hook": "^3.0.0", - "semantic-release": "^15.0.0" + "precommit-hook": "^3.0.0" }, "dependencies": { "winston": "^2.2.0", From 063ac314a2fdebafda4ce6096237fd11c192e51a Mon Sep 17 00:00:00 2001 From: Julian Simioni Date: Thu, 30 Aug 2018 23:08:43 +0300 Subject: [PATCH 3/4] Use ci-tools script for semantic-release --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e83588f..5ab053b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,4 +18,4 @@ jobs: include: - stage: release node_js: 10 - script: npx semantic-release + script: curl "https://raw.githubusercontent.com/pelias/ci-tools/master/semantic-release.sh" | bash - From 5d7d447b433aa88f0d678c215a0a8270c352e5d0 Mon Sep 17 00:00:00 2001 From: Julian Simioni Date: Thu, 30 Aug 2018 23:12:36 +0300 Subject: [PATCH 4/4] Only run semantic-release on master branch As this is an NPM module, the master branch is where we do releases. Running semantic-release anywhere else just wastes time on TravisCI. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 5ab053b..60235aa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,3 +19,4 @@ jobs: - stage: release node_js: 10 script: curl "https://raw.githubusercontent.com/pelias/ci-tools/master/semantic-release.sh" | bash - + if: branch = master