Skip to content

Commit

Permalink
Merge pull request #108 from mojaloop/feature/#1289MigratedPerformanc…
Browse files Browse the repository at this point in the history
…eChangesforv95Release

### Updated to include Performance Stream migration changes
getSummary
- Added getSummary - returns Summary metric
- Added isInitiated - returns true if the Metrics object has been setup
- Added getDefaultRegister - returns the default registry from the Prom-Client library
- Added units tests for getSummary, isInitiated & getDefaultRegister
- Some minor re-formatting changes
- Added some commented out placeholders in preperation for an upgrade to Prom-Client v12.x in future <-- there is an issue here that needs to be addressed.

### Aligning TS config, setup and build for CI/CD to Mojaloop standards
- Fixes for alignment to TS Mojaloop standards
- Added npm-check-updates and commands for 'dep:check' and 'dep:update'
- Added pre-commit checks for 'dep:check'
- Removed ./lib folder as its not needed anymore. JS will now be compiled into the ./dist folder as per other Mojaloop TS repositories.
  • Loading branch information
mdebarros authored Apr 9, 2020
2 parents e3c84ba + 8012e04 commit bf620a4
Show file tree
Hide file tree
Showing 15 changed files with 1,888 additions and 1,655 deletions.
152 changes: 109 additions & 43 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# CircleCI v2 Config
version: 2

defaults_working_directory: &defaults_working_directory
working_directory: /home/circleci/project

defaults_docker_node: &defaults_docker_node
docker:
- image: mhart/alpine-node:12.16.0
# CircleCI v2.1 Config
version: 2.1

##
# defaults
#
# YAML defaults templates, in alphabetical order
##
defaults_Dependencies: &defaults_Dependencies |
apk --no-cache add git
apk --no-cache add ca-certificates
Expand All @@ -18,6 +16,9 @@ defaults_Dependencies: &defaults_Dependencies |
npm config set unsafe-perm true
npm install -g node-gyp

defaults_Typescript: &defaults_Typescript |
npm run build

defaults_awsCliDependencies: &defaults_awsCliDependencies |
apk --no-cache add \
python \
Expand All @@ -28,29 +29,29 @@ defaults_awsCliDependencies: &defaults_awsCliDependencies |
pip install --upgrade awscli==1.14.5 s3cmd==2.0.1 python-magic
apk -v --purge del py-pip

defaults_license_scanner: &defaults_license_scanner
name: Install and set up license-scanner
command: |
git clone https://github.com/mojaloop/license-scanner /tmp/license-scanner
cd /tmp/license-scanner && make build default-files set-up
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: |
source $BASH_ENV
echo "Publishing tag $RELEASE_TAG"
npm publish --tag $RELEASE_TAG --access public
defaults_npm_publish_version: &defaults_npm_publish
name: Update version to prerelease
command: |
source $BASH_ENV
echo "Publishing tag $CIRCLE_TAG"
npm publish --tag $CIRCLE_TAG --access public
defaults_npm_publish_release: &defaults_npm_publish_release
name: Publish NPM $RELEASE_TAG artifact
defaults_license_scanner: &defaults_license_scanner
name: Install and set up license-scanner
command: |
source $BASH_ENV
echo "Publishing tag $RELEASE_TAG"
npm publish --tag $RELEASE_TAG --access public
git clone https://github.com/mojaloop/license-scanner /tmp/license-scanner
cd /tmp/license-scanner && make build default-files set-up
defaults_slack_announcement: &defaults_slack_announcement
name: Slack announcement for tag releases
Expand All @@ -59,19 +60,36 @@ defaults_slack_announcement: &defaults_slack_announcement
$SLACK_WEBHOOK_ANNOUNCEMENT \
-H 'Content-type: application/json' \
-H 'cache-control: no-cache' \
-d "{
\"text\": \"*${CIRCLE_PROJECT_REPONAME}* - Release \`${CIRCLE_TAG}\`: https://github.com/mojaloop/${CIRCLE_PROJECT_REPONAME}/releases/tag/${CIRCLE_TAG}\"
}"
-d "{\"text\": \"*${CIRCLE_PROJECT_REPONAME}* - Release \`${CIRCLE_TAG}\`: https://github.com/mojaloop/${CIRCLE_PROJECT_REPONAME}/releases/tag/${CIRCLE_TAG}\"}"
##
# Executors
#
# CircleCI Executors
##
executors:
default-docker:
working_directory: /home/circleci/project
docker:
- image: node:12.16.0-alpine

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

##
# Jobs
#
# A map of CircleCI jobs
##
jobs:
setup:
<<: *defaults_working_directory
<<: *defaults_docker_node
executor: default-docker
steps:
- checkout
- run:
name: Install general dependencies
command: *defaults_Dependencies
- checkout
- run:
name: Update NPM install
command: npm install
Expand All @@ -81,15 +99,17 @@ jobs:
- node_modules

test-unit:
<<: *defaults_working_directory
<<: *defaults_docker_node
executor: default-docker
steps:
- checkout
- run:
name: Install general dependencies
command: *defaults_Dependencies
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- run:
name: Build typescript
command: *defaults_Typescript
- run:
name: Install tape, tapes and tap-xunit
command: npm install tape tapes tap-xunit tap-spec nyc
Expand All @@ -106,16 +126,15 @@ jobs:
path: ./test/results

test-coverage:
<<: *defaults_working_directory
<<: *defaults_docker_node
executor: default-docker
steps:
- checkout
- run:
name: Install general dependencies
command: *defaults_Dependencies
- run:
name: Install AWS CLI dependencies
command: *defaults_awsCliDependencies
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- run:
Expand All @@ -141,37 +160,38 @@ jobs:
fi
vulnerability-check:
<<: *defaults_working_directory
<<: *defaults_docker_node
executor: default-docker
steps:
- checkout
- run:
name: Install general dependencies
command: *defaults_Dependencies
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- 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 --silent -- --json > ./audit/results/auditResults.json
- store_artifacts:
path: ./audit/results
prefix: audit

audit-licenses:
<<: *defaults_working_directory
<<: *defaults_docker_node
executor: default-docker
steps:
- checkout
- run:
name: Install general dependencies
command: *defaults_Dependencies
- run:
<<: *defaults_license_scanner
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- run:
name: Prune non-production packages before running license-scanner
command: npm prune --production
- run:
name: Run the license-scanner
command: cd /tmp/license-scanner && pathToRepo=$CIRCLE_WORKING_DIRECTORY make run
Expand All @@ -180,13 +200,17 @@ jobs:
prefix: licenses

build-snapshot:
<<: *defaults_working_directory
<<: *defaults_docker_node
executor: default-docker
steps:
- run:
name: Install general dependencies
command: *defaults_Dependencies
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- run:
name: Build typescript
command: *defaults_Typescript
- run:
name: setup environment vars for SNAPSHOT release
command: |
Expand All @@ -198,14 +222,41 @@ jobs:
- run:
<<: *defaults_slack_announcement

build-perf:
executor: default-docker
steps:
- run:
name: Install general dependencies
command: *defaults_Dependencies
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- run:
name: Build typescript
command: *defaults_Typescript
- run:
name: setup environment vars for PERFORMANCE release
command: |
echo 'export RELEASE_TAG=$RELEASE_TAG_PERFORMANCE' >> $BASH_ENV
- run:
<<: *defaults_npm_auth
- run:
<<: *defaults_npm_publish_release
- run:
<<: *defaults_slack_announcement

build:
<<: *defaults_working_directory
<<: *defaults_docker_node
executor: default-docker
steps:
- run:
name: Install general dependencies
command: *defaults_Dependencies
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- run:
name: Build typescript
command: *defaults_Typescript
- run:
name: setup environment vars for LATEST release
command: |
Expand All @@ -217,6 +268,11 @@ jobs:
- run:
<<: *defaults_slack_announcement

##
# Workflows
#
# CircleCI Workflow config
##
workflows:
version: 2
build_and_test:
Expand Down Expand Up @@ -288,6 +344,16 @@ workflows:
branches:
ignore:
- /.*/
- build-perf:
context: org-global
requires:
- setup
filters:
tags:
only: /v[0-9]+(\.[0-9]+)*\-perf+((\.[0-9]+)?)/
branches:
ignore:
- /.*/
- build:
context: org-global
requires:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ jspm_packages/
# TypeScript v1 declaration files
typings/

# TypeScript dist folder
dist/

# Optional npm cache directory
.npm

Expand Down
5 changes: 5 additions & 0 deletions .ncurc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"reject": [
"prom-client"
]
}
10 changes: 10 additions & 0 deletions audit-resolve.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@
"1325|typedoc>handlebars": {
"decision": "fix",
"madeAt": 1579862904773
},
"1179|tap-xunit>minimist": {
"decision": "ignore",
"madeAt": 1586451861665,
"expiresAt": 1587056655839
},
"1179|faucet>minimist": {
"decision": "ignore",
"madeAt": 1586451848125,
"expiresAt": 1587056610669
}
},
"rules": {},
Expand Down
27 changes: 0 additions & 27 deletions lib/index.d.ts

This file was deleted.

28 changes: 0 additions & 28 deletions lib/index.js

This file was deleted.

1 change: 0 additions & 1 deletion lib/index.js.map

This file was deleted.

Loading

0 comments on commit bf620a4

Please sign in to comment.