Skip to content

Commit

Permalink
HMS-2056 ci: update makefiles for smoke tests
Browse files Browse the repository at this point in the history
Update the makefile rules to integrate smoke tests for the 'test' rule.

Signed-off-by: Alejandro Visiedo <[email protected]>
  • Loading branch information
avisiedo committed Nov 25, 2023
1 parent de3517e commit 60eae2a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
4 changes: 3 additions & 1 deletion scripts/mk/compose.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

ifeq (podman,$(CONTAINER_ENGINE))
CONTAINER_COMPOSE ?= podman-compose
CONTAINER_DATABASE_NAME ?= $(COMPOSE_PROJECT)_database_1
else
CONTAINER_COMPOSE ?= docker-compose
CONTAINER_DATABASE_NAME ?= $(COMPOSE_PROJECT)-database-1
endif

COMPOSE_FILE ?= $(PROJECT_DIR)/deployments/docker-compose.yaml
Expand Down Expand Up @@ -53,7 +55,7 @@ compose-up: ## Start local infrastructure
.PHONY: .compose-wait-db
.compose-wait-db:
@printf "Waiting database"; \
while [ "$$( $(CONTAINER_ENGINE) container inspect --format '{{$(CONTAINER_HEALTH_PATH)}}' "$(COMPOSE_PROJECT)_database_1" )" != "healthy" ]; \
while [ "$$( $(CONTAINER_ENGINE) container inspect --format '{{$(CONTAINER_HEALTH_PATH)}}' "$(CONTAINER_DATABASE_NAME)" )" != "healthy" ]; \
do sleep 1; printf "."; \
done; \
printf "\n"
Expand Down
17 changes: 12 additions & 5 deletions scripts/mk/go-rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -91,20 +91,27 @@ vendor: ## Generate vendor/ directory populated with the dependencies
# Exclude /internal/interface directories because only contain interfaces
TEST_GREP_FILTER := -v \
-e /vendor/ \
-e /internal/test/mock \
-e /internal/test \
-e /internal/interface/ \
-e /internal/api/metrics \
-e /internal/api/private \
-e /internal/api/public

.PHONY: test
test: ## Run tests
go test -coverprofile="coverage.out" -covermode count $(MOD_VENDOR) $(shell go list ./... | grep $(TEST_GREP_FILTER) )
test: test-unit test-smoke ## Run unit tests, smoke tests and integration tests

.PHONY: test-unit
test-unit: ## Run unit tests
go test -parallel 4 -coverprofile="coverage.out" -covermode count $(MOD_VENDOR) $(shell go list ./... | grep $(TEST_GREP_FILTER) )

.PHONY: test-ci
test-ci: ## Run tests for ci
go test $(MOD_VENDOR) ./...

.PHONY: test-smoke
test-smoke: ## Run smoke tests
CONFIG_PATH="$(PROJECT_DIR)/configs" go test -parallel 1 ./internal/test/smoke/... -test.failfast -test.v

# Add dependencies from binaries to all the the sources
# so any change is detected for the build rule
$(patsubst cmd/%,$(BIN)/%,$(wildcard cmd/*)): $(shell find $(PROJECT_DIR)/cmd -type f -name '*.go') $(shell find $(PROJECT_DIR)/pkg -type f -name '*.go' 2>/dev/null) $(shell find $(PROJECT_DIR)/internal -type f -name '*.go' 2>/dev/null)
Expand Down Expand Up @@ -164,8 +171,8 @@ $(EVENT_SCHEMA_DIR)/%.event.json: $(EVENT_MESSAGE_DIR)/%.event.yaml

# Mockery support
MOCK_DIRS := internal/api/private \
internal/api/public \
internal/api/openapi \
internal/api/public \
internal/api/openapi \
internal/interface/repository \
internal/interface/interactor \
internal/interface/presenter \
Expand Down

0 comments on commit 60eae2a

Please sign in to comment.