Commit dd3ab51b authored by Artem Baldin's avatar Artem Baldin
Browse files

build: update gitlab-ci & makefile remove-compose

parent c0f008ed
......@@ -11,11 +11,6 @@ stages:
- security
- cleanup
variables:
FULL_NAME_IMAGE: registry-gitlab.prozorro.sale/prozorro-sale/prozorro-auth
IMAGE: prozorro-sale/prozorro-auth:$CI_COMMIT_SHORT_SHA
IMAGE_TEST: prozorro-sale/prozorro-auth:$CI_COMMIT_SHORT_SHA-test
code-style-check:
extends: .lint-template
......
......@@ -6,6 +6,10 @@ GIT_STAMP ?= $(shell git describe || echo v0.1.0)
CI_COMMIT_REF_NAME ?= ''
CI_PIPELINE_ID ?= 1
COMPOSE_PROJECT_NAME ?= $(PROJECT_NAME)-$(CI_PIPELINE_ID)
PROJECT_ID ?= $(COMPOSE_PROJECT_NAME)-$(CI_COMMIT_SHORT_SHA)
PROJECT_ID_UNIT=$(PROJECT_ID)-unit
PROJECT_ID_INTEGRATION ?= $(PROJECT_ID)-integration
PUBLISH_STAGE_CONTAINER_NAME ?= $(PROJECT_ID)-publish
# colors
GREEN = $(shell tput -Txterm setaf 2)
......@@ -50,16 +54,9 @@ run: docker-build
## Stop application and remove containers for a service.
remove-compose:
@docker-compose stop
@docker-compose -p $(COMPOSE_PROJECT_NAME)-integration stop
@docker-compose -p $(COMPOSE_PROJECT_NAME)-unit stop
@docker-compose down -v --rmi local
@docker-compose -p $(COMPOSE_PROJECT_NAME)-integration down -v --rmi local
@docker-compose -p $(COMPOSE_PROJECT_NAME)-unit down -v --rmi local
@docker-compose rm -fsv
@docker-compose -p $(COMPOSE_PROJECT_NAME)-integration rm -fsv
@docker-compose -p $(COMPOSE_PROJECT_NAME)-unit rm -fsv
@docker network ls -q -f name=$(PROJECT_NAME)-$(CI_PIPELINE_ID)* | xargs -r docker network rm
docker ps -a -q -f name=$(COMPOSE_PROJECT_NAME).* | xargs --no-run-if-empty docker stop || exit 0
docker ps -a -q -f name=$(COMPOSE_PROJECT_NAME).* | xargs --no-run-if-empty docker rm -v -f || exit 0
docker network ls -q -f name=$(COMPOSE_PROJECT_NAME).* | xargs --no-run-if-empty docker network rm || exit 0
## Builds docker image
docker-build:
......@@ -74,21 +71,21 @@ docker-build:
## Runs unit tests | Tests
test-unit: $(REBUILD_IMAGES_FOR_TESTS)
@docker rm -f $(PROJECT_NAME)-unit-$(CI_COMMIT_SHORT_SHA)$(CI_PIPELINE_ID) || true
@docker-compose -p $(COMPOSE_PROJECT_NAME)-unit \
run --name $(PROJECT_NAME)-unit-$(CI_COMMIT_SHORT_SHA)$(CI_PIPELINE_ID) \
@docker rm -f $(PROJECT_ID_UNIT) || true
@docker-compose -p $(PROJECT_ID_UNIT) \
run --name $(PROJECT_ID_UNIT) \
$(PROJECT_NAME)-test-unit pytest -v -q --cov-report= --cov=prozorro_sale test/unit
@docker cp $(PROJECT_NAME)-unit-$(CI_COMMIT_SHORT_SHA)$(CI_PIPELINE_ID):/$(PROJECT_NAME)/.coverage .coverage.unit
@docker-compose -p $(COMPOSE_PROJECT_NAME)-unit stop
@docker cp $(PROJECT_ID_UNIT):/$(PROJECT_NAME)/.coverage .coverage.unit
@docker-compose -p $(PROJECT_ID_UNIT) stop
## Runs integration tests
test-integration: $(REBUILD_IMAGES_FOR_TESTS)
@docker rm -f $(PROJECT_NAME)-integration-$(CI_COMMIT_SHORT_SHA)$(CI_PIPELINE_ID) || true
@docker-compose -p $(COMPOSE_PROJECT_NAME)-integration \
run --name $(PROJECT_NAME)-integration-$(CI_COMMIT_SHORT_SHA)$(CI_PIPELINE_ID) \
@docker rm -f $(PROJECT_ID_INTEGRATION) || true
@docker-compose -p $(PROJECT_ID_INTEGRATION) \
run --name $(PROJECT_ID_INTEGRATION) \
$(PROJECT_NAME)-test-integration pytest -v -s -q --cov-report= --cov=prozorro_sale test/integration/
@docker cp $(PROJECT_NAME)-integration-$(CI_COMMIT_SHORT_SHA)$(CI_PIPELINE_ID):/$(PROJECT_NAME)/.coverage .coverage.integration
@docker-compose -p $(COMPOSE_PROJECT_NAME)-integration stop
@docker cp $(PROJECT_ID_INTEGRATION):/$(PROJECT_NAME)/.coverage .coverage.integration
@docker-compose -p $(PROJECT_ID_INTEGRATION) stop
## Safety checks your installed dependencies for known security vulnerabilities.
safety: docker-build
......@@ -123,13 +120,13 @@ push-helm-package:
## Publish coverage report
publish-coverage:
@docker rm -f $(CI_COMMIT_SHORT_SHA) || true
@docker run -d --name $(CI_COMMIT_SHORT_SHA) $(IMAGE_TEST) sleep infinity
@docker cp .coverage.unit $(CI_COMMIT_SHORT_SHA):/tmp/
@docker cp .coverage.integration $(CI_COMMIT_SHORT_SHA):/tmp/
@docker exec $(CI_COMMIT_SHORT_SHA) bash -c "cd /tmp && coverage combine && coverage report && coverage html -d cover-html"
@docker cp $(CI_COMMIT_SHORT_SHA):/tmp/cover-html cover-html
@docker rm -f $(CI_COMMIT_SHORT_SHA)
@docker rm -f $(PUBLISH_STAGE_CONTAINER_NAME) || true
@docker run -d --name $(PUBLISH_STAGE_CONTAINER_NAME) $(IMAGE_TEST) sleep infinity
@docker cp .coverage.unit $(PUBLISH_STAGE_CONTAINER_NAME):/tmp/
@docker cp .coverage.integration $(PUBLISH_STAGE_CONTAINER_NAME):/tmp/
@docker exec $(PUBLISH_STAGE_CONTAINER_NAME) bash -c "cd /tmp && coverage combine && coverage report && coverage html -d cover-html"
@docker cp $(PUBLISH_STAGE_CONTAINER_NAME):/tmp/cover-html cover-html
@docker rm -f $(PUBLISH_STAGE_CONTAINER_NAME)
## Create tag
version:
......
......@@ -3,7 +3,6 @@ version: '3.3'
services:
auth-app: &base_app
image: "${IMAGE}"
container_name: auth-api
command: python -m prozorro_sale.auth.api
environment: &base_app_environment
AUCTIONS_API: "http://0.0.0.0:7777"
......@@ -12,7 +11,6 @@ services:
auth-databridge:
<<: *base_app
container_name: auth-databridge
command: python -m prozorro_sale.auth.databridge
auth-test-integration: &test_app
......@@ -46,7 +44,6 @@ services:
auth-databridge-local:
<<: *local_app
container_name: auth-databridge
command: adev runserver --app-factory=create_databridge prozorro_sale/auth/databridge
environment:
<<: *local_app_environment
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment