Skip to content

Commit

Permalink
chore(mojaloop/#3475): NodeJS version upgrade
Browse files Browse the repository at this point in the history
chore(mojaloop/#3475): NodeJS version upgrade - mojaloop/project#3475
- Upgraded nodejs from v16 to v18 LTS
- Applied CI changes as previously implemented in [sdk-scheme-adapter](mojaloop/sdk-scheme-adapter#453)
- Updated NPM dependencies
- Re-implement husky integration due to API changes in husky's latest version
- Replaced deprecated `ttypescript` with `ts-patch` to allow for `typescript` upgrade
- Resolved all audit issues
  • Loading branch information
oderayi authored Aug 17, 2023
1 parent 8d43124 commit d42f85a
Show file tree
Hide file tree
Showing 16 changed files with 6,094 additions and 9,279 deletions.
127 changes: 94 additions & 33 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,29 @@ version: 2.1
# Orbs used in this pipeline
##
orbs:
slack: circleci/slack@4.9.3 # Ref: https://github.com/mojaloop/ci-config/tree/master/slack-templates
slack: circleci/slack@4.12.5 # Ref: https://github.com/mojaloop/ci-config/tree/master/slack-templates
pr-tools: mojaloop/pr-tools@0.1.10 # Ref: https://github.com/mojaloop/ci-config/
gh: circleci/github-cli@2.1.0

##
# defaults
#
# YAML defaults templates, in alphabetical order
# YAML defaults templates
##
defaults_Dependencies: &defaults_Dependencies |
apk --no-cache add git
apk --no-cache add ca-certificates
apk --no-cache add curl
apk --no-cache add openssh-client
apk add --no-cache -t build-dependencies make gcc g++ python3 libtool autoconf automake jq
npm config set unsafe-perm true
npm install -g node-gyp

## Default 'default-docker' executor dependencies
defaults_docker_Dependencies: &defaults_docker_Dependencies |
apk --no-cache add coreutils
apk --no-cache add util-linux pciutils usbutils coreutils binutils findutils grep iproute2
apk --no-cache add git
apk --no-cache add ca-certificates
apk --no-cache add curl
apk --no-cache add openssh-client
apk --no-cache add bash bash-doc bash-completion
apk --no-cache add -t build-dependencies make gcc g++ python3 libtool autoconf automake

defaults_awsCliDependencies: &defaults_awsCliDependencies |
apk --no-cache add aws-cli
apk --no-cache add aws-cli

defaults_license_scanner: &defaults_license_scanner
name: Install and set up license-scanner
Expand All @@ -38,7 +41,6 @@ defaults_npm_auth: &defaults_npm_auth
name: Update NPM registry auth token
command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc


defaults_npm_publish_release: &defaults_npm_publish_release
name: Publish NPM $RELEASE_TAG artifact
command: |
Expand All @@ -62,14 +64,54 @@ defaults_configure_git: &defaults_configure_git
defaults_configure_nvm: &defaults_configure_nvm
name: Configure NVM
command: |
touch $HOME/.profile
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
cd $HOME
export ENV_DOT_PROFILE=$HOME/.profile
touch $ENV_DOT_PROFILE
echo "1. Export env variable"
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
echo "Installing Node version: $(cat .nvmrc)"
nvm install $(cat .nvmrc)
nvm alias default $(cat .nvmrc)
nvm use $(cat .nvmrc)
if [ -z "$NVMRC_VERSION" ]; then
echo "==> Configuring NVMRC_VERSION!"
export NVMRC_VERSION=$(cat $CIRCLE_WORKING_DIRECTORY/.nvmrc)
echo "export NVMRC_VERSION=$NVMRC_VERSION" >> $ENV_DOT_PROFILE
fi
if [ -f "$NVM_DIR" ]; then
echo "==> $NVM_DIR exists. Skipping steps 2-4!"
else
echo "==> $NVM_DIR does not exists. Executing steps 2-4!"
echo "2. Installing NVM"
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
echo "3. Executing $NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
fi
## Ref: https://github.com/nvm-sh/nvm/issues/1102#issuecomment-550572252
if [ ! -z "$NVM_ARCH_UNOFFICIAL_OVERRIDE" ]; then
echo "==> Handle NVM_ARCH_UNOFFICIAL_OVERRIDE=$NVM_ARCH_UNOFFICIAL_OVERRIDE!"
echo "nvm_get_arch() { nvm_echo \"${NVM_ARCH_UNOFFICIAL_OVERRIDE}\"; }" >> $ENV_DOT_PROFILE
echo "export NVM_NODEJS_ORG_MIRROR=https://unofficial-builds.nodejs.org/download/release" >> $ENV_DOT_PROFILE
source $ENV_DOT_PROFILE
fi
echo "4. Installing Node version: $NVMRC_VERSION"
nvm install $NVMRC_VERSION
nvm alias default $NVMRC_VERSION
nvm use $NVMRC_VERSION
cd $CIRCLE_WORKING_DIRECTORY
defaults_display_versions: &defaults_display_versions
name: Display Versions
command: |
echo "What is the active version of Nodejs?"
echo "node: $(node --version)"
echo "yarn: $(yarn --version)"
echo "npm: $(npm --version)"
echo "nvm: $(nvm --version)"
##
# Executors
Expand All @@ -79,28 +121,36 @@ defaults_configure_nvm: &defaults_configure_nvm
executors:
default-docker:
working_directory: &WORKING_DIR /home/circleci/project
shell: "/bin/sh -leo pipefail" ## Ref: https://circleci.com/docs/env-vars/#alpine-linux
environment:
BASH_ENV: /etc/profile ## Ref: https://circleci.com/docs/env-vars/#alpine-linux
NVM_ARCH_UNOFFICIAL_OVERRIDE: x64-musl ## Ref: https://github.com/nvm-sh/nvm/issues/1102#issuecomment-550572252
docker:
- image: node:16.14.2-alpine

- image: node:lts-alpine # Ref: https://hub.docker.com/_/node?tab=tags&page=1&name=alpine
default-machine:
working_directory: *WORKING_DIR
shell: "/bin/bash -leo pipefail"
machine:
image: ubuntu-2004:current
image: ubuntu-2204:2023.04.2 # Ref: https://circleci.com/developer/machine/image/ubuntu-2204

jobs:
setup:
executor: default-docker
steps:
- run:
name: Install general dependencies
command: *defaults_Dependencies
command: *defaults_docker_Dependencies
- checkout
- run:
<<: *defaults_configure_nvm
- run:
name: Update NPM install
<<: *defaults_display_versions
- run:
name: Install NPM dependencies
command: npm ci
- save_cache:
name: Save dependency cache
key: dependency-cache-{{ .Environment.CIRCLE_SHA1 }}
paths:
- node_modules
Expand All @@ -110,11 +160,14 @@ jobs:
steps:
- run:
name: Install general dependencies
command: *defaults_Dependencies
command: *defaults_docker_Dependencies
- checkout
- run:
<<: *defaults_configure_nvm
- run:
<<: *defaults_display_versions
- restore_cache:
name: Restore dependency cache
key: dependency-cache-{{ .Environment.CIRCLE_SHA1 }}
- run:
name: Execute dependency tests
Expand All @@ -125,10 +178,12 @@ jobs:
steps:
- run:
name: Install general dependencies
command: *defaults_Dependencies
command: *defaults_docker_Dependencies
- checkout
- run:
<<: *defaults_configure_nvm
- run:
<<: *defaults_display_versions
- restore_cache:
key: dependency-cache-{{ .Environment.CIRCLE_SHA1 }}
- run:
Expand All @@ -144,10 +199,12 @@ jobs:
steps:
- run:
name: Install general dependencies
command: *defaults_Dependencies
command: *defaults_docker_Dependencies
- checkout
- run:
<<: *defaults_configure_nvm
- run:
<<: *defaults_display_versions
- restore_cache:
key: dependency-cache-{{ .Environment.CIRCLE_SHA1 }}
- run:
Expand All @@ -170,10 +227,12 @@ jobs:
steps:
- run:
name: Install general dependencies
command: *defaults_Dependencies
command: *defaults_docker_Dependencies
- checkout
- run:
<<: *defaults_configure_nvm
- run:
<<: *defaults_display_versions
- restore_cache:
key: dependency-cache-{{ .Environment.CIRCLE_SHA1 }}
- run:
Expand All @@ -191,10 +250,10 @@ jobs:
steps:
- run:
name: Install general dependencies
command: *defaults_Dependencies
command: *defaults_docker_Dependencies
- checkout
- run:
<<: *defaults_license_scanner
- checkout
- run:
<<: *defaults_configure_nvm
- restore_cache:
Expand All @@ -211,11 +270,12 @@ jobs:
steps:
- run:
name: Install general dependencies
command: *defaults_Dependencies
command: *defaults_docker_Dependencies
- checkout
- run:
<<: *defaults_configure_nvm
- restore_cache:
name: Restore dependency cache
keys:
- dependency-cache-{{ .Environment.CIRCLE_SHA1 }}
- run:
Expand All @@ -240,6 +300,7 @@ jobs:

github-release:
executor: default-machine
shell: "/bin/bash -eo pipefail"
steps:
- run:
name: Install git
Expand Down Expand Up @@ -287,7 +348,7 @@ jobs:
steps:
- run:
name: Install general dependencies
command: *defaults_Dependencies
command: *defaults_docker_Dependencies
- checkout
- restore_cache:
keys:
Expand Down Expand Up @@ -328,7 +389,7 @@ jobs:
steps:
- run:
name: Install general dependencies
command: *defaults_Dependencies
command: *defaults_docker_Dependencies
- checkout
- restore_cache:
keys:
Expand Down
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx commitlint --edit $1
4 changes: 4 additions & 0 deletions .husky/post-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

git update-index --again
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx lint-staged; npm run test:unit
11 changes: 0 additions & 11 deletions .ncurc.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
module.exports = {
reject: [
// Upgrading past husky@4 to involves a full config migration with no current and apparent benefit.
// So we are just sticking to husky@4.x.x for the time being.
'husky',
// Transpiler currently fails. TODO: Story to investigate and fix.
'openapi-typescript',
// 10.1.0 is a breaking change and has some issues
'@apidevtools/json-schema-ref-parser',
// Upgrading typescript to 5.0.4 causing unit test failures due to breaking changes related to `ttypescript` for 'custom transformers'
'typescript',
// TODO: The new version of npm-check-updates uses new Glob v9.x and it is introducing a dependency Package "path-scurry@1.6.1" which is licensed under "BlueOak-1.0.0" which is not permitted by the Mojaloop License Policy
'npm-check-updates',
// TODO: Upgrading ts-auto-mock is breaking the npm install
'ts-auto-mock'
]
}
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
55 changes: 0 additions & 55 deletions audit-resolve.json
Original file line number Diff line number Diff line change
@@ -1,55 +0,0 @@
{
"decisions": {
"1523|json-refs>graphlib>lodash": {
"decision": "fix",
"madeAt": 1594874545630
},
"1523|json-refs>lodash": {
"decision": "fix",
"madeAt": 1594874545630
},
"1673|json-refs>graphlib>lodash": {
"decision": "fix",
"madeAt": 1620349428789
},
"1673|json-refs>lodash": {
"decision": "fix",
"madeAt": 1620349428789
},
"1677|openapi-typescript>meow>normalize-package-data>hosted-git-info": {
"decision": "fix",
"madeAt": 1620349441428
},
"1677|openapi-typescript>meow>read-pkg-up>read-pkg>normalize-package-data>hosted-git-info": {
"decision": "ignore",
"madeAt": 1628212241952,
"expiresAt": 1630804238026
},
"1753|openapi-typescript>meow>trim-newlines": {
"decision": "fix",
"madeAt": 1623946682346
},
"1773|openapi-typescript>meow>normalize-package-data>resolve>path-parse": {
"decision": "fix",
"madeAt": 1628651158363
},
"1773|openapi-typescript>meow>read-pkg-up>read-pkg>normalize-package-data>resolve>path-parse": {
"decision": "fix",
"madeAt": 1628651158363
},
"1773|ttypescript>resolve>path-parse": {
"decision": "fix",
"madeAt": 1628651158363
},
"1081677|undici": {
"decision": "ignore",
"madeAt": 1658705873542
},
"1081697|undici": {
"decision": "ignore",
"madeAt": 1658705876146
}
},
"rules": {},
"version": 1
}
Original file line number Diff line number Diff line change
Expand Up @@ -386,12 +386,12 @@ paths:
/requestToPayTransfer/{transactionRequestId}:
put:
summary: >-
Continues a transfer that has paused at the Authentication stage in order to accept
Continues a transfer that has paused at the otp stage in order to accept
or reject quote
description: >
This request is used to continue a requestToPayTransfer initiated via
the `POST /requestToPayTransfer` method that has halted after Quotation
stage and/or Authentication stage.
the `POST /requestToPayTransfer` method that has halted after quotation
stage and/or otp stage.
The request body should contain either the "acceptOTP" or "acceptQuote"
Expand Down
6 changes: 2 additions & 4 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ module.exports = {
},
globals: {
'ts-jest': {
compiler: 'ttypescript'
compiler: 'ts-patch/compiler'
}
},
setupFiles: [
'<rootDir>config.ts'
]
setupFiles: ['<rootDir>config.ts']
}
Loading

0 comments on commit d42f85a

Please sign in to comment.