DEFRA / water-abstraction-team

Guides, info and issue management for the Water Abstraction Team
Other
1 stars 0 forks source link

Stop using version in package.json #107

Closed Cruikshanks closed 4 months ago

Cruikshanks commented 1 year ago

Currently, we have each app report details about itself on a /health/info endpoint. For each app this returns the current commit hash and the version recorded in package.json.

All this then gets shown in our main /service-status endpoint (or /health/info in water-abstraction-system if you want to go direct!)

Normally, when we cut a release we're ok to just take whatever is on main and tag that as the next version. We run npm version [minor|patch] and both the tagging and the updating of the version in package.json is done for us.

But in a recent release main in a couple of the repos contained changes we weren't yet ready to include. No problem, we just have to check out an earlier commit and create the git tag there. This does mean though we can't run npm version and increment the version in package.json.

The issue came when our QA went to /service-status to double-check the versions now running. The commit hashes were all correct; we were running the version of the code we'd tagged for release. But the versions displayed were now out of sync with the git tags.

There are only 3 solutions as far as we can see

Whenever we 'cut' a release we create a tag at the commit we intend to push to production. The tag is our version, not what's in the package.json. So, if all our /health/info endpoints returned the result of git describe --always --tags instead they would be

Cruikshanks commented 1 year ago

For those interested in git describe --always --tags

git describe returns a human-readable name based on the current commit reference, for example, v0.1.0-26-g92a2027.

The command finds the most recent tag that is reachable from a commit. If the tag points to the commit, then only the tag is shown. Otherwise, it suffixes the tag name with the number of additional commits on top of the tagged object and the abbreviated object name of the most recent commit. The result is a "human-readable" object name which can also be used to identify the commit to other git commands.

Git docs for git-describe

Our example v0.1.0-26-g92a2027 broken down means

The g just denotes that the source control system is git.

For reference the git describe --always --tags command broken down means

Cruikshanks commented 4 months ago

All projects updated!