-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
86 lines (71 loc) · 3.33 KB
/
Copy pathMakefile
File metadata and controls
86 lines (71 loc) · 3.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
BIN ?= bin/gqlgate
IMAGE ?= suprbdev/gqlgate
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
LDFLAGS := -s -w -X main.version=$(VERSION)
.DEFAULT_GOAL := help
.PHONY: help
help: ## Show this help
@grep -hE '^[a-zA-Z0-9_-]+:.*?## ' $(MAKEFILE_LIST) | \
awk 'BEGIN{FS=":.*?## "}{printf " \033[36m%-16s\033[0m %s\n", $$1, $$2}'
.PHONY: build
build: ## Build the gqlgate binary
CGO_ENABLED=0 go build -trimpath -ldflags="$(LDFLAGS)" -o $(BIN) ./cmd/gqlgate
.PHONY: test
test: ## Run the hermetic test suite
go test ./...
.PHONY: test-e2e
test-e2e: ## Run the end-to-end tests against a composed pdbq + postgres
docker compose -p gqlgate-test -f compose.test.yaml up -d --wait
GQLGATE_TEST_TARGET_URL=http://localhost:8090 \
GQLGATE_TEST_VERBOSE_URL=http://localhost:8091 \
go test ./test/... -count=1 -v; \
status=$$?; \
docker compose -p gqlgate-test -f compose.test.yaml down -v; \
exit $$status
.PHONY: lint
lint: ## Vet and format-check the tree
go vet ./...
@test -z "$$(gofmt -l . | tee /dev/stderr)" || (echo "gofmt needed"; exit 1)
.PHONY: openapi
openapi: build ## Print the OpenAPI document for the committed test fixture
$(BIN) openapi --schema.path internal/gqlschema/testdata/pdbq.json --upstream.url http://unused
.PHONY: golden
golden: ## Regenerate the golden route tables (review the diff before committing)
go test ./internal/plan -args -update
.PHONY: routes
routes: build ## Print the route table for the committed test fixture
$(BIN) routes --schema.path internal/gqlschema/testdata/pdbq.json --upstream.url http://localhost:8080
.PHONY: example-config
example-config: build ## Regenerate examples/gqlgate.example.yaml
@mkdir -p examples
$(BIN) config example > examples/gqlgate.example.yaml
@echo "wrote examples/gqlgate.example.yaml"
.PHONY: docker-build
docker-build: ## Build the container image
docker build --build-arg VERSION=$(VERSION) -t $(IMAGE):$(VERSION) -t $(IMAGE):latest .
.PHONY: compose-up
compose-up: ## Start the local stack (postgres + pdbq + gqlgate)
docker compose up --build
.PHONY: compose-down
compose-down: ## Stop the local stack and remove volumes
docker compose down -v
# Verifies, tags, and pushes; the Release workflow (release.yaml) then builds
# the binaries/image and publishes the GitHub release with generated notes.
.PHONY: release
release: ## Cut a new release (prompts for version, tags, pushes)
@set -e; \
git diff --quiet && git diff --cached --quiet || { echo "error: working tree dirty — commit or stash first"; exit 1; }; \
current=$$(git describe --tags --abbrev=0 2>/dev/null || echo "(none)"); \
echo "Current version: $$current"; \
printf "New version (vX.Y.Z): "; read -r version; \
echo "$$version" | grep -Eq '^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.]+)?$$' || { echo "error: invalid version '$$version' (expected vX.Y.Z)"; exit 1; }; \
if git rev-parse -q --verify "refs/tags/$$version" >/dev/null; then echo "error: tag $$version already exists"; exit 1; fi; \
$(MAKE) test lint; \
git tag -a "$$version" -m "$$version"; \
git push origin HEAD "$$version"; \
url=$$(git remote get-url origin | sed -E 's#^git@github\.com:#https://github.com/#; s#\.git$$##'); \
echo "Pushed $$version — the Release workflow is publishing it:"; \
echo " $$url/actions/workflows/release.yaml"
.PHONY: clean
clean: ## Remove build artifacts
rm -rf bin dist