@@ -13,7 +13,7 @@ LOCAL_PROJECT = submitqueue
1313# Set REPO_ROOT for docker-compose
1414export REPO_ROOT := $(shell pwd)
1515
16- .PHONY : build build-all-linux build-gateway-linux build-orchestrator-linux clean clean-proto deps e2e-test gazelle integration-test integration-test-extensions integration-test-gateway integration-test-orchestrator local-clean local-gateway-start local-gateway-stop local-init-schemas local-logs local-orchestrator-start local-orchestrator-stop local-ps local-restart local-start local-stop proto query-deps query-targets run-client-gateway run-client-orchestrator run-queue-admin test test-no-cache help
16+ .PHONY : build build-all-linux build-gateway-linux build-orchestrator-linux check-gazelle check-tidy clean clean-proto deps e2e-test fmt gazelle integration-test integration-test-extensions integration-test-gateway integration-test-orchestrator lint lint-fmt lint-json lint-shell lint-yaml local-clean local-gateway-start local-gateway-stop local-init-schemas local-logs local-orchestrator-start local-orchestrator-stop local-ps local-restart local-start local-stop proto query-deps query-targets run-client-gateway run-client-orchestrator run-queue-admin test test-no-cache help
1717
1818
1919build : # # Build all services and examples
@@ -41,6 +41,36 @@ build-orchestrator-linux: ## Build Orchestrator Linux binary for Docker
4141 cp -f bazel-bin/example/server/orchestrator/orchestrator .docker-bin/orchestrator
4242 @echo " Orchestrator Linux binary ready at .docker-bin/orchestrator"
4343
44+ check-gazelle : # # Check BUILD.bazel files are up to date
45+ @echo " Running Gazelle to check BUILD files..."
46+ @$(BAZEL ) run //:gazelle
47+ @if ! git diff --quiet; then \
48+ echo " BUILD files are out of date!" >&2 ; \
49+ echo " " >&2 ; \
50+ echo " The following files were modified by Gazelle:" >&2 ; \
51+ git diff --name-only >&2 ; \
52+ echo " " >&2 ; \
53+ echo " Please run 'make gazelle' locally and commit the changes." >&2 ; \
54+ exit 1; \
55+ fi
56+ @echo " BUILD files are up to date."
57+
58+ check-tidy : # # Check that go.mod and MODULE.bazel are tidy
59+ @echo " Running go mod tidy..."
60+ @go mod tidy -e
61+ @echo " Running bazel mod tidy..."
62+ @$(BAZEL ) mod tidy
63+ @if ! git diff --quiet; then \
64+ echo " Module files are out of date!" >&2 ; \
65+ echo " " >&2 ; \
66+ echo " The following files were modified:" >&2 ; \
67+ git diff --name-only >&2 ; \
68+ echo " " >&2 ; \
69+ echo " Please run 'go mod tidy' and 'bazel mod tidy' locally and commit the changes." >&2 ; \
70+ exit 1; \
71+ fi
72+ @echo " Module files are up to date."
73+
4474clean : # # Clean generated files and binaries
4575 @echo " Cleaning with Bazel..."
4676 @$(BAZEL ) clean
@@ -63,6 +93,12 @@ e2e-test: build-all-linux ## Run end-to-end tests (hermetic, auto-builds binarie
6393 @echo " Running end-to-end tests..."
6494 @$(BAZEL ) test //test/e2e:e2e_test --test_output=streamed
6595
96+ fmt : # # Format Go code
97+ @GOFMT=$$($(BAZEL ) run @rules_go//go -- env GOROOT 2>/dev/null | tail -1) /bin/gofmt; \
98+ echo " Formatting Go code (using $$ GOFMT)..." ; \
99+ $$ GOFMT -w . ; \
100+ echo " Formatting complete!"
101+
66102gazelle : # # Update BUILD.bazel files
67103 @echo " Running Gazelle to update BUILD files..."
68104 @$(BAZEL ) run //:gazelle
@@ -83,6 +119,47 @@ integration-test-orchestrator: build-orchestrator-linux ## Run Orchestrator inte
83119 @echo " Running Orchestrator integration tests..."
84120 @$(BAZEL ) test //test/integration/orchestrator:orchestrator_test --test_output=streamed
85121
122+ lint : lint-fmt lint-json lint-shell lint-yaml # # Run all linters
123+ @echo " All lint checks passed."
124+
125+ lint-fmt : # # Check Go code formatting (fails if unformatted)
126+ @GOFMT=$$($(BAZEL ) run @rules_go//go -- env GOROOT 2>/dev/null | tail -1) /bin/gofmt; \
127+ echo " Checking Go code formatting (using $$ GOFMT)..." ; \
128+ unformatted=$$($$GOFMT -l . ) ; \
129+ if [ -n " $$ unformatted" ]; then \
130+ echo " The following files are not formatted:" >&2 ; \
131+ echo " $$ unformatted" >&2 ; \
132+ echo " " >&2 ; \
133+ echo " Please run 'make fmt' and commit the changes." >&2 ; \
134+ exit 1; \
135+ fi
136+ @echo " All Go files are properly formatted."
137+
138+ lint-json : # # Check JSON files are valid
139+ @echo " Checking JSON files..."
140+ @invalid=0; \
141+ for f in $$ (find . -name ' *.json' -not -path ' ./bazel-*' -not -path ' ./.git/*' 2> /dev/null); do \
142+ if ! jq . " $$ f" > /dev/null 2>&1 ; then \
143+ echo " Invalid JSON: $$ f" >&2 ; \
144+ invalid=1; \
145+ fi ; \
146+ done ; \
147+ if [ " $$ invalid" -eq 1 ]; then exit 1; fi
148+ @echo " All JSON files are valid."
149+
150+ lint-shell : # # Check shell scripts with shellcheck
151+ @echo " Checking shell scripts..."
152+ @scripts=$$(find . -name '*.sh' -not -path './bazel-*' -not -path './.git/*' 2>/dev/null ) ; \
153+ if [ -n " $$ scripts" ]; then \
154+ shellcheck $$ scripts; \
155+ fi
156+ @echo " All shell scripts are valid."
157+
158+ lint-yaml : # # Check YAML files with yamllint
159+ @echo " Checking YAML files..."
160+ @yamllint -c .yamllint.yml .
161+ @echo " All YAML files are valid."
162+
86163local-clean : # # Stop and remove all local services, volumes, and images
87164 @echo " Cleaning all services and data..."
88165 @$(COMPOSE ) -f $(COMPOSE_FILE ) -p $(LOCAL_PROJECT ) down -v --rmi local
0 commit comments