Package versioning
This document outlines our versioning standards for packages and how to manage breaking changes.
Note
This document is relevant mostly for code in packages. We rarely update the package versions on services or clients.
Package versioning standards
Our package versioning is based on Semantic Versioning. The package versions have the format MAJOR.MINOR.PATCH
- MAJOR version when you make incompatible API change
- MINOR version when you add functionality in a backwards compatible manner
- PATCH version when you make backwards compatible bug fixes
PATCH version update Example
Assume the original package version of utils package is 4.1.7
{
"name": "@bhag-business-platform/luna-utils",
"version": "4.1.7",
...
}There is a method in utils package
export const getCurrentDailyRate = (
rateHistory: RateHistory[],
date: string = getLocalISODate()
): number => {
const rate = rateHistory.filter(r => r.start <= date && r.end >= date);
return rate.amount;
};This method could throw a null pointer exception is rate is null. So you fix the bug
export const getCurrentDailyRate = (
rateHistory: RateHistory[],
date: string = getLocalISODate()
): number => {
const rate = rateHistory?.filter(r => r.start <= date && r.end >= date);
return rate?.amount ?? 0;
};This bug fix doesn't break the contract of the method so its backward compatible. In this case the Patch version of the package will be update and new package version will be 4.1.8
MINOR version update Example
Assume the original package version of utils package is 4.1.7
{
"name": "@bhag-business-platform/luna-utils",
"version": "4.1.7",
...
}and you have added a new util which didn't exist before
export const getEngagementWorkGroups = (engagement) =>
engagement.roleGroups.filter((rg) => !rg.parentGroupId);The addition of the util is backward compatible. In this case the Minor version will be updated and new package version will be 4.2.0
MAJOR version update Example
Assume the original package version of core package is 4.1.7
{
"name": "@bhag-business-platform/luna-core",
"version": "4.1.7",
...
}and you modify the dietaryRequirement in AndiDetails from string to string[]
export interface AndiDetails {
id: string;
andiId?: string;
type?: string;
title: string;
firstName: string;
lastName: string;
knownAs?: string;
dietaryRequirement?: string;
}dietaryRequirement is string[] in the updated AndiDetails
export interface AndiDetails {
id: string;
andiId?: string;
type?: string;
title: string;
firstName: string;
lastName: string;
knownAs?: string;
dietaryRequirement?: string[];
}The above is a breaking change and not backward compatible. In this case the Major version will be updated and new package version will be 5.0.0
Managing breaking changes
If you are making a breaking change, then there are a few things you need to keep in mind before merging the change.
Important : Merging a breaking change in a package to main will block others if you have not updated all the other packages/services/clients which need this package.
Follow the below steps if you have made a breaking change to a package assuming the version changed from 4.2.0 to 5.0.0
- Deploy the change to a lower env by merging to
env/<env>branch. For example if made a breaking change toluna-coreand merged the branch toenv/pulsarbranch, it would publish the 5.0.0 version for@bhag-business-platform/luna-corewith a labelenv-pulsar - After the major version updated package is published for an environment, you can import the package in the service/client/package where it is used. For the above case you can use the below command
yarn add @bhag-business-platform/luna-core@env-pulsarOnce you have imported the major version in the service/client/package, do some testing. Make sure
- Code builds successfully
- Unit tests are passing
- Deploy the service/client to a lower environment to make sure everything works
If the above testing succeeds, raise PR for any changes done to service/client/package and after code review is approved, merge all the PRs together or right after each other
Make sure the deployment is successful on staging and do a brush test
Managing security vulnerabilities
Sometimes security audit on a package may start failing because a dependency of the package may have a high security vulnerability. To resolve it, some dependencies for the package may need updating. If there is a major version update for a dependency its always prudent to deploy the package on a lower env, update it in a service or client where it is used and atleast run all unit tests. The steps to do so are described in managing breaking changes section
