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

docs(guidelines): add dependencies guidelines #4040

Merged
merged 20 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ For experimental package changes, see the [experimental CHANGELOG](experimental/

### :books: (Refine Doc)

* docs(guidelines): add dependencies guidelines [#4040](https://github.com/open-telemetry/opentelemetry-js/pull/4040)

### :house: (Internal)

## 1.15.1
Expand Down
27 changes: 27 additions & 0 deletions GUIDELINES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# OpenTelemetry JS Code Contribution Guide

This document outlines the essential guidelines for contributing code to the OpenTelemetry JS repository. These guidelines are designed to ensure consistency, stability, and the highest quality of code across the project.

## Dependencies

This section refers to `"dependencies"` and `"devDependencies"` entries in `package.json` file.
It's important to note that not all libraries follow the `semver` convention, and those who do, might occasionally introduce breaking changes due to human errors (like putting breaking API changes in a patch version).
haddasbronfman marked this conversation as resolved.
Show resolved Hide resolved

### "DevDependencies"
haddasbronfman marked this conversation as resolved.
Show resolved Hide resolved

`"devDependencies"` SHOULD be pinned to reduce the risk of autobreaking the build. Since we do not have the option of using the `package-lock.json` file (because the libraries are distributed without it), our control over the version our users will get is limited. By using pinned versions, we prevent potential disruptions caused by using unpinned versions such as `^1.2.3`, which might inadvertently lead to version `1.2.6` with unintended breaking changes.
haddasbronfman marked this conversation as resolved.
Show resolved Hide resolved

As this behavior might leave our users with outdated libraries, we adopt `renovate-bot`. This automated dependency update tool proactively opens pull requests upon the release of new patch/minor/major versions. The complete configuration for renovate-bot can be found in [renovate.json](./renovate.json) file.
haddasbronfman marked this conversation as resolved.
Show resolved Hide resolved

### "Dependencies of the same monorepo"
haddasbronfman marked this conversation as resolved.
Show resolved Hide resolved

All packages of the same monorepo MUST have the same pinned version, as these dependencies are automatically updated on each release by lerna. For instance: all packages under `opentelemetry-js/packages` should consistently maintain the same version, as should those under `opentelemetry-js/experimental/packages`.
haddasbronfman marked this conversation as resolved.
Show resolved Hide resolved

### Third-Party Library Dependencies

Packages categorized as third-party and listed under the `"dependencies"` section (e.g., @grpc/grpc-js, @grpc/proto-loader, shimmer, etc.) should remain unpinned and utilize the caret (`^`) symbol. This strategic approach offers several advantages:
haddasbronfman marked this conversation as resolved.
Show resolved Hide resolved

* Our users could get bug fixes of those 3rd-party packages easily, without waiting for us to update our library.
* In cases where multiple packages have dependencies on different versions of the same package, npm will opt for the most recent version, saving space and preventing potential disruptions.

It's important to acknowledge that this approach does expose users to potential breaking changes arising from either human error or libraries that do not strictly follow to semver conventions. This trade-off is an inherent aspect of this approach.