From df6c3d765d8b10b25fb722f92df10c194b39c28e Mon Sep 17 00:00:00 2001 From: Gsk54 Date: Tue, 10 Jan 2023 10:39:36 +0100 Subject: [PATCH] test ci --check --- .gitlab-ci.yml | 18 +++++++++++++++++- docker-compose.ci.yml | 32 ++++++++++++++++---------------- package.json | 5 +++-- 3 files changed, 36 insertions(+), 19 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b2d1578..a99bf28 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,7 +8,7 @@ stages: # TEST STAGE # ############## -unit-test-api: +unit-test: stage: test:unit image: node:18-alpine3.16 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' 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: # stage: test # image: docker/compose:latest diff --git a/docker-compose.ci.yml b/docker-compose.ci.yml index 9335edf..83c814a 100644 --- a/docker-compose.ci.yml +++ b/docker-compose.ci.yml @@ -1,22 +1,22 @@ version: '3.8' services: - api: - container_name: v3-user - build: - dockerfile: ci/Dockerfile - context: . - env_file: - - ci/.env.ci - ports: - - 5001:5001 - depends_on: - - db-test - - broker - networks: - v3-network: - aliases: - - v3-user-api + # api: + # container_name: v3-user + # build: + # dockerfile: ci/Dockerfile + # context: . + # env_file: + # - ci/.env.ci + # ports: + # - 5001:5001 + # depends_on: + # - db-test + # - broker + # networks: + # v3-network: + # aliases: + # - v3-user-api db-test: container_name: v3-user-db-test diff --git a/package.json b/package.json index c8e7959..d426df6 100644 --- a/package.json +++ b/package.json @@ -17,10 +17,11 @@ "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: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: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": { "@automapper/classes": "^8.7.7",