-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
37 lines (30 loc) · 1.2 KB
/
Makefile
File metadata and controls
37 lines (30 loc) · 1.2 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
.PHONY: pre-commit
pre-commit:
@echo "Checking staged Go files..."
@STAGED_GO_FILES=$$(git diff --cached --name-only --diff-filter=ACM | grep '\.go$$' || true); \
if [ -n "$$STAGED_GO_FILES" ]; then \
echo "Running go fmt on staged files..."; \
UNFORMATTED=$$(gofmt -l $$STAGED_GO_FILES); \
if [ -n "$$UNFORMATTED" ]; then \
echo "[FAIL] The following staged Go files are not properly formatted:"; \
echo "$$UNFORMATTED"; \
exit 1; \
else \
echo "[SUCCESS] All staged Go files are properly formatted."; \
fi \
else \
echo "No staged Go files to check."; \
fi
@echo "build sysy test image"
@chmod +x ./bin/build-precommit-test.sh
@./bin/build-precommit-test.sh
@echo "Running go vet..."
@go vet ./... || (echo "[FAIL] go vet failed." && exit 1)
@echo "Running go test (integration testing)..."
@go test ./test/it/... -v || (echo "[FAIL] Integration testing failed." && exit 1)
@echo "[SUCCESS] Pre-commit checks passed!"
@echo "Removing services image"
@if docker images daffaputranarendra/sysy:test | awk 'NR>1 {print $1}' | grep -q .; then docker rmi daffaputranarendra/sysy:test; fi
precom-preparation:
@cp ./bin/pre-commit ./.git/hooks/pre-commit
@chmod +x ./.git/hooks/pre-commit