Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Everything else should be loaded **lazily** through skills only when needed.

1. If you changed files, use `report_progress` to commit and push.
2. Before **intermediate** `report_progress` calls, run `make agent-report-progress-no-test` (fast, no tests). Before the **final** `report_progress`, run `make agent-report-progress` (includes `test-unit`).
- `test-unit` is impacted-first by default (~30s target). Use `TEST_UNIT_RUN_FULL=1 make test-unit` or `make test-unit-all` when full-suite coverage is required.
- Run `test-unit` only once per PR — at the final push, not on every intermediate save.
3. After Go changes, run `make fmt`.
4. After workflow markdown changes (`.md` under `.github/workflows/`), run `make recompile`.
Expand Down
41 changes: 38 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ CI_UNIT_TEST_ARTIFACT_PATTERN ?= test-result-cgo-unit
CI_UNIT_RUN_ID ?=
GO_IMPACTED_TEST_MAX_SECONDS ?= 60
GO_IMPACTED_TEST_PATTERN_MAX_CHARS ?= 8000
GO_IMPACTED_TEST_FALLBACK_MODE ?= package
GO_IMPACTED_TEST_SAMPLE_PER_PACKAGE_DEFAULT ?= 5
GO_IMPACTED_TEST_SAMPLE_PER_PACKAGE ?= $(GO_IMPACTED_TEST_SAMPLE_PER_PACKAGE_DEFAULT)
TEST_UNIT_MAX_SECONDS ?= 30
TEST_UNIT_RUN_FULL ?= 0
TEST_UNIT_IMPACTED_FALLBACK_MODE ?= sample

# Build flags
LDFLAGS=-ldflags "-s -w -X main.version=$(VERSION)"
Expand Down Expand Up @@ -79,10 +85,20 @@ build-wasm:
.PHONY: test
test: test-unit test-integration

# Test unit tests only (excludes labelled integration tests and long tests)
# Test all Go unit tests only (excludes labelled integration tests and long tests)
.PHONY: test-unit-all
test-unit-all:
go test -v -parallel=4 -timeout=10m -run='^Test' ./... -short

# Test impacted Go unit tests first for faster feedback (target budget: ~30s)
.PHONY: test-unit
test-unit:
go test -v -parallel=4 -timeout=10m -run='^Test' ./... -short
@echo "Running impacted Go unit tests first (time budget: $(TEST_UNIT_MAX_SECONDS)s)..."; \
$(MAKE) --no-print-directory test-impacted-go CI_COVERAGE_ENABLED=0 GO_IMPACTED_TEST_MAX_SECONDS=$(TEST_UNIT_MAX_SECONDS) GO_IMPACTED_TEST_FALLBACK_MODE=$(TEST_UNIT_IMPACTED_FALLBACK_MODE) GO_IMPACTED_TEST_SAMPLE_PER_PACKAGE=$(GO_IMPACTED_TEST_SAMPLE_PER_PACKAGE); \
if [ "$(TEST_UNIT_RUN_FULL)" = "1" ]; then \
echo "TEST_UNIT_RUN_FULL=1 set; running full Go unit test suite after impacted tests."; \
$(MAKE) --no-print-directory test-unit-all; \
fi

.PHONY: test-integration
test-integration:
Expand Down Expand Up @@ -414,6 +430,24 @@ test-impacted-go:
done || exit 1; \
exit 0; \
fi; \
if [ "$(GO_IMPACTED_TEST_FALLBACK_MODE)" = "sample" ]; then \
SAMPLE_PER_PACKAGE="$(GO_IMPACTED_TEST_SAMPLE_PER_PACKAGE)"; \
case "$$SAMPLE_PER_PACKAGE" in \
''|*[!0-9]*|0) SAMPLE_PER_PACKAGE="$(GO_IMPACTED_TEST_SAMPLE_PER_PACKAGE_DEFAULT)" ;; \
esac; \
echo "No impacted timing data available; running up to $$SAMPLE_PER_PACKAGE sampled top-level tests per impacted package."; \
printf '%s\n' "$$CHANGED_GO_PACKAGES" | while IFS= read -r pkg; do \
[ -z "$$pkg" ] && continue; \
TEST_PATTERN=$$(go test -list '^Test' "$$pkg" 2>/dev/null | head -n "$$SAMPLE_PER_PACKAGE" | paste -sd'|' -); \
if [ -z "$$TEST_PATTERN" ]; then \
echo "No top-level tests discovered in $$pkg; skipping sampled run for this package."; \
continue; \
fi; \
echo "Running sampled impacted Go unit tests in $$pkg with pattern ^($$TEST_PATTERN)$$"; \
go test -v -parallel=4 -timeout=10m -short -run "^($$TEST_PATTERN)$$" "$$pkg" || exit 1; \
done || exit 1; \
exit 0; \
fi; \
# Use -short to exclude integration tests and keep execution to unit-test scope. \
printf '%s\n' "$$CHANGED_GO_PACKAGES" | tr '\n' '\0' | xargs -0 -r go test -v -parallel=4 -timeout=10m -short

Expand Down Expand Up @@ -1197,7 +1231,8 @@ help:
@echo " build-awmg - Build the awmg (MCP gateway) binary for current platform"
@echo " build-all - Build binaries for all platforms (gh-aw and awmg)"
@echo " test - Run Go tests (unit + integration)"
@echo " test-unit - Run Go unit tests only (faster)"
@echo " test-unit - Run impacted Go unit tests first (~$(TEST_UNIT_MAX_SECONDS)s budget); set TEST_UNIT_RUN_FULL=1 for full suite"
@echo " test-unit-all - Run full Go unit test suite"
Comment on lines +1234 to +1235
@echo " test-security - Run security regression tests"
@echo " test-js - Run JavaScript tests"
@echo " test-impacted-js - Run impacted JavaScript unit tests for current branch changes"
Expand Down
Loading