Skip to content

Commit

Permalink
PCQ-1547 Update version file to YAML and match required format for HM…
Browse files Browse the repository at this point in the history
…CTS healthcheck module
  • Loading branch information
bradley-hmcts committed Oct 18, 2022
1 parent fe0da4c commit dc84a9b
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
!config/**
!test
!createVersionFile.js
!version.json
!version
!.git
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ coverage
/test/end-to-end/output/**
package-lock.json
yarn-error.log
version.json
version
.scannerwork/
infrastructure/.terraform
/mochawesome-report/
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ FROM base as runtime
COPY --from=build ${WORKDIR}/app app/
COPY --from=build ${WORKDIR}/config config/
COPY --from=build ${WORKDIR}/public public/
COPY --from=build ${WORKDIR}/server.js ${WORKDIR}/app.js ${WORKDIR}/version.json ./
COPY --from=build ${WORKDIR}/server.js ${WORKDIR}/app.js ${WORKDIR}/version ./
EXPOSE 4000
CMD ["yarn", "start" ]

10 changes: 1 addition & 9 deletions app/healthcheck.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ const healthcheck = require('@hmcts/nodejs-healthcheck');
const logger = require('app/components/logger')('Init');
const os = require('os');
const config = require('config');
const osHostname = os.hostname();
const version = require('../version.json');
const gitCommitId = version.commit;
const gitRevision = process.env.GIT_REVISION;

const checks = {};
const readinessChecks = {};
Expand Down Expand Up @@ -35,14 +31,10 @@ const setup = app => {
name: config.service.name,
host: os.hostname(),
uptime: process.uptime(),
version: gitRevision,
gitCommitId
}
});
};

module.exports = {
setup: setup,
osHostname: osHostname,
gitCommitId: gitCommitId
setup: setup
};
5 changes: 3 additions & 2 deletions createVersionFile.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const git = require('git-rev-sync');
const yaml = require('js-yaml');
const readFileSync = require('fs').readFileSync;
const writeFileSync = require('fs').writeFileSync;

Expand Down Expand Up @@ -30,14 +31,14 @@ function getAppVersion() {
}

function createVersionFile() {
const versionFilePath = `${process.env.NODE_PATH || '.'}/version.json`;
const versionFilePath = `${process.env.NODE_PATH || '.'}/version`;
const fileData = {
version: getAppVersion(),
commit: getCommitHash(),
date: getCommitDate(),
};

writeFileSync(versionFilePath, JSON.stringify(fileData));
writeFileSync(versionFilePath, yaml.dump(fileData, {}));
}

createVersionFile();
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "protected-characteristics-frontend",
"description": "Protected Characteristics web app",
"version": "1.2.46",
"version": "1.2.47",
"license": "MIT",
"engines": {
"node": ">=14.18.1"
Expand Down Expand Up @@ -72,7 +72,7 @@
"https-proxy-agent": "^2.2.4",
"i18next": "^17.0.11",
"ioredis": "^4.27.2",
"js-yaml": "^3.13.1",
"js-yaml": "^4.1.0",
"jsonwebtoken": "^8.5.1",
"launchdarkly-node-server-sdk": "^5.14.4",
"lodash": "^4.17.21",
Expand Down
2 changes: 1 addition & 1 deletion test/mutation/stryker.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports = {
'!app.js',
'!server.js',
'!package.json',
'!version.json',
'!version',
'!app/**',
'!config/*',
'!test/**'
Expand Down
3 changes: 0 additions & 3 deletions test/route/app/healthcheck.int.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const {expect} = require('chai');
const app = require('app');
const request = require('supertest');
const healthcheck = require('app/healthcheck');
const commonContent = require('app/resources/en/translation/common');

describe('healthcheck.js', () => {
Expand All @@ -17,8 +16,6 @@ describe('healthcheck.js', () => {
}
expect(res.body).to.have.property('name').and.equal(commonContent.serviceName);
expect(res.body).to.have.property('status').and.equal('UP');
expect(res.body).to.have.property('host').and.equal(healthcheck.osHostname);
expect(res.body).to.have.property('gitCommitId').and.equal(healthcheck.gitCommitId);
done();
});
});
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9834,7 +9834,7 @@ __metadata:
https-proxy-agent: ^2.2.4
i18next: ^17.0.11
ioredis: ^4.27.2
js-yaml: ^3.13.1
js-yaml: ^4.1.0
jsonwebtoken: ^8.5.1
launchdarkly-node-server-sdk: ^5.14.4
lodash: ^4.17.21
Expand Down

0 comments on commit dc84a9b

Please sign in to comment.