Merge branch 'ci' into 'main'
Ci See merge request v3/services/auth!4
This commit is contained in:
commit
c483d3997c
|
@ -3,7 +3,7 @@ SERVICE_URL=0.0.0.0
|
||||||
SERVICE_PORT=5002
|
SERVICE_PORT=5002
|
||||||
|
|
||||||
# PRISMA
|
# PRISMA
|
||||||
DATABASE_URL="postgresql://auth:auth@db:5432/auth?schema=public"
|
DATABASE_URL="postgresql://auth:auth@v3-auth-db:5432/auth?schema=public"
|
||||||
|
|
||||||
# RABBIT MQ
|
# RABBIT MQ
|
||||||
RMQ_URI=amqp://v3-broker:5672
|
RMQ_URI=amqp://v3-broker:5672
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
image: docker:20.10.22
|
||||||
|
|
||||||
|
stages:
|
||||||
|
- test
|
||||||
|
|
||||||
|
##############
|
||||||
|
# TEST STAGE #
|
||||||
|
##############
|
||||||
|
|
||||||
|
integration-test:
|
||||||
|
stage: test
|
||||||
|
image: docker/compose:latest
|
||||||
|
variables:
|
||||||
|
DOCKER_TLS_CERTDIR: ""
|
||||||
|
services:
|
||||||
|
- docker:dind
|
||||||
|
script:
|
||||||
|
- docker-compose -f docker-compose.ci.yml --env-file ci/.env.ci up -d
|
||||||
|
- sh ci/wait-up.sh
|
||||||
|
- docker-compose -f docker-compose.ci.yml --env-file ci/.env.ci logs
|
||||||
|
- docker exec -t v3-auth sh -c "npm run test:integration:ci"
|
||||||
|
coverage: /All files[^|]*\|[^|]*\s+([\d\.]+)/
|
||||||
|
rules:
|
||||||
|
- if: '$CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH || $CI_COMMIT_MESSAGE =~ /--check/ || $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
|
||||||
|
when: always
|
|
@ -0,0 +1,15 @@
|
||||||
|
# SERVICE
|
||||||
|
SERVICE_URL=0.0.0.0
|
||||||
|
SERVICE_PORT=5002
|
||||||
|
|
||||||
|
# PRISMA
|
||||||
|
DATABASE_URL="postgresql://auth:auth@db:5432/auth?schema=public"
|
||||||
|
|
||||||
|
# RABBIT MQ
|
||||||
|
RMQ_URI=amqp://broker:5672
|
||||||
|
|
||||||
|
# MESSAGE BROKER
|
||||||
|
BROKER_IMAGE=rabbitmq:3-alpine
|
||||||
|
|
||||||
|
# POSTGRES
|
||||||
|
POSTGRES_IMAGE=postgres:15.0
|
|
@ -0,0 +1,29 @@
|
||||||
|
###################
|
||||||
|
# BUILD FOR CI TESTING
|
||||||
|
###################
|
||||||
|
|
||||||
|
FROM node:18-alpine3.16
|
||||||
|
|
||||||
|
# Create app directory
|
||||||
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
|
# A wildcard is used to ensure both package.json AND package-lock.json are copied
|
||||||
|
COPY package*.json ./
|
||||||
|
|
||||||
|
# Install app dependencies
|
||||||
|
RUN npm ci
|
||||||
|
|
||||||
|
# Bundle app source
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# Generate prisma client
|
||||||
|
RUN npx prisma generate
|
||||||
|
|
||||||
|
# Create a "dist" folder
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
# Run unit tests
|
||||||
|
RUN npm run test:unit:ci
|
||||||
|
|
||||||
|
# Start the server
|
||||||
|
CMD [ "node", "dist/main.js" ]
|
|
@ -0,0 +1,12 @@
|
||||||
|
#!/bin/bash
|
||||||
|
testlog() {
|
||||||
|
docker logs v3-auth-db-test | grep -q "database system is ready to accept connections"
|
||||||
|
}
|
||||||
|
|
||||||
|
testlog 2> /dev/null
|
||||||
|
while [ $? -ne 0 ];
|
||||||
|
do
|
||||||
|
sleep 5
|
||||||
|
echo "Waiting for Test DB to be up..."
|
||||||
|
testlog 2> /dev/null
|
||||||
|
done
|
|
@ -0,0 +1,41 @@
|
||||||
|
version: '3.8'
|
||||||
|
|
||||||
|
services:
|
||||||
|
api:
|
||||||
|
container_name: v3-auth
|
||||||
|
build:
|
||||||
|
dockerfile: ci/Dockerfile
|
||||||
|
context: .
|
||||||
|
env_file:
|
||||||
|
- ci/.env.ci
|
||||||
|
ports:
|
||||||
|
- 5002:5002
|
||||||
|
depends_on:
|
||||||
|
- db
|
||||||
|
- broker
|
||||||
|
networks:
|
||||||
|
- v3-network
|
||||||
|
|
||||||
|
db:
|
||||||
|
container_name: v3-auth-db-test
|
||||||
|
image: ${POSTGRES_IMAGE}
|
||||||
|
environment:
|
||||||
|
POSTGRES_DB: auth
|
||||||
|
POSTGRES_USER: auth
|
||||||
|
POSTGRES_PASSWORD: auth
|
||||||
|
ports:
|
||||||
|
- 5602:5432
|
||||||
|
networks:
|
||||||
|
- v3-network
|
||||||
|
|
||||||
|
broker:
|
||||||
|
container_name: v3-broker
|
||||||
|
image: ${BROKER_IMAGE}
|
||||||
|
ports:
|
||||||
|
- 5672:5672
|
||||||
|
networks:
|
||||||
|
- v3-network
|
||||||
|
|
||||||
|
networks:
|
||||||
|
v3-network:
|
||||||
|
name: v3-network
|
23
package.json
23
package.json
|
@ -1,10 +1,10 @@
|
||||||
{
|
{
|
||||||
"name": "auth",
|
"name": "mobicoop-v3-auth",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"description": "",
|
"description": "Mobicoop V3 Auth Service",
|
||||||
"author": "",
|
"author": "sbriat",
|
||||||
"private": true,
|
"private": true,
|
||||||
"license": "UNLICENSED",
|
"license": "AGPL",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prebuild": "rimraf dist",
|
"prebuild": "rimraf dist",
|
||||||
"build": "nest build",
|
"build": "nest build",
|
||||||
|
@ -14,13 +14,16 @@
|
||||||
"start:debug": "nest start --debug --watch",
|
"start:debug": "nest start --debug --watch",
|
||||||
"start:prod": "node dist/main",
|
"start:prod": "node dist/main",
|
||||||
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
|
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
|
||||||
"test": "npm run migrate-test && dotenv -e .env.test jest",
|
"test": "npm run migrate:test && dotenv -e .env.test jest",
|
||||||
"test:unit": "jest --testPathIgnorePatterns 'integration' --verbose",
|
"test:unit": "jest --testPathPattern 'tests/unit/' --verbose",
|
||||||
"test:integration": "npm run migrate-test && dotenv -e .env.test -- jest --testPathPattern 'integration' --verbose",
|
"test:unit:ci": "jest --testPathPattern 'tests/unit/' --coverage",
|
||||||
"test:cov": "npm run migrate-test && dotenv -e .env.test -- jest --coverage",
|
"test:integration": "npm run migrate:test && dotenv -e .env.test -- jest --testPathPattern 'tests/integration/' --verbose",
|
||||||
|
"test:integration:ci": "npm run migrate:test:ci && dotenv -e ci/.env.ci -- jest --testPathPattern 'tests/integration/'",
|
||||||
|
"test:cov": "npm run migrate:test && dotenv -e .env.test -- jest --coverage",
|
||||||
"test:e2e": "jest --config ./test/jest-e2e.json",
|
"test:e2e": "jest --config ./test/jest-e2e.json",
|
||||||
"migrate": "docker exec v3-user sh -c 'npx prisma migrate dev'",
|
"migrate": "docker exec v3-auth sh -c 'npx prisma migrate dev'",
|
||||||
"migrate-test": "dotenv -e .env.test -- npx prisma migrate dev --name postgres-init"
|
"migrate:test": "dotenv -e .env.test -- npx prisma migrate deploy",
|
||||||
|
"migrate:test:ci": "dotenv -e ci/.env.ci -- npx prisma migrate deploy"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@automapper/classes": "^8.7.7",
|
"@automapper/classes": "^8.7.7",
|
||||||
|
|
|
@ -35,6 +35,7 @@ import { LoggingMessager } from './adapters/secondaries/logging.messager';
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
uri: configService.get<string>('RMQ_URI'),
|
uri: configService.get<string>('RMQ_URI'),
|
||||||
|
connectionInitOptions: { wait: false },
|
||||||
enableControllerDiscovery: true,
|
enableControllerDiscovery: true,
|
||||||
}),
|
}),
|
||||||
inject: [ConfigService],
|
inject: [ConfigService],
|
||||||
|
|
Loading…
Reference in New Issue