Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switches to local shared-libs #5684

Merged
merged 14 commits into from Jun 19, 2019
Merged

Switches to local shared-libs #5684

merged 14 commits into from Jun 19, 2019

Conversation

dianabarsan
Copy link
Member

@dianabarsan dianabarsan commented May 22, 2019

Description

Changes transitions error reporting to not stringify errors.
Changes lineage lib to not require pouchdb and run integration tests with memory adapter, to avoid building leveldown every time we install or test the library.
Changes packages for all apps so shared-libs are local again.
Adds jasmine reporter to improve e2e tests outputs.

#5694

Code review items

  • Readable: Concise, well named, follows the style guide, documented if necessary.
  • Documented: Configuration and user documentation on medic-docs
  • Tested: Unit and/or e2e where appropriate
  • Internationalised: All user facing text
  • Backwards compatible: Works with existing data and configuration or includes a migration. Any breaking changes documented in Changes.md.

License

The software is provided under AGPL-3.0. Contributions to this project are accepted under the same license.

Gruntfile.js Outdated
@@ -815,7 +815,7 @@ module.exports = function(grunt) {
// Build tasks
grunt.registerTask('install-dependencies', 'Update and patch dependencies', [
'exec:undo-patches',
'exec:npm-ci-shared-libs',
'exec:npm-ci-shared-libs:production',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing this to not pack shared-libs dev dependencies.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this command is only ever called from here, so I think we should just hardcode --production into the command above.

@@ -50,6 +50,7 @@
"grunt-sass": "^3.0.2",
"grunt-text-replace": "^0.4.0",
"grunt-xmlmin": "^0.1.8",
"jasmine-spec-reporter": "^4.2.1",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes e2e jasmine spec reporting look pretty:
https://travis-ci.org/medic/medic/jobs/535893166#L3633 - successfull build
https://travis-ci.org/medic/medic/jobs/535888193#L3682 - deliberately failed build

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice.

const PouchDB = require('pouchdb').defaults({ db: memdown });
const PouchDB = require('pouchdb-core');
PouchDB.plugin(require('pouchdb-adapter-memory'));
PouchDB.plugin(require('pouchdb-mapreduce'));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Runs integration tests with memory adapter instead of leveldown, so we don't need to build leveldown every time we install or test this dependency. Shaves ~3 minutes off the Travis build job.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow. Awesome!

@@ -238,7 +238,7 @@ const finalize = ({ change, results }, callback) => {
// todo: how to handle a failed save? for now just
// waiting until next change and try again.
if (err) {
logger.error(`error saving changes on doc ${change.id} seq ${change.seq}: ${JSON.stringify(err)}`);
logger.error(`error saving changes on doc ${change.id} seq ${change.seq}: %o`, err);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

console.log(JSON.stringify(new Error('you would expect something else, right?'))); => {}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh.

@dianabarsan dianabarsan changed the title Dependencies juggling Switches to local shared-libs May 23, 2019
@@ -962,7 +962,6 @@ module.exports = function(grunt) {
'static-analysis',
'build',
'build-admin',
'install-dependencies',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't find a good reason to install dependencies the second time.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally. Must've been a bug...

@dianabarsan
Copy link
Member Author

@garethbowen could you please have a look?
I put a bunch of other small stuff in, but I could separate them if you want.

Copy link
Member

@garethbowen garethbowen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome. So many improvements in a single PR! I've made a few minor comments inline.

I'm a little concerned about destabilising 3.5.0 so near the finish line. Do you think it's worth holding off merging until 3.6.0?

I think we should have an issue created to track this. I think it could use a little AT to make sure the release works as expected. What do you think?

Gruntfile.js Outdated
return getSharedLibDirs()
.map(
lib =>
`echo Installing shared library: ${lib} &&
(cd shared-libs/${lib} && npm ci)`
(cd shared-libs/${lib} && npm ci ${production && '--production' || ''})`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a ternary would be clearer, eg: ${production ? '--production' : ''}

@@ -962,7 +962,6 @@ module.exports = function(grunt) {
'static-analysis',
'build',
'build-admin',
'install-dependencies',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally. Must've been a bug...

Gruntfile.js Outdated
@@ -815,7 +815,7 @@ module.exports = function(grunt) {
// Build tasks
grunt.registerTask('install-dependencies', 'Update and patch dependencies', [
'exec:undo-patches',
'exec:npm-ci-shared-libs',
'exec:npm-ci-shared-libs:production',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this command is only ever called from here, so I think we should just hardcode --production into the command above.

api/package.json Outdated
"async": "^2.6.1",
"bikram-sambat": "^1.5.0",
"bikram-sambat": "1.5.0",
"bikram-sambat-bootstrap": "1.4.2",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These versions should have a ^, right?

@@ -50,6 +50,7 @@
"grunt-sass": "^3.0.2",
"grunt-text-replace": "^0.4.0",
"grunt-xmlmin": "^0.1.8",
"jasmine-spec-reporter": "^4.2.1",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice.

const PouchDB = require('pouchdb').defaults({ db: memdown });
const PouchDB = require('pouchdb-core');
PouchDB.plugin(require('pouchdb-adapter-memory'));
PouchDB.plugin(require('pouchdb-mapreduce'));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow. Awesome!

"object-path": "^0.11.4"
},
"dependencies": {
"object-path": "^0.11.4",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has moved most of the libs from devDependencies to dependencies - were they previously in the wrong place?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. Because I'm installing them with --production, I needed them in the proper place (they're not dev dependencies).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome.

@@ -238,7 +238,7 @@ const finalize = ({ change, results }, callback) => {
// todo: how to handle a failed save? for now just
// waiting until next change and try again.
if (err) {
logger.error(`error saving changes on doc ${change.id} seq ${change.seq}: ${JSON.stringify(err)}`);
logger.error(`error saving changes on doc ${change.id} seq ${change.seq}: %o`, err);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh.

jasmineNodeOpts: {
// makes default jasmine reporter not display dots for every spec
print: () => {}
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't like the dots?

Occasionally it's useful to know that the tests are still running.

Can we print the name of the test that's being executed instead of a dot? Potentially we could only print the name if in debug mode?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like the dots, the dots along with the names look stange - the default reporter displays a . for a successful test and an F for a failure.
Together they look like this:
image

I do like the names, and I'd like to see them in my Travis builds.
This new reporter offers plenty of customization. Would you rather the name of the test be displayed at start and then a separate message upon success/failure?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No that's perfect, without the dots! It's fairly easy to work out which test is running if you can see which test has just completed so leave it as is.

Copy link
Member

@garethbowen garethbowen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great stuff!

The code is good to go. Please raise a new issue covering your changes and schedule it for 3.6.0 (in AT) and it can be merged once 3.5.0 is out the door.

@dianabarsan
Copy link
Member Author

dianabarsan commented May 27, 2019

@garethbowen
Thanks for the review!
I added a small update to add spec duration to the reporter (like in the image I posted) and to add watches for shared-libs folders to the nodemon api and sentinel commands. Could you please review that as well? Thanks again!
Also, I created the issue and scheduled it in 3.6.

Copy link
Member

@garethbowen garethbowen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The duration looks great. Good work!

@garethbowen garethbowen merged commit 704e9df into master Jun 19, 2019
@garethbowen garethbowen deleted the fix-error-logging branch June 19, 2019 23:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants