Skip to content

Commit

Permalink
chore(mojaloop/#3434): nodejs upgrade (#394)
Browse files Browse the repository at this point in the history
chore(mojaloop/#3434): nodejs upgrade - mojaloop/project#3434
- Upgraded NodeJS from v16 to v18 LTS
- Updated CI config to use NodeJS latest LTS version
- Updated CI config to display runtime versions for each job
- Upgraded NPM dependencies
- Fixed CI bugs caused by the NodeJS upgrade
- Updated CI pipeline use NVM to select node version from` .nvmrc` file
- Upgraded circleci orbs
- Migrated `master` branch to `main`
- Added `.versionrc`
- Refactor/reorganize the integration test setup
  • Loading branch information
oderayi authored Sep 11, 2023
1 parent 55b5de6 commit 09b1847
Show file tree
Hide file tree
Showing 30 changed files with 5,948 additions and 20,689 deletions.
429 changes: 285 additions & 144 deletions .circleci/config.yml

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions .ncurc.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
## Add a TODO comment indicating the reason for each rejected dependency upgrade added to this list, and what should be done to resolve it (i.e. handle it through a story, etc).
reject: [
# TODO: v6+ (ref: https://github.com/sindresorhus/get-port/releases/tag/v6.0.0) is an ESM library and thus not compatible with CommonJS. Future story needed to resolve.
"get-port",
# @hapi/catbox-memory v6 and onwards breaks tests. Needs investigation.
"@hapi/catbox-memory"
]
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16.15.0
18.17.1
16 changes: 16 additions & 0 deletions .versionrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"types": [
{"type": "feat", "section": "Features"},
{"type": "fix", "section": "Bug Fixes"},
{"type": "docs", "section": "Documentation"},
{"type": "style", "section": "Styling"},
{"type": "refactor", "section": "Refactors"},
{"type": "perf", "section": "Performance"},
{"type": "test", "section": "Tests"},
{"type": "build", "section": "Build System"},
{"type": "ci", "section": "CI"},
{"type": "chore", "section": "Chore"},
{"type": "revert", "section": "Reverts"}
]
}

24 changes: 18 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
FROM node:16.15.0-alpine as builder
# Arguments
ARG NODE_VERSION=lts-alpine

# NOTE: Ensure you set NODE_VERSION Build Argument as follows...
#
# export NODE_VERSION="$(cat .nvmrc)-alpine" \
# docker build \
# --build-arg NODE_VERSION=$NODE_VERSION \
# -t mojaloop/sdk-scheme-adapter:local \
# . \
#

# Build Image
FROM node:${NODE_VERSION} as builder

USER root

WORKDIR /opt/app/

RUN apk add --no-cache -t build-dependencies git make gcc g++ python3 libtool autoconf automake \
&& cd $(npm root -g)/npm \
&& npm config set unsafe-perm true \
&& npm install -g node-gyp
RUN apk add --no-cache -t build-dependencies git make gcc g++ python3 libtool autoconf automake bash \
&& cd $(npm root -g)/npm

COPY package.json package-lock.json* /opt/app/
RUN npm ci
Expand All @@ -16,7 +28,7 @@ COPY scripts /opt/app/scripts
COPY src /opt/app/src
COPY README.md /opt/app

FROM node:16.15.0-alpine
FROM node:${NODE_VERSION}
WORKDIR /opt/app/

# Create empty log file & link stdout to the application log file
Expand Down
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# central-settlements
[![Git Commit](https://img.shields.io/github/last-commit/mojaloop/central-settlement.svg?style=flat)](https://github.com/mojaloop/central-settlement/commits/master)
[![Git Commit](https://img.shields.io/github/last-commit/mojaloop/central-settlement.svg?style=flat)](https://github.com/mojaloop/central-settlement/commits/main)
[![Git Releases](https://img.shields.io/github/release/mojaloop/central-settlement.svg?style=flat)](https://github.com/mojaloop/central-settlement/releases)
[![Docker pulls](https://img.shields.io/docker/pulls/mojaloop/central-settlement.svg?style=flat)](https://hub.docker.com/r/mojaloop/central-settlement)
[![CircleCI](https://circleci.com/gh/mojaloop/central-settlement.svg?style=svg)](https://app.circleci.com/pipelines/github/mojaloop/central-settlement)
Expand Down Expand Up @@ -64,9 +64,9 @@ Running integration tests (narrow)
If you want to run integration tests in a repetitive manner, you can startup the test containers using `docker-compose`, login to running `central-settlement` container like so:

```bash
docker-compose -f docker-compose.yml -f docker-compose.integration.yml up
npm run docker:build && npm run docker:up

#first time only:
#first time only (in a new shell):
docker exec -it cs_central-ledger sh
npm run migrate

Expand All @@ -77,19 +77,21 @@ npm run test:int

## Auditing Dependencies

We use `npm-audit-resolver` along with `npm audit` to check dependencies for node vulnerabilities, and keep track of resolved dependencies with an `audit-resolve.json` file.
We use `audit-ci` along with `npm audit` to check dependencies for node vulnerabilities, and keep track of resolved dependencies with an `audit-ci.jsonc` file.

To start a new resolution process, run:

```bash
npm run audit:resolve
npm run audit:fix
```

You can then check to see if the CI will pass based on the current dependencies with:

```bash
npm run audit:check
```

And commit the changed `audit-resolv.json` to ensure that CircleCI will build correctly.
The [audit-ci.jsonc](./audit-ci.jsonc) contains any audit-exceptions that cannot be fixed to ensure that CircleCI will build correctly.

## Container Scans

Expand Down
10 changes: 6 additions & 4 deletions audit-ci.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@
"GHSA-phwq-j96m-2c2q",
"GHSA-7hx8-2rxv-66xv",
"GHSA-282f-qqgm-c34q",
"GHSA-8cf7-32gw-wr33",
"GHSA-hjrf-2m68-5959",
"GHSA-qwph-4952-7xr6",
"GHSA-4jv9-3563-23j3",
"GHSA-6vfc-qv3f-vr6c",
"GHSA-wc69-rhjr-hc9g",
"GHSA-f825-f98c-gj3g",
"GHSA-g954-5hwp-pp24",
"GHSA-rjqq-98f6-6j3r",
"GHSA-mjxr-4v3x-q3m4",
"GHSA-rjqq-98f6-6j3r",
"GHSA-g64q-3vg8-8f93",
"GHSA-5854-jvxx-2cg9",
"GHSA-2mvq-xp48-4c77",
"GHSA-w5p7-h5w8-2hfq",
"GHSA-qgmg-gppg-76g5",
"GHSA-p9pc-299p-vxgp"
Expand Down
2 changes: 1 addition & 1 deletion config/default.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"PORT": 3007,
"HOSTNAME": "http://central-settlements.local",
"HOSTNAME": "http://central-settlement",
"DATABASE": {
"DIALECT": "mysql",
"HOST": "localhost",
Expand Down
127 changes: 0 additions & 127 deletions docker-compose.integration.yml

This file was deleted.

Loading

0 comments on commit 09b1847

Please sign in to comment.