lab2
This commit is contained in:
@@ -5,7 +5,7 @@ ACTION_SCRIPT ?=
|
||||
TLS_ARGS = $(if $(CA_FILE),--ca-file "$(CA_FILE)",)
|
||||
PYTHON_LOCAL = env -u HTTP_PROXY -u HTTPS_PROXY -u ALL_PROXY -u http_proxy -u https_proxy -u all_proxy NO_PROXY=localhost,127.0.0.1,::1 no_proxy=localhost,127.0.0.1,::1 $(PYTHON)
|
||||
|
||||
.PHONY: help check validate test load smoke-local load-local
|
||||
.PHONY: help check validate test load test-persistence smoke-local load-local
|
||||
|
||||
help:
|
||||
@echo "check: offline structure; validate: full OpenAPI (requirements-dev.txt); test: running API; load: synthetic writes"
|
||||
@@ -22,6 +22,10 @@ test:
|
||||
load:
|
||||
$(PYTHON) tests/load.py --base-url "$(BASE_URL)" $(TLS_ARGS)
|
||||
|
||||
test-persistence:
|
||||
@test -n "$(ACTION_SCRIPT)" || (echo "Set ACTION_SCRIPT to your implemented executable restart hook"; exit 2)
|
||||
$(PYTHON) tests/resilience.py --mode persistence --action-script "$(ACTION_SCRIPT)" --base-url "$(BASE_URL)" $(TLS_ARGS)
|
||||
|
||||
smoke-local:
|
||||
$(PYTHON_LOCAL) tests/smoke.py --base-url "$(BASE_URL)" $(TLS_ARGS)
|
||||
|
||||
@@ -37,18 +41,38 @@ GOLANGCI_LINT_VERSION ?= v2.13.2
|
||||
GOLANGCI_LINT := $(LOCAL_BIN)/golangci-lint
|
||||
OPENAPI_SPEC := contracts/openapi.json
|
||||
OGEN_CONFIG := .ogen.yml
|
||||
OAS_DIR := internal/transport/rest/oas
|
||||
OAS_DIR := internal/transport/rest/internal/oas
|
||||
|
||||
-include .env
|
||||
export
|
||||
|
||||
# .env feeds local tooling, but its application variables must not leak into the
|
||||
# Go test process: the config tests assert defaults and the dev YAML, so an
|
||||
# ambient REDIS_ENABLED/CACHE_ENABLED would fail them.
|
||||
ENV_KEYS := $(shell sed -n 's/^\([A-Za-z_][A-Za-z0-9_]*\)=.*/\1/p' .env 2>/dev/null)
|
||||
CLEAN_ENV = env $(addprefix -u ,$(ENV_KEYS))
|
||||
|
||||
.PHONY: unit-test
|
||||
unit-test:
|
||||
$(GO) test -race -shuffle=on -count=1 -timeout=5m ./...
|
||||
$(CLEAN_ENV) $(GO) test -race -shuffle=on -count=1 -timeout=5m ./...
|
||||
|
||||
.PHONY: integration-test
|
||||
integration-test:
|
||||
$(GO) test -tags=integration -p 1 -count=1 -timeout=15m ./internal/storage/postgres ./internal/storage/redis
|
||||
|
||||
.PHONY: test-db-up test-db-down
|
||||
test-db-up:
|
||||
@docker-compose -f docker-compose.local.yaml up -d --wait postgres redis
|
||||
|
||||
test-db-down:
|
||||
@docker-compose -f docker-compose.local.yaml down
|
||||
|
||||
# не учитываем генеренные файлы, также cmd в подсчете покрытия
|
||||
COVER_EXCLUDE ?= /(mocks|oas)/|/cmd/
|
||||
|
||||
.PHONY: cover
|
||||
cover:
|
||||
$(GO) test -race -shuffle=on -count=1 -timeout=5m \
|
||||
$(CLEAN_ENV) $(GO) test -race -shuffle=on -count=1 -timeout=5m \
|
||||
-covermode=atomic -coverprofile=coverage.out.tmp ./...
|
||||
@grep -Ev '$(COVER_EXCLUDE)' coverage.out.tmp > coverage.out
|
||||
@rm coverage.out.tmp
|
||||
@@ -56,7 +80,7 @@ cover:
|
||||
$(GO) tool cover -html=coverage.out
|
||||
|
||||
.PHONY: generate
|
||||
generate: generate-api generate-mocks
|
||||
generate: generate-api generate-mocks sqlc
|
||||
|
||||
.PHONY: generate-api
|
||||
generate-api:
|
||||
@@ -66,14 +90,26 @@ generate-api:
|
||||
generate-mocks:
|
||||
$(GO) tool mockery
|
||||
|
||||
.PHONY: run
|
||||
run:
|
||||
$(GO) run $(CMD_PKG)
|
||||
.PHONY: sqlc
|
||||
sqlc:
|
||||
$(GO) tool sqlc generate
|
||||
|
||||
.PHONY: dev-up dev-down dev-reload
|
||||
dev-up:
|
||||
@docker-compose -f docker-compose.local.yaml up -d --build
|
||||
|
||||
dev-down:
|
||||
@docker-compose -f docker-compose.local.yaml down
|
||||
|
||||
dev-reload:
|
||||
@docker-compose -f docker-compose.local.yaml up -d --build --force-recreate
|
||||
|
||||
.PHONY: migrate
|
||||
migrate:
|
||||
$(GO) run ./cmd/migrate up
|
||||
|
||||
$(GOLANGCI_LINT):
|
||||
GOBIN=$(LOCAL_BIN) $(GO) install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)
|
||||
|
||||
lint: $(GOLANGCI_LINT)
|
||||
$(GOLANGCI_LINT) run -v
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user