forked from fifthsegment/Gatesentry
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
39 lines (35 loc) · 1.34 KB
/
Makefile
File metadata and controls
39 lines (35 loc) · 1.34 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
.PHONY: test build run clean-test
clean-test:
@echo "Cleaning up test artifacts..."
@-kill `cat /tmp/gatesentry.pid 2>/dev/null` 2>/dev/null || true
@-rm -f /tmp/gatesentry.pid /tmp/gatesentry.log
@-rm -rf /tmp/gatesentry
build: clean-test
go build -o /tmp/gatesentry-bin .
run: build
cd /tmp && ./gatesentry-bin
# Run integration tests with server
test: clean-test build
@echo "Starting Gatesentry server in background..."
@cd /tmp && ./gatesentry-bin > /dev/null 2>&1 & echo $$! > /tmp/gatesentry.pid
@echo "Waiting for server to be ready..."
@for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15; do \
if curl -s http://localhost:10786/api/health > /dev/null 2>&1 || curl -s http://localhost:10786 > /dev/null 2>&1; then \
echo "Server is ready!"; \
break; \
fi; \
if [ $$i -eq 15 ]; then \
echo "Server failed to start. Logs:"; \
cat /tmp/gatesentry.log; \
kill `cat /tmp/gatesentry.pid` 2>/dev/null || true; \
rm -f /tmp/gatesentry.pid; \
exit 1; \
fi; \
echo "Waiting... ($$i/15)"; \
sleep 2; \
done
@echo "Running tests..."
@GODEBUG=gotestcache=off go test -v -timeout 5m ./tests/... -coverprofile=coverage.txt -covermode=atomic || (kill `cat /tmp/gatesentry.pid` 2>/dev/null; rm -f /tmp/gatesentry.pid; exit 1)
@echo "Stopping server..."
@kill `cat /tmp/gatesentry.pid` 2>/dev/null || true
@rm -f /tmp/gatesentry.pid