Skip to content

Commit

Permalink
chore: fix publish job and update packages (#145)
Browse files Browse the repository at this point in the history
* chore: fix publish job

* chore: update ci and bump packages

* chore: test-bdd

* chore: comments

* chore: fixes

* chore: bdd

* chore(snapshot): 14.0.2-snapshot.0

* chore: move

* chore(snapshot): 14.0.2-snapshot.1
  • Loading branch information
kleyow authored May 24, 2022
1 parent 602cc14 commit 808afd1
Show file tree
Hide file tree
Showing 8 changed files with 3,624 additions and 2,597 deletions.
611 changes: 372 additions & 239 deletions .circleci/config.yml

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions .ncurc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
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',
// 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'
]
}
17 changes: 9 additions & 8 deletions docker/Dockerfile → Dockerfile
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
FROM node:16.15.0-alpine as builder
USER root
WORKDIR /opt/thirdparty-sdk

WORKDIR /opt/app

RUN apk update \
&& apk add --no-cache -t build-dependencies git make gcc g++ python3 libtool autoconf automake openssh \
&& cd $(npm root -g)/npm \
&& npm config set unsafe-perm true \
&& npm install -g node-gyp

COPY package.json package-lock.json* ./
COPY package.json package-lock.json* /opt/app/
RUN npm ci

COPY ./ ./
COPY ./ /opt/app/
RUN npm run build
RUN rm -rf src secrets test docs
RUN npm prune --production


FROM node:16.15.0-alpine
WORKDIR /opt/thirdparty-sdk
WORKDIR /opt/app/

# Create empty log file & link stdout to the application log file
RUN mkdir ./logs && touch ./logs/combined.log
RUN ln -sf /dev/stdout ./logs/combined.log

# Create a non-root user: ml-user
RUN adduser -D ml-user
USER ml-user
COPY --chown=ml-user --from=builder /opt/thirdparty-sdk ./
# Create a non-root user: app-user
RUN adduser -D app-user
USER app-user
COPY --chown=app-user --from=builder /opt/app/ ./

EXPOSE 4005 4006
58 changes: 29 additions & 29 deletions contributing.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Contributing

We strive for stability and security.
Pull Requests and contributions in general are welcome as long as
We strive for stability and security.
Pull Requests and contributions in general are welcome as long as
they don't compromise those goals and follow the [Mojaloop Contributors Guide](https://docs.mojaloop.io/documentation/contributors-guide/)

## Code style
Coding style is `standard` described through the EditorConfig [.editorconfig](./.editorconfig) file
and enforced by ESLint through the [.eslintrc.js](./.eslintrc.js) file.
Coding style is `standard` described through the EditorConfig [.editorconfig](./.editorconfig) file
and enforced by ESLint through the [.eslintrc.js](./.eslintrc.js) file.

```bash
npm run lint
Expand All @@ -30,8 +30,8 @@ npm run audit:check
This command is run as guard in CI/CD pipeline to ensure our code is not vulnerable.


`audit:resolve` should be used to resolve audit problems.
Generated `audit-resolve.json` file should be committed,
`audit:resolve` should be used to resolve audit problems.
Generated `audit-resolve.json` file should be committed,
elsewhere CI/CD pipeline will stop with error in case of any audit problems.
```bash
npm run audit:resolve
Expand All @@ -40,8 +40,8 @@ npm run audit:resolve
## Pre-commit hook
> Pull Requests with broken code will not be accepted to merge.
Pre-commit hook is used to reject untested and unlinted code.
Before every commit we run `npm test` and we lint all staged files.
Pre-commit hook is used to reject untested and unlinted code.
Before every commit we run `npm test` and we lint all staged files.
If any file is bad formatted or any unit test is broken the commit is rejected.

In case you need commit broken code use `no-verify` flag
Expand All @@ -50,30 +50,30 @@ git commit -m '<your commit message>' --no-verify
```

## Pre-push hook
Pre-push hook is used to reject untested code.
It also enforce to have fresh and actual dependencies.
Before every push we run `npm test` and `npm run updates:check`
Pre-push hook is used to reject untested code.
It also enforce to have fresh and actual dependencies.
Before every push we run `npm test` and `npm run updates:check`
In case you need push broken code use `no-verify` flag

## Always fresh code dependencies
There is a need to have always fresh code dependencies.
It is realized by [npm-check-updates](https://github.com/raineorshine/npm-check-updates).
There is a need to have always fresh code dependencies.
It is realized by [npm-check-updates](https://github.com/raineorshine/npm-check-updates).
```bash
npm run updates:check
```
In case of outdated dependencies run
```bash
npm run updates:update
```
It will update `package.json`, install all dependencies and regenerate `package-lock.json`.
All tests should be run successfully after updating the dependencies.
Both package files should be then committed.
It will update `package.json`, install all dependencies and regenerate `package-lock.json`.
All tests should be run successfully after updating the dependencies.
Both package files should be then committed.

## Testing
> All testing scripts are invoked via `npm run test<type>` defined in [package.json](./package.json)
The tests implementations are located in [test](./test) folder.
[Jest](http://jestjs.io/) is used to run all types of tests.
The tests implementations are located in [test](./test) folder.
[Jest](http://jestjs.io/) is used to run all types of tests.
Jest configuration: [jest.config.js](./jest.config.js)

### Default tests
Expand All @@ -92,43 +92,43 @@ Unit tests implementation is located in [test/unit](./test/unit) folder
```bash
npm run test:bdd
```
BDD tests are specified using `Gherkin` language and are located in [test/features](./test/features) folder,
BDD tests are specified using `Gherkin` language and are located in [test/features](./test/features) folder,
whereas their mappings to `Jest` tests are located in [test/step-definitions](./test/step-definitions)

### Integration tests
> To run locally integration tests there is a need to build and start containers
> with both API services with their dependencies services: (Redis as a cache & PUB/SUB notification engine).
> To run locally integration tests there is a need to build and start containers
> with both API services with their dependencies services: (Redis as a cache & PUB/SUB notification engine).
**Open two terminals.**
**Open two terminals.**
In first:
```bash
docker-compose build
docker-compose up
```
and wait a moment until all dockerized services are up
and wait a moment until all dockerized services are up

In second terminal
```bash
npm run test:integration
```

# Dockerized services
> `Inbound` and `Outbound API` services are dockerized.
> `Inbound` and `Outbound API` services are dockerized.
> To build and run use `npm run docker*` scripts defined in [package.json](./package.json)
## Inbound API
```bash
npm run docker:build
npm run docker:start:inbound
```
`Inboound API` Dockerfile: [docker/Docker.Inbound](./docker/Docker.Inbound)
`Inboound API` Dockerfile: [Docker.Inbound](./Docker.Inbound)

## Outbound API
```bash
npm run docker:build
npm run docker:run:outbound
```
`Outboound API` Dockerfile: [docker/Docker.Outbound](./docker/Docker.Outbound)
`Outboound API` Dockerfile: [Docker.Outbound](./Docker.Outbound)

## Docker-compose
To build and run all services
Expand All @@ -141,9 +141,9 @@ docker-compose specification: [docker-compose.yaml](./docker-compose.yaml)
# Configuration and run environments of services
> Configuration is managed by [Convict](https://github.com/mozilla/node-convict)
Services can be run in five environments: `development`, `test`, `integration`, `e2e`, `production`.
Selection of run environment can be done by setting `NODE_ENV` environment variable.
Dedicated to environments configuration files are located in [config/](./config) folder.
Services can be run in five environments: `development`, `test`, `integration`, `e2e`, `production`.
Selection of run environment can be done by setting `NODE_ENV` environment variable.
Dedicated to environments configuration files are located in [config/](./config) folder.

## Configuration file schema

Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ services:
container_name: inbound-thirdparty-sdk
build:
context: ./
dockerfile: ./docker/Dockerfile
dockerfile: ./Dockerfile
command: sh -c "/opt/thirdparty-sdk/wait4/wait4.js inbound-thirdparty-sdk && NODE_ENV=integration npm run start:inbound"
volumes:
- ./docker/wait4:/opt/thirdparty-sdk/wait4
Expand All @@ -33,7 +33,7 @@ services:
container_name: outbound-thirdparty-sdk
build:
context: ./
dockerfile: ./docker/Dockerfile
dockerfile: ./Dockerfile
command: sh -c "/opt/thirdparty-sdk/wait4/wait4.js outbound-thirdparty-sdk && NODE_ENV=integration npm run start:outbound"
volumes:
- ./docker/wait4:/opt/thirdparty-sdk/wait4
Expand Down
Loading

0 comments on commit 808afd1

Please sign in to comment.