test ci --check

This commit is contained in:
Gsk54 2023-01-10 10:39:36 +01:00
parent 35c8e1c065
commit df6c3d765d
3 changed files with 36 additions and 19 deletions

View File

@ -8,7 +8,7 @@ stages:
# TEST STAGE # # TEST STAGE #
############## ##############
unit-test-api: unit-test:
stage: test:unit stage: test:unit
image: node:18-alpine3.16 image: node:18-alpine3.16
script: script:
@ -18,6 +18,22 @@ unit-test-api:
- if: '$CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH || $CI_COMMIT_MESSAGE =~ /--check/ || $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH' - if: '$CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH || $CI_COMMIT_MESSAGE =~ /--check/ || $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
when: always when: always
integration-test:
stage: test:integration
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
- sleep 30
- npm install
- npm run test:integration
rules:
- if: '$CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH || $CI_COMMIT_MESSAGE =~ /--check/ || $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
when: always
# test-api-dev: # test-api-dev:
# stage: test # stage: test
# image: docker/compose:latest # image: docker/compose:latest

View File

@ -1,22 +1,22 @@
version: '3.8' version: '3.8'
services: services:
api: # api:
container_name: v3-user # container_name: v3-user
build: # build:
dockerfile: ci/Dockerfile # dockerfile: ci/Dockerfile
context: . # context: .
env_file: # env_file:
- ci/.env.ci # - ci/.env.ci
ports: # ports:
- 5001:5001 # - 5001:5001
depends_on: # depends_on:
- db-test # - db-test
- broker # - broker
networks: # networks:
v3-network: # v3-network:
aliases: # aliases:
- v3-user-api # - v3-user-api
db-test: db-test:
container_name: v3-user-db-test container_name: v3-user-db-test

View File

@ -17,10 +17,11 @@
"test": "npm run migrate-test && dotenv -e .env.test jest", "test": "npm run migrate-test && dotenv -e .env.test jest",
"test:ci": "docker ps && dotenv -e ci/.env.ci -- npx prisma migrate deploy --name postgres-init && dotenv -e ci/.env.ci jest", "test:ci": "docker ps && dotenv -e ci/.env.ci -- npx prisma migrate deploy --name postgres-init && dotenv -e ci/.env.ci jest",
"test:unit": "jest --testPathIgnorePatterns 'integration' --verbose", "test:unit": "jest --testPathIgnorePatterns 'integration' --verbose",
"test:integration": "dotenv -e .env.test -- npx prisma migrate dev --name postgres-init && dotenv -e .env.test -- jest --testPathPattern 'integration' --verbose", "test:integration": "npm run migrate-test && dotenv -e .env.test -- jest --testPathPattern 'integration' --verbose",
"test:cov": "npm run migrate-test && dotenv -e .env.test -- jest --coverage", "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-user sh -c 'npx prisma migrate dev'",
"migrate-test": "dotenv -e .env.test -- npx prisma migrate deploy"
}, },
"dependencies": { "dependencies": {
"@automapper/classes": "^8.7.7", "@automapper/classes": "^8.7.7",