Skip to content

Commit

Permalink
chore: update ci, packages and linting (#116)
Browse files Browse the repository at this point in the history
* chore: update ci, packages and linting

* chore: update packages

* chore: lint test

* chore: lint src/

* chore: regen inteface

* chore(snapshot): 13.0.1-snapshot.0

* chore: package

* chore(snapshot): 13.0.1-snapshot.1

* chore: add codeowners

* chore: update code owners
  • Loading branch information
kleyow committed May 24, 2022
1 parent 2f3806a commit b45d6f9
Show file tree
Hide file tree
Showing 108 changed files with 22,081 additions and 25,753 deletions.
112 changes: 90 additions & 22 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ orbs:
pr-tools: mojaloop/[email protected] # Ref: https://github.com/mojaloop/ci-config/
gh: circleci/[email protected]
anchore: anchore/[email protected]
deploy-kube: mojaloop/[email protected]

##
# defaults
Expand All @@ -24,7 +23,7 @@ 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++ python3 libtool autoconf automake jq mysql-client
apk add --no-cache -t build-dependencies make gcc g++ python3 libtool autoconf automake jq
apk add --no-cache -t openssl ncurses coreutils libgcc linux-headers grep util-linux binutils findutils
npm config set unsafe-perm true
npm install -g node-gyp
Expand Down Expand Up @@ -102,6 +101,21 @@ jobs:
paths:
- node_modules

test-dependencies:
executor: default-docker
steps:
- run:
name: Install general dependencies
command: *defaults_Dependencies
- checkout
- run:
<<: *defaults_configure_nvm
- restore_cache:
key: dependency-cache-{{ .Environment.CIRCLE_SHA1 }}
- run:
name: Execute dependency tests
command: npm run dep:check

test-lint:
executor: default-docker
steps:
Expand Down Expand Up @@ -142,6 +156,30 @@ jobs:
- store_test_results:
path: ./test/results

test-bdd:
executor: default-docker
steps:
- run:
name: Install general dependencies
command: *defaults_Dependencies
- checkout
- run:
<<: *defaults_configure_nvm
- restore_cache:
key: dependency-cache-{{ .Environment.CIRCLE_SHA1 }}
- run:
name: Execute unit tests
command: npm run test:bdd
- run:
name: prepare test/results
command: |
mkdir -p test/results
mv junit.xml test/results
- store_artifacts:
path: ./test/results
- store_test_results:
path: ./test/results

test-coverage:
executor: default-docker
steps:
Expand Down Expand Up @@ -455,16 +493,6 @@ jobs:
name: Load the pre-built docker image from workspace
command: |
docker load -i /tmp/docker-image.tar
- run:
name: Set Image Digest
command: |
IMAGE_DIGEST=$(docker images --no-trunc --quiet $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:$RELEASE_TAG)
echo "IMAGE_DIGEST=${IMAGE_DIGEST}"
echo "export IMAGE_DIGEST=${IMAGE_DIGEST}" >> $BASH_ENV
- run:
name: Update Slack config
command: |
echo "export SLACK_RELEASE_URL='https://hub.docker.com/layers/${CIRCLE_PROJECT_REPONAME}/${DOCKER_ORG}/${CIRCLE_PROJECT_REPONAME}/v${CIRCLE_TAG:1}/images/${IMAGE_DIGEST}?context=explore'" | sed -r 's/sha256:/sha256-/g' >> $BASH_ENV
- run:
name: Login to Docker Hub
command: docker login -u $DOCKER_USER -p $DOCKER_PASS
Expand All @@ -479,6 +507,16 @@ jobs:
docker push $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:$CIRCLE_TAG
echo "Publishing $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:$RELEASE_TAG"
docker push $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:$RELEASE_TAG
- run:
name: Set Image Digest
command: |
IMAGE_DIGEST=$(docker inspect $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:v${CIRCLE_TAG:1} | jq '.[0].RepoDigests | .[]')
echo "IMAGE_DIGEST=${IMAGE_DIGEST}"
echo "export IMAGE_DIGEST=${IMAGE_DIGEST}" >> $BASH_ENV
- run:
name: Update Slack config
command: |
echo "export SLACK_RELEASE_URL='https://hub.docker.com/layers/${CIRCLE_PROJECT_REPONAME}/${DOCKER_ORG}/${CIRCLE_PROJECT_REPONAME}/v${CIRCLE_TAG:1}/images/${IMAGE_DIGEST}?context=explore'" | sed -r "s/${DOCKER_ORG}\/${CIRCLE_PROJECT_REPONAME}@sha256:/sha256-/g" >> $BASH_ENV
- slack/notify:
event: pass
template: SLACK_TEMP_RELEASE_SUCCESS
Expand Down Expand Up @@ -513,16 +551,6 @@ jobs:
name: Load the pre-built docker image from workspace
command: |
docker load -i /tmp/docker-image.tar
- run:
name: Set Image Digest
command: |
IMAGE_DIGEST=$(docker images --no-trunc --quiet $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:$RELEASE_TAG)
echo "IMAGE_DIGEST=${IMAGE_DIGEST}"
echo "export IMAGE_DIGEST=${IMAGE_DIGEST}" >> $BASH_ENV
- run:
name: Update Slack config
command: |
echo "export SLACK_RELEASE_URL='https://hub.docker.com/layers/${CIRCLE_PROJECT_REPONAME}/${DOCKER_ORG}/${CIRCLE_PROJECT_REPONAME}/v${CIRCLE_TAG:1}/images/${IMAGE_DIGEST}?context=explore'" | sed -r 's/sha256:/sha256-/g' >> $BASH_ENV
- run:
name: Login to Docker Hub
command: docker login -u $DOCKER_USER -p $DOCKER_PASS
Expand All @@ -537,6 +565,16 @@ jobs:
docker push $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:$CIRCLE_TAG
echo "Publishing $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:$RELEASE_TAG"
docker push $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:$RELEASE_TAG
- run:
name: Set Image Digest
command: |
IMAGE_DIGEST=$(docker inspect $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:v${CIRCLE_TAG:1} | jq '.[0].RepoDigests | .[]')
echo "IMAGE_DIGEST=${IMAGE_DIGEST}"
echo "export IMAGE_DIGEST=${IMAGE_DIGEST}" >> $BASH_ENV
- run:
name: Update Slack config
command: |
echo "export SLACK_RELEASE_URL='https://hub.docker.com/layers/${CIRCLE_PROJECT_REPONAME}/${DOCKER_ORG}/${CIRCLE_PROJECT_REPONAME}/v${CIRCLE_TAG:1}/images/${IMAGE_DIGEST}?context=explore'" | sed -r "s/${DOCKER_ORG}\/${CIRCLE_PROJECT_REPONAME}@sha256:/sha256-/g" >> $BASH_ENV
- slack/notify:
event: pass
template: SLACK_TEMP_RELEASE_SUCCESS
Expand Down Expand Up @@ -564,6 +602,17 @@ workflows:
ignore:
- /feature*/
- /bugfix*/
- test-dependencies:
context: org-global
requires:
- setup
filters:
tags:
only: /.*/
branches:
ignore:
- /feature*/
- /bugfix*/
- test-lint:
context: org-global
requires:
Expand All @@ -586,6 +635,17 @@ workflows:
ignore:
- /feature*/
- /bugfix*/
- test-bdd:
context: org-global
requires:
- setup
filters:
tags:
only: /.*/
branches:
ignore:
- /feature*/
- /bugfix*/
- test-coverage:
context: org-global
requires:
Expand Down Expand Up @@ -634,8 +694,10 @@ workflows:
context: org-global
requires:
- setup
- test-dependencies
- test-lint
- test-unit
- test-bdd
- test-coverage
- test-integration
- vulnerability-check
Expand Down Expand Up @@ -671,8 +733,10 @@ workflows:
context: org-global
requires:
- pr-tools/pr-title-check
- test-dependencies
- test-lint
- test-unit
- test-bdd
- test-coverage
- test-integration
- vulnerability-check
Expand All @@ -697,8 +761,10 @@ workflows:
context: org-global
requires:
- pr-tools/pr-title-check
- test-dependencies
- test-lint
- test-unit
- test-bdd
- test-coverage
- test-integration
- vulnerability-check
Expand All @@ -716,8 +782,10 @@ workflows:
context: org-global
requires:
- pr-tools/pr-title-check
- test-dependencies
- test-lint
- test-unit
- test-bdd
- test-coverage
- test-integration
- vulnerability-check
Expand Down
56 changes: 18 additions & 38 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
module.exports = {
parser: '@typescript-eslint/parser', // Specifies the ESLint parser
plugins: [
'cucumber',
'@typescript-eslint'
],
extends: [
'eslint:recommended',
'standard',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
//'prettier/@typescript-eslint', // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
//'plugin:prettier/recommended', // Enables eslint-plugin-prettier and displays prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
'plugin:@typescript-eslint/recommended', // Uses the recommended rules from the @typescript-eslint/eslint-plugin
'prettier', // Uses prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
'plugin:prettier/recommended', // Enables eslint-plugin-prettier and displays prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
// Enforces ES6+ import/export syntax
'plugin:import/errors',
'plugin:import/warnings',
Expand All @@ -19,32 +12,20 @@ module.exports = {
parserOptions: {
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
sourceType: 'module', // Allows for the use of imports
project: "./tsconfig.json",
tsConfigRootDir: "./"
project: './tsconfig.json',
tsConfigRootDir: './'
},
rules: {
indent: 'off',
'@typescript-eslint/indent': ['error', 2],
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-var-requires': 'error',
'@typescript-eslint/no-empty-interface': 'warn',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'no-console': 'off',
quotes: ['error', 'single'],
'linebreak-style': ['error', 'unix'],
semi: ['error', 'never'],
'cucumber/async-then': 2,
'cucumber/expression-type': 2,
'cucumber/no-restricted-tags': [2, 'wip', 'broken', 'foo'],
'cucumber/no-arrow-functions': 2,
'import/default': 'warn', // Support legacy modules without default export
'import/extensions': 'off',
'max-len': ["off", { "code": 120 }],
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
// Sometimes openapi generator emits empty interfaces
'@typescript-eslint/no-empty-interface': 'warn'
},
settings: {
"import/resolver": {
"typescript": {}
'import/resolver': {
typescript: {}
}
},
overrides: [
Expand All @@ -65,15 +46,14 @@ module.exports = {
'@typescript-eslint/no-var-requires': 'off',
}
},
{ // properly handle generated DTO and autofix it
files: [
'src/interface/**/*.ts'
],
{
files: ['src/interface/**/*.ts'],
rules: {
'no-use-before-define': 'off',
'max-len': ['warn', { code: 500 }],
'@typescript-eslint/ban-types': 'off'
'max-len': ['warn', { code: 600 }],
'@typescript-eslint/ban-types': 'off',
'@typescript-eslint/no-empty-interface': 'off'
}
}
},
],
};
24 changes: 24 additions & 0 deletions .ncurc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
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 [email protected] for the time being.
'husky',
// Caution advised in upgrading redis-mock past 0.52.0. Investigation needed.
'redis-mock',
// Upgrading past redis@3 to the next major version introduces a lot of breaking changes.
'redis',
'@types/redis',
// Upgrading past jest|ts-jest|@types/jest@26 introduces a lot of breaking changes to current tests.
'jest',
'ts-jest',
'@types/jest',
// Upgrading past commander@7 introduces a lot of breaking changes.
'commander',
// Upgrading sqlite past 5.0.2 seems to introduce sh: 1: node-pre-gyp: not found.
// Investigation needed.
'sqlite3',
// Upgrading fido2-lib past @2.8.3 seems to break tests with error message
// `error parsing ASN.1`. Investigation needed.
'fido2-lib'
]
}
7 changes: 7 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
semi: false,
trailingComma: 'none',
singleQuote: true,
printWidth: 120,
tabWidth: 2,
};
39 changes: 39 additions & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
* @kleyow @elnyry-sam-k @lewisdaly @vijayg10 @mdebarros

# This is a comment.
# Each line is a file pattern followed by one or more owners.

## These owners will be the default owners for everything in
## the repo. Unless a later match takes precedence,
## @global-owner1 and @global-owner2 will be requested for
## review when someone opens a pull request.
#* @global-owner1 @global-owner2

## Order is important; the last matching pattern takes the most
## precedence. When someone opens a pull request that only
## modifies JS files, only @js-owner and not the global
## owner(s) will be requested for a review.
# *.js @js-owner

## You can also use email addresses if you prefer. They'll be
## used to look up users just like we do for commit author
## emails.
#*.go [email protected]

# In this example, @doctocat owns any files in the build/logs
# directory at the root of the repository and any of its
# subdirectories.
# /build/logs/ @doctocat

## The `docs/*` pattern will match files like
## `docs/getting-started.md` but not further nested files like
## `docs/build-app/troubleshooting.md`.
# docs/* [email protected]

## In this example, @octocat owns any file in an apps directory
## anywhere in your repository.
#apps/ @octocat

## In this example, @doctocat owns any file in the `/docs`
## directory in the root of your repository.
#/docs/ @doctocat
Loading

0 comments on commit b45d6f9

Please sign in to comment.