-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(mojaloop/#3455): nodejs upgrade (#73)
chore(mojaloop/#3452): NodeJS version upgrade - mojaloop/project#3452 - 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 - Upgraded CircleCI orbs versions - Updated CI pipeline use NVM to select node version from` .nvmrc` file - Replaced [gRPC](https://www.npmjs.com/package/grpc) with [gRPC-js](https://www.npmjs.com/package/@grpc/grpc-js) - optimized logging calls
- Loading branch information
Showing
15 changed files
with
7,720 additions
and
6,603 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,22 +7,21 @@ 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/[email protected] # Ref: https://github.com/mojaloop/ci-config/ | ||
gh: circleci/github-cli@2.1.0 | ||
gh: circleci/github-cli@2.2.0 | ||
|
||
## | ||
# defaults | ||
# | ||
# YAML defaults templates, in alphabetical order | ||
## | ||
defaults_Dependencies: &defaults_Dependencies | | ||
defaults_docker_Dependencies: &defaults_docker_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 | ||
apk add --no-cache -t build-dependencies make gcc g++ python3 libtool autoconf automake jq bash | ||
npm install -g node-gyp | ||
|
||
defaults_awsCliDependencies: &defaults_awsCliDependencies | | ||
|
@@ -38,7 +37,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: | | ||
|
@@ -59,6 +57,58 @@ defaults_configure_git: &defaults_configure_git | |
git config user.email ${GIT_CI_EMAIL} | ||
git config user.name ${GIT_CI_USER} | ||
defaults_configure_nvm: &defaults_configure_nvm | ||
name: Configure NVM | ||
command: | | ||
cd $HOME | ||
export ENV_DOT_PROFILE=$HOME/.profile | ||
touch $ENV_DOT_PROFILE | ||
echo "1. Export env variable" | ||
export NVM_DIR="$HOME/.nvm" | ||
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 | ||
# | ||
|
@@ -67,24 +117,33 @@ defaults_configure_git: &defaults_configure_git | |
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 | ||
|
||
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: | ||
name: Update NPM install | ||
<<: *defaults_configure_nvm | ||
- run: | ||
<<: *defaults_display_versions | ||
- run: | ||
name: Install NPM dependencies | ||
command: npm ci | ||
- save_cache: | ||
key: dependency-cache-{{ .Environment.CIRCLE_SHA1 }} | ||
|
@@ -96,8 +155,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: | ||
|
@@ -109,8 +172,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: | ||
|
@@ -122,8 +189,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: | ||
|
@@ -138,7 +209,7 @@ jobs: | |
command: npm -s run test:xunit | ||
- store_artifacts: | ||
path: ./test/results | ||
prefix: test | ||
destination: test | ||
- store_test_results: | ||
path: ./test/results | ||
|
||
|
@@ -147,19 +218,23 @@ jobs: | |
steps: | ||
- run: | ||
name: Install general dependencies | ||
command: *defaults_Dependencies | ||
command: *defaults_docker_Dependencies | ||
- run: | ||
name: Install AWS CLI dependencies | ||
command: *defaults_awsCliDependencies | ||
- checkout | ||
- run: | ||
<<: *defaults_configure_nvm | ||
- run: | ||
<<: *defaults_display_versions | ||
- restore_cache: | ||
key: dependency-cache-{{ .Environment.CIRCLE_SHA1 }} | ||
- run: | ||
name: Execute code coverage check | ||
command: npm -s run test:coverage-check | ||
- store_artifacts: | ||
path: coverage | ||
prefix: test | ||
destination: test | ||
- store_test_results: | ||
path: coverage | ||
- run: | ||
|
@@ -178,26 +253,30 @@ 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: | ||
name: Create dir for test results | ||
command: mkdir -p ./audit/results | ||
- run: | ||
name: Check for new npm vulnerabilities | ||
command: npm run audit:check --silent -- --json > ./audit/results/auditResults.json | ||
command: npm run audit:check -- -o json > ./audit/results/auditResults.json | ||
- store_artifacts: | ||
path: ./audit/results | ||
prefix: audit | ||
destination: audit | ||
|
||
audit-licenses: | ||
executor: default-docker | ||
steps: | ||
- run: | ||
name: Install general dependencies | ||
command: *defaults_Dependencies | ||
command: *defaults_docker_Dependencies | ||
- run: | ||
<<: *defaults_license_scanner | ||
- checkout | ||
|
@@ -208,14 +287,14 @@ jobs: | |
command: cd /tmp/license-scanner && pathToRepo=$CIRCLE_WORKING_DIRECTORY make run | ||
- store_artifacts: | ||
path: /tmp/license-scanner/results | ||
prefix: licenses | ||
destination: licenses | ||
|
||
release: | ||
executor: default-docker | ||
steps: | ||
- run: | ||
name: Install general dependencies | ||
command: *defaults_Dependencies | ||
command: *defaults_docker_Dependencies | ||
- checkout | ||
- restore_cache: | ||
keys: | ||
|
@@ -287,7 +366,7 @@ jobs: | |
steps: | ||
- run: | ||
name: Install general dependencies | ||
command: *defaults_Dependencies | ||
command: *defaults_docker_Dependencies | ||
- checkout | ||
- restore_cache: | ||
key: dependency-cache-{{ .Environment.CIRCLE_SHA1 }} | ||
|
@@ -330,7 +409,7 @@ jobs: | |
steps: | ||
- run: | ||
name: Install general dependencies | ||
command: *defaults_Dependencies | ||
command: *defaults_docker_Dependencies | ||
- checkout | ||
- restore_cache: | ||
key: dependency-cache-{{ .Environment.CIRCLE_SHA1 }} | ||
|
@@ -372,7 +451,6 @@ jobs: | |
template: SLACK_TEMP_RELEASE_FAILURE | ||
|
||
workflows: | ||
version: 2 | ||
build_and_test: | ||
jobs: | ||
- pr-tools/pr-title-check: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
16.15.0 | ||
18.17.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"$schema": "https://github.com/IBM/audit-ci/raw/main/docs/schema.json", | ||
// audit-ci supports reading JSON, JSONC, and JSON5 config files. | ||
// Only use one of ["low": true, "moderate": true, "high": true, "critical": true] | ||
"moderate": true, | ||
"allowlist": [ | ||
] | ||
} |
Oops, something went wrong.