diff --git a/Makefile b/Makefile index 2ebda1a..8907615 100644 --- a/Makefile +++ b/Makefile @@ -32,14 +32,6 @@ docs: ## create documentation files test: ## run tests @mix test --cover --trace --slowest 10 -.PHONY: compose_up -compose_up: ## start containers for this service - @$(COMPOSE) up -d - -.PHONY: compose_watch -compose_watch: ## start containers for this service watching for updates in filesystem - @$(COMPOSE) up -w - .PHONY: compose_database_create compose_database_create: @$(COMPOSE) run --rm --entrypoint mix app ecto.create @@ -59,6 +51,22 @@ compose_ps: ## status of containers compose_remote: ## connect to remote node @$(COMPOSE) exec app ./priv/docker/service/docker-remote.sh +.PHONY: compose_test +compose_test: ## execute test on docker environment + @$(COMPOSE) --profile test run --rm test + +.PHONY: compose_test_shell +compose_test_shell: ## enter test environment shell + @$(COMPOSE) --profile test run --rm --entrypoint bash test -c bash + +.PHONY: compose_up +compose_up: ## start containers for this service + @$(COMPOSE) up -d + +.PHONY: compose_watch +compose_watch: ## start containers for this service watching for updates in filesystem + @$(COMPOSE) up -w + .PHONY: help help: @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' diff --git a/docker-compose.yml b/docker-compose.yml index 21b55ec..2ca1931 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -19,6 +19,7 @@ services: context: . args: BUILD_MIX_ENV: dev + pull_policy: never hostname: &app_host ex_trainer depends_on: - db @@ -53,6 +54,39 @@ services: scale: 3 entrypoint: ./priv/docker/service/docker-entrypoint.sh command: local-cookie + test: + image: 'joaodubas/ex_trainer:test' + build: + target: builder + context: . + args: + BUILD_MIX_ENV: test + pull_policy: never + profiles: + - test + hostname: ex_trainer_test + depends_on: + - db + init: true + volumes: + - './mix.exs:/opt/app/mix.exs:ro' + - './mix.lock:/opt/app/mix.lock:ro' + - './students.csv:/opt/app/students.csv:ro' + - './config:/opt/app/config' + - './cover:/opt/app/cover' + - './lib:/opt/app/lib' + - './priv:/opt/app/priv' + - './report:/opt/app/report' + - './test:/opt/app/test' + environment: + POSTGRES_HOST: *db_host + POSTGRES_USER: *db_user + POSTGRES_PASS: *db_pass + POSTGRES_NAME: wabanex_test + working_dir: /opt/app + restart: never + entrypoint: mix test + command: --trace --cover --slowest 10 volumes: db_data: {}