Skip to content

Commit

Permalink
feat!: update nodejs to lts (#142)
Browse files Browse the repository at this point in the history
* feat: update nodejs to lts

* chore: version

* chore: text

* chore: pull in some ci changes

* chore: remove

* chore: deps

* chore: package

* chore: regen

* chore: remove peer

* chore: npm install

* chore: npm audit fix

* chore: ignore audit

* chore: jq

* feat: bump packages and remove unused

* chore: update packages

* chore: update test

* chore: mocks

* chore: audit
  • Loading branch information
kleyow authored May 20, 2022
1 parent 71d1f1f commit f2a352c
Show file tree
Hide file tree
Showing 12 changed files with 23,485 additions and 6,202 deletions.
111 changes: 87 additions & 24 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ version: 2.1
orbs:
anchore: anchore/[email protected]
github-release: h-matsuo/[email protected]
slack: circleci/[email protected]
slack: circleci/[email protected] # Ref: https://github.com/mojaloop/ci-config/tree/master/slack-templates
pr-tools: mojaloop/[email protected] # Ref: https://github.com/mojaloop/ci-config/

##
# defaults
Expand All @@ -21,7 +22,8 @@ defaults_Dependencies: &defaults_Dependencies |
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++ python libtool autoconf automake jq
apk --no-cache add bash
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

Expand All @@ -41,6 +43,13 @@ defaults_license_scanner: &defaults_license_scanner
git clone https://github.com/mojaloop/license-scanner /tmp/license-scanner
cd /tmp/license-scanner && make build default-files set-up
defaults_export_version_from_package: &defaults_export_version_from_package
name: Format the changelog into the github release body and get release tag
command: |
git diff --no-indent-heuristic master~1 HEAD CHANGELOG.md | sed -n '/^+[^+]/ s/^+//p' > /tmp/changes
echo 'export RELEASE_CHANGES=`cat /tmp/changes`' >> $BASH_ENV
echo 'export RELEASE_TAG=`cat package-lock.json | jq -r .version`' >> $BASH_ENV
##
# Executors
#
Expand All @@ -50,11 +59,11 @@ executors:
default-docker:
working_directory: /home/circleci/project
docker:
- image: node:12.16.1-alpine
- image: node:16.15.0-alpine

default-machine:
machine:
image: ubuntu-1604:201903-01
image: ubuntu-2004:202010-01

##
# Jobs
Expand Down Expand Up @@ -83,6 +92,19 @@ jobs:
paths:
- node_modules

test-lint:
executor: default-docker
steps:
- run:
name: Install general dependencies
command: *defaults_Dependencies
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "package-lock.json" }}
- run:
name: Execute lint tests
command: npm run lint

test-unit:
executor: default-docker
steps:
Expand All @@ -105,7 +127,7 @@ jobs:
path: ./test/results
- store_test_results:
path: ./test/results

test-bdd:
executor: default-docker
steps:
Expand Down Expand Up @@ -181,7 +203,7 @@ jobs:
npm ci
- run:
name: Create dir for test results
command: |
command: |
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
mkdir -p ./test/results
- run:
Expand Down Expand Up @@ -308,12 +330,23 @@ jobs:
ssh-keyscan -p 443 ssh.github.com >> ~/.ssh/known_hosts
ssh-keyscan github.com >> ~/.ssh/known_hosts
chmod 0200 ~/.ssh/*
- run:
name: Setup Slack config
command: |
echo "export SLACK_PROJECT_NAME=${CIRCLE_PROJECT_REPONAME}" >> $BASH_ENV
echo "export SLACK_RELEASE_TYPE='GitHub Release'" >> $BASH_ENV
echo "export SLACK_RELEASE_TAG='${RELEASE_TAG} on ${CIRCLE_BRANCH} branch'" >> $BASH_ENV
echo "export SLACK_BUILD_ID=${CIRCLE_BUILD_NUM}" >> $BASH_ENV
echo "export SLACK_CI_URL=${CIRCLE_BUILD_URL}" >> $BASH_ENV
- run:
name: Generate changelog and bump package version
command: npm run release
command: npm run release -- --no-verify
- run:
name: Push the release
command: git push --follow-tags origin ${CIRCLE_BRANCH}
- slack/notify:
event: fail
template: SLACK_TEMP_RELEASE_FAILURE

github-release:
executor: default-machine
Expand All @@ -332,25 +365,32 @@ jobs:
git fetch origin
git checkout origin/${CIRCLE_BRANCH}
- run:
# Note: this is rather imperfect, but will do for now
name: Format the changelog into the github release body and get release tag
command: |
git diff --no-indent-heuristic master~1 HEAD CHANGELOG.md | sed -n '/^+[^+]/ s/^+//p' > /tmp/changes
echo 'export RELEASE_CHANGES=`cat /tmp/changes`' >> $BASH_ENV
echo 'export RELEASE_TAG=`cat package.json | jq -r .version`' >> $BASH_ENV
<<: *defaults_export_version_from_package
- run:
name: check the release changes
command: |
echo "Changes are: ${RELEASE_CHANGES}"
- run:
name: Setup Slack config
command: |
echo "export SLACK_PROJECT_NAME=${CIRCLE_PROJECT_REPONAME}" >> $BASH_ENV
echo "export SLACK_RELEASE_TYPE='Github Release'" >> $BASH_ENV
echo "export SLACK_RELEASE_TAG=v${RELEASE_TAG}" >> $BASH_ENV
echo "export SLACK_RELEASE_URL=https://github.com/mojaloop/${CIRCLE_PROJECT_REPONAME}/releases/tag/v${RELEASE_TAG}" >> $BASH_ENV
echo "export SLACK_BUILD_ID=${CIRCLE_BUILD_NUM}" >> $BASH_ENV
echo "export SLACK_CI_URL=${CIRCLE_BUILD_URL}" >> $BASH_ENV
- github-release/create:
github-token-variable: ${GITHUB_TOKEN}
tag: v${RELEASE_TAG}
title: v${RELEASE_TAG} Release
description: ${RELEASE_CHANGES}
file-path: CHANGELOG.md
- slack/status:
webhook: "$SLACK_WEBHOOK_ANNOUNCEMENT"
success_message: '*"${CIRCLE_PROJECT_REPONAME}"* - Release \`"v${RELEASE_TAG}"\` \nhttps://github.com/mojaloop/"${CIRCLE_PROJECT_REPONAME}"/releases/tag/"v${RELEASE_TAG}"'
- slack/notify:
event: pass
template: SLACK_TEMP_RELEASE_SUCCESS
- slack/notify:
event: fail
template: SLACK_TEMP_RELEASE_FAILURE

publish:
executor: default-machine
Expand Down Expand Up @@ -380,12 +420,24 @@ jobs:
docker push $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:latest
echo "Publishing $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:${CIRCLE_TAG}"
docker push $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:${CIRCLE_TAG}
- slack/status:
fail_only: true
webhook: "$SLACK_WEBHOOK_ANNOUNCEMENT_CI_CD"
failure_message: 'Publishing docker image failed for: \`"${DOCKER_ORG}/${CIRCLE_PROJECT_REPONAME}:${CIRCLE_TAG}"\`'

# temporarily disabled as api-snippets is not compatible with existing license policy
- run:
name: Setup Slack config
command: |
echo 'export RELEASE_TAG=$RELEASE_TAG_SNAPSHOT' >> $BASH_ENV
echo "export SLACK_PROJECT_NAME=${CIRCLE_PROJECT_REPONAME}" >> $BASH_ENV
echo "export SLACK_RELEASE_TYPE='NPM Release'" >> $BASH_ENV
echo "export SLACK_RELEASE_TAG=v${CIRCLE_TAG:1}" >> $BASH_ENV
echo "export SLACK_RELEASE_URL=https://www.npmjs.com/package/@mojaloop/${CIRCLE_PROJECT_REPONAME}/v/${CIRCLE_TAG:1}" >> $BASH_ENV
echo "export SLACK_BUILD_ID=${CIRCLE_BUILD_NUM}" >> $BASH_ENV
echo "export SLACK_CI_URL=${CIRCLE_BUILD_URL}" >> $BASH_ENV
- slack/notify:
event: pass
template: SLACK_TEMP_RELEASE_SUCCESS
- slack/notify:
event: fail
template: SLACK_TEMP_RELEASE_FAILURE

# temporarily disabled as api-snippets is not compatible with existing license policy
# license-scan:
# executor: default-machine
# steps:
Expand Down Expand Up @@ -464,6 +516,17 @@ workflows:
version: 2
build_and_test:
jobs:
- pr-tools/pr-title-check:
context: org-global

- test-lint:
context: org-global
requires:
- setup
filters:
tags:
only: /.*/

- build-local:
context: org-global
filters:
Expand Down Expand Up @@ -550,7 +613,7 @@ workflows:
# TODO: redis related vulnerabilities found
# they are related to external dependency so there is a need for proper action, more info here:
# https://app.circleci.com/pipelines/github/mojaloop/thirdparty-sdk/85/workflows/32f38148-42ba-41fe-a9f3-ece5de28df63/jobs/617
#
#
# - image-scan:
# context: org-global
# requires:
Expand Down Expand Up @@ -604,4 +667,4 @@ workflows:
only: /.*/
branches:
ignore:
- /.*/
- /.*/
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
16.15.0
Loading

0 comments on commit f2a352c

Please sign in to comment.