Skip to content

Commit

Permalink
Feature/656 add integration tests (#100)
Browse files Browse the repository at this point in the history
* Replace ava with jest for unit testing,
  - add unit tests to expand coverage
  - update most dependencies

* Finish fixing code coverage, fix final missing tests

* Remove commented code

* bump package version to 8.2.0

* Adding docker-compose config for integration tests

* Implement basic integration tests and integration test runner,
- upgrade circleCI runner to 2.1 to get docker-compose working

* working on better integration runner for testing live api

* Working on integration runner

* improving test usage env vars

* Upgrade everything but @hapi/boom

* Upgrade everything but @hapi/boom

* work on integration runner

* Resolve package.json conflicts, update to latest version

* Updating readme for integration and local runner

* working on test runner and readme

* resolve package-lock.json merge conflicts

* Bump package version to try and fix failing ci tests

* testing circleci 2.1 changes

* cleaning up circleci config

* testing refactor of working_directory

* clean up yaml templating
  • Loading branch information
lewisdaly authored Oct 8, 2019
1 parent 98a2ad2 commit f6eabee
Show file tree
Hide file tree
Showing 32 changed files with 3,419 additions and 981 deletions.
101 changes: 46 additions & 55 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
# CircleCI v2 Config
version: 2

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

defaults_docker_node: &defaults_docker_node
docker:
- image: node:10.15.3-alpine

defaults_docker_helm_kube: &defaults_docker_helm_kube
docker:
- image: hypnoglow/kubernetes-helm
# CircleCI v2.1 Config
version: 2.1

defaults_Dependencies: &defaults_Dependencies |
apk --no-cache add git
Expand Down Expand Up @@ -145,14 +134,26 @@ 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:
default-docker:
working_directory: /home/circleci/project
docker:
- image: node:10.15.3-alpine

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

helm-kube:
working_directory: /home/circleci/project
docker:
- image: hypnoglow/kubernetes-helm

jobs:
setup:
<<: *defaults_working_directory
<<: *defaults_docker_node
executor: default-docker
steps:
- checkout
- run:
Expand All @@ -178,8 +179,7 @@ jobs:
- node_modules

test-unit:
<<: *defaults_working_directory
<<: *defaults_docker_node
executor: default-docker
steps:
- checkout
- run:
Expand All @@ -203,8 +203,7 @@ jobs:
path: ./test/results

test-coverage:
<<: *defaults_working_directory
<<: *defaults_docker_node
executor: default-docker
steps:
- checkout
- run:
Expand Down Expand Up @@ -241,20 +240,17 @@ jobs:
fi
test-integration:
machine: true
<<: *defaults_working_directory
executor: default-machine
steps:
- checkout
- run:
<<: *defaults_environment
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- run:
name: Create dir for test results
command: mkdir -p ./test/results
- run:
name: Execute integration tests
command: npm -s run test:integration
command: RESULTS_DIR="./test/results" npm -s run test:integration
no_output_timeout: 25m
- store_artifacts:
path: ./test/results
Expand Down Expand Up @@ -338,8 +334,7 @@ jobs:
# path: ./test/results

vulnerability-check:
<<: *defaults_working_directory
<<: *defaults_docker_node
executor: default-docker
steps:
- run:
name: Install general dependencies
Expand All @@ -358,8 +353,7 @@ jobs:
prefix: audit

audit-licenses:
<<: *defaults_working_directory
<<: *defaults_docker_node
executor: default-docker
steps:
- run:
name: Install general dependencies
Expand All @@ -380,8 +374,7 @@ jobs:
prefix: licenses

build-snapshot:
machine: true
<<: *defaults_working_directory
executor: default-machine
steps:
- checkout
- run:
Expand All @@ -404,7 +397,7 @@ jobs:
<<: *defaults_slack_announcement

build-hotfix:
machine: true
executor: default-machine
# <<: *default_env
steps:
- checkout
Expand All @@ -424,7 +417,7 @@ jobs:
<<: *defaults_slack_announcement

build:
machine: true
executor: default-machine
# <<: *default_env
steps:
- checkout
Expand Down Expand Up @@ -456,8 +449,7 @@ jobs:
<<: *defaults_slack_announcement

deploy-snapshot:
<<: *defaults_working_directory
<<: *defaults_docker_helm_kube
executor: helm-kube
steps:
- run:
<<: *defaults_environment
Expand Down Expand Up @@ -492,8 +484,7 @@ jobs:
<<: *defaults_deploy_install_or_upgrade_helm_chart

deploy:
<<: *defaults_working_directory
<<: *defaults_docker_helm_kube
executor: helm-kube
steps:
- run:
<<: *defaults_environment
Expand Down Expand Up @@ -562,17 +553,17 @@ workflows:
ignore:
- /feature*/
- /bugfix*/
# - test-integration:
# context: org-global
# requires:
# - setup
# filters:
# tags:
# only: /.*/
# branches:
# ignore:
# - /feature*/
# - /bugfix*/
- test-integration:
context: org-global
requires:
- setup
filters:
tags:
only: /.*/
branches:
ignore:
- /feature*/
- /bugfix*/
- vulnerability-check:
context: org-global
requires:
Expand All @@ -599,9 +590,9 @@ workflows:
context: org-global
requires:
- setup
# - test-unit
# - test-coverage
# - test-integration
- test-unit
- test-coverage
- test-integration
# - test-functional
# - test-spec
filters:
Expand All @@ -626,7 +617,7 @@ workflows:
- setup
- test-unit
- test-coverage
# - test-integration
- test-integration
# - test-functional
# - test-spec
- vulnerability-check
Expand All @@ -643,7 +634,7 @@ workflows:
- setup
- test-unit
- test-coverage
# - test-integration
- test-integration
# - test-functional
# - test-spec
- vulnerability-check
Expand Down
13 changes: 9 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:10.15.3-alpine
FROM node:10.15.3-alpine AS builder

WORKDIR /opt/account-lookup-service

Expand All @@ -8,15 +8,20 @@ RUN apk add --no-cache -t build-dependencies git make gcc g++ python libtool aut
&& npm install -g node-gyp

COPY package.json package-lock.json* /opt/account-lookup-service/
RUN npm install --production

RUN apk del build-dependencies
RUN npm install

COPY config /opt/account-lookup-service/config
COPY migrations /opt/account-lookup-service/migrations
COPY seeds /opt/account-lookup-service/seeds
COPY src /opt/account-lookup-service/src

FROM node:10.15.3-alpine

WORKDIR /opt/account-lookup-service

COPY --from=builder /opt/account-lookup-service .
RUN npm prune --production

EXPOSE 4002
EXPOSE 4001
CMD ["npm", "run", "start"]
Loading

0 comments on commit f6eabee

Please sign in to comment.