diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 849e358..804aa0f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,15 +1,14 @@ image: docker:20.10.22 stages: - - test:unit - - test:integration + - test ############## # TEST STAGE # ############## unit-test: - stage: test:unit + stage: test image: node:18-alpine3.16 script: - npm install @@ -19,7 +18,7 @@ unit-test: when: always integration-test: - stage: test:integration + stage: test image: docker/compose:latest variables: DOCKER_TLS_CERTDIR: "" @@ -29,7 +28,7 @@ integration-test: - docker-compose -f docker-compose.ci.yml --env-file ci/.env.ci up -d - sleep 30 - docker-compose -f docker-compose.ci.yml --env-file ci/.env.ci logs - - docker exec -t v3-user sh -c "npm run test:integration" + - docker exec -t v3-user sh -c "npm run test:integration:ci" rules: - if: '$CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH || $CI_COMMIT_MESSAGE =~ /--check/ || $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH' when: always diff --git a/ci/.env.ci b/ci/.env.ci index 9ac82b6..bc9fdb7 100644 --- a/ci/.env.ci +++ b/ci/.env.ci @@ -1,8 +1,12 @@ +# SERVICE +SERVICE_URL=0.0.0.0 +SERVICE_PORT=5001 + # PRISMA -DATABASE_URL="postgresql://user:user@v3-user-db-test:5432/user?schema=public" +DATABASE_URL="postgresql://user:user@db:5432/user?schema=public" # RABBIT MQ -RMQ_URI=amqp://v3-broker:5672 +RMQ_URI=amqp://broker:5672 # MESSAGE BROKER BROKER_IMAGE=rabbitmq:3-alpine diff --git a/docker-compose.ci.yml b/docker-compose.ci.yml index 9335edf..e8cb3a1 100644 --- a/docker-compose.ci.yml +++ b/docker-compose.ci.yml @@ -11,14 +11,12 @@ services: ports: - 5001:5001 depends_on: - - db-test + - db - broker networks: - v3-network: - aliases: - - v3-user-api + - v3-network - db-test: + db: container_name: v3-user-db-test image: ${POSTGRES_IMAGE} environment: @@ -28,9 +26,7 @@ services: ports: - 5601:5432 networks: - v3-network: - aliases: - - v3-user-db-test + - v3-network broker: container_name: v3-broker @@ -38,11 +34,8 @@ services: ports: - 5672:5672 networks: - v3-network: - aliases: - - v3-broker + - v3-network networks: v3-network: name: v3-network - driver: bridge diff --git a/package.json b/package.json index d426df6..35ce14d 100644 --- a/package.json +++ b/package.json @@ -14,14 +14,15 @@ "start:debug": "nest start --debug --watch", "start:prod": "node dist/main", "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix", - "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": "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": "npm run migrate:test && dotenv -e .env.test jest", + "test:unit": "jest --testPathPattern 'tests/unit/' --verbose", + "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/' --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-test": "dotenv -e .env.test -- npx prisma migrate deploy" + "migrate:test": "dotenv -e .env.test -- npx prisma migrate deploy", + "migrate:test:ci": "dotenv -e ci/.env.ci -- npx prisma migrate deploy" }, "dependencies": { "@automapper/classes": "^8.7.7",