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

improved monorepo docs #2969

Merged
merged 1 commit into from
Jan 6, 2020
Merged

improved monorepo docs #2969

merged 1 commit into from
Jan 6, 2020

Conversation

onursumer
Copy link
Member

Added tips for dependency management and package.json updates.

Checks

  • Has tests or has a separate issue that describes the types of test that should be created. If no test is included it should explicitly be mentioned in the PR why there is no test.
  • The commit log is comprehensible. It follows 7 rules of great commit messages. For most PRs a single commit should suffice, in some cases multiple topical commits can be useful. During review it is ok to see tiny commits (e.g. Fix reviewer comments), but right before the code gets merged to master or rc branch, any such commits should be squashed since they are useless to the other developers. Definitely avoid merge commits, use rebase instead.
  • Is this PR adding logic based on one or more clinical attributes? If yes, please make sure validation for this attribute is also present in the data validation / data loading layers (in backend repo) and documented in File-Formats Clinical data section!

Any screenshots or GIFs?

If this is a new visual feature please add a before/after screenshot or gif
here with e.g. GifGrabber.

Notify reviewers

Read our Pull request merging
policy
. It can help to figure out who worked on the
file before you. Please use git blame <filename> to determine that
and notify them either through slack or by assigning them as a reviewer on the PR

README.md Outdated

Since now all the packages live under a single repository it might be confusing how to import different modules into the file you're working on.

If you are working on `cbioportal-frontend` repository feel free to import any module from any package under `packages`. When importing from internal packages always use import statements like `import {something} from 'cbioportal-frontend-commons'`. Never do under any circumstances something like `import {something} from ../../packages/cbioportal-frontend-commons/src/lib/someLib` or `import {something} from ../../packages/react-mutation-mapper/src/component/someComponent`. Treat internal packages like any other npm package you would import.
Copy link
Member

Choose a reason for hiding this comment

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

might be good to have a circle ci check or github action for this at some point, could be as simple as

git grep -q "../packages/" src/** && exit 1

Copy link
Member

Choose a reason for hiding this comment

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

but maybe this is already caught by the build process itself?

README.md Outdated

If you are working on `cbioportal-frontend` repository feel free to import any module from any package under `packages`. When importing from internal packages always use import statements like `import {something} from 'cbioportal-frontend-commons'`. Never do under any circumstances something like `import {something} from ../../packages/cbioportal-frontend-commons/src/lib/someLib` or `import {something} from ../../packages/react-mutation-mapper/src/component/someComponent`. Treat internal packages like any other npm package you would import.

Avoid circular dependencies at all costs. For example, while it is okay to import a module from `cbioportal-frontend-commons` in `react-mutation-mapper`, there should not be any imports from `react-mutation-mapper` in `cbioportal-frontend-commons`. If you happen to need some component from from `react-mutation-mapper` in `cbioportal-frontend-commons`, consider moving that component into `cbioportal-frontend-commons` package.
Copy link
Member

Choose a reason for hiding this comment

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

does adding a circular dependency result in some error while building?

README.md Outdated

### Updating existing packages

Whenever you need to update code under packages, you should also consider updating the version number in the corresponding `package.json` as well as the dependencies of other packages depending on the package you updated. For example if you update the `cbioportal-frontend-commons` version from`0.1.1` to `0.1.2`, corresponding `cbioportal-frontend-commons` dependency in the `package.json` for `react-mutation-mapper` and `cbioportal-frontend` should also be updated to the new version.
Copy link
Member

Choose a reason for hiding this comment

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

is there a lerna or yarn workspace command that can help with this?

README.md Outdated
Comment on lines 284 to 297
### Updating existing packages

Whenever you need to update code under packages, you should also consider updating the version number in the corresponding `package.json` as well as the dependencies of other packages depending on the package you updated. For example if you update the `cbioportal-frontend-commons` version from`0.1.1` to `0.1.2`, corresponding `cbioportal-frontend-commons` dependency in the `package.json` for `react-mutation-mapper` and `cbioportal-frontend` should also be updated to the new version.
Copy link
Member

Choose a reason for hiding this comment

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

kinda same here as with other comments. Should prolly be some ci or lerna/yarn build failure when trying to build something that refers to an older version of a package included in the monorepo? I guess in some cases this might be desired behavior but ideally we would avoid that

Copy link
Member

@inodb inodb left a comment

Choose a reason for hiding this comment

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

Thanks @onursumer ! This looks good to me

If necessary we can open some issues about the questions I raised. I think ideally most of these things would be taken care of by the build process, so developers are alerted early about these pitfalls. If that's not the case or the messages the build process spits out are too cryptic, we can add some CI checks

@jjgao jjgao temporarily deployed to cbioportal-f-monorepo-d-kibvex January 6, 2020 16:16 Inactive
@alisman
Copy link
Collaborator

alisman commented Jan 6, 2020

@Luke-Sikina have a look at the documentation for monorepo and let me know what you think

Copy link
Member

@Luke-Sikina Luke-Sikina left a comment

Choose a reason for hiding this comment

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

Few tiny things, but it looks reasonable. Any comment prefixed Suggestion: is optional. As far as the updating of version numbers goes, is there a simple way to make sure we corrected the version numbers of all workspaces that depend on the one we changed?

@@ -271,6 +271,31 @@ In order to add a new workspace, one should create a new directory under `packag

Copy link
Member

Choose a reason for hiding this comment

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

Line 268 typo: pakcages instead of packages

@@ -271,6 +271,31 @@ In order to add a new workspace, one should create a new directory under `packag

Suggested way to add a new dependency to an existing workspace is to run `yarn workspace <workspace name> add <package name>` instead of just `yarn add <package name>`. For example, run `yarn workspace cbioportal-frontend add lodash` instead of `yarn add lodash`. Similarly to remove a package run `yarn workspace <workspace name> remove <package name>`.

### Tips for dependency management
Copy link
Member

Choose a reason for hiding this comment

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

Suggestion: add a subheading titled Adding a New Workspace before line 270. You already have the information, but it doesn't stand out.

The cBioPortal uses a monrepo. In a monorepo, multiple related packages are housed in single repository and published separately. E.g. the main portal project (cbioportal-frontend) lives in the same repository as the libraries which it uses, but which are also
published for use by other projects. Please abide by the following rules for working in a monorepo:

1. If you are working on `cbioportal-frontend` repository, import modules from packages using the package's alias:
Copy link
Member

Choose a reason for hiding this comment

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

Nice. I like these tips.

README.md Outdated

Remember that the packages are used by other projects and compatibility needs to be carefully managed.

Whenever you need to update code under packages, you should also consider updating the version number in the corresponding `package.json` as well as the dependencies of other packages depending on the package you updated. For example if you update the `cbioportal-frontend-commons` version from`0.1.1` to `0.1.2`, corresponding `cbioportal-frontend-commons` dependency in the `package.json` for `react-mutation-mapper` and `cbioportal-frontend` should also be updated to the new version.
Copy link
Member

Choose a reason for hiding this comment

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

from0.1.1
you're missing a space character.

@alisman alisman merged commit f9316d7 into master Jan 6, 2020
@alisman alisman deleted the monorepo-docs-update branch January 6, 2020 22:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants