-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
74 lines (63 loc) · 1.95 KB
/
Makefile
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
# Variables
BINARY_NAME=go-deploy
BUILD_DIR=bin
MAIN_FILE=main.go
BUILDTIMESTAMP=$(shell date -u +%Y%m%d%H%M%S)
EXT=$(if $(filter windows,$(GOOS)),.exe,)
# Targets
.PHONY: all clean build run clean docs release test acc e2e lint
all: build
build:
@echo "Building the application..."
@mkdir -p $(BUILD_DIR)
@CGO_ENABLED=0 go build -o $(BUILD_DIR)/$(BINARY_NAME)$(EXT) .
@echo "Build complete."
run: build
@echo "Running the application..."
@./$(BUILD_DIR)/$(BINARY_NAME)$(EXT)
clean:
@echo "Cleaning up..."
@rm -rf $(BUILD_DIR)
@echo "Clean complete."
docs:
@cd scripts && ./generate-docs.sh && ./generate-types.sh
release: docs
@echo "Building the application..."
@mkdir -p $(BUILD_DIR)
@CGO_ENABLED=0 go build -mod=readonly -ldflags "-w -s" -o $(BUILD_DIR)/$(BINARY_NAME)$(EXT) .
@echo "Build complete."
test: clean build
@go test ./test/acc/...
@echo "Starting go-deploy in test mode..."
@./$(BUILD_DIR)/$(BINARY_NAME)$(EXT) --mode=test & echo $$! > go_deploy.pid
@echo "Waiting for API to become ready..."
@until curl --output /dev/null --silent --head --fail http://localhost:8080/healthz; do \
echo "Waiting for API to start"; \
sleep 1; \
done
@echo "API is ready!"
@echo "Running e2e tests..."
@go test ./test/e2e/...
@if [ -f go_deploy.pid ]; then \
echo "Stopping go-deploy..."; \
kill $$(cat go_deploy.pid) && rm -f go_deploy.pid; \
fi
acc: clean build
@go test ./test/acc/...
e2e: clean build
@echo "Starting go-deploy in test mode..."
@./$(BUILD_DIR)/$(BINARY_NAME)$(EXT) --mode=test & echo $$! > go_deploy.pid
@echo "Waiting for API to become ready..."
@until curl --output /dev/null --silent --head --fail http://localhost:8080/healthz; do \
echo "Waiting for API to start"; \
sleep 1; \
done
@echo "API is ready!"
@echo "Running e2e tests..."
@go test ./test/e2e/...
@if [ -f go_deploy.pid ]; then \
echo "Stopping go-deploy..."; \
kill $$(cat go_deploy.pid) && rm -f go_deploy.pid; \
fi
lint:
@./scripts/check-lint.sh