From e57accc74523aefac31740aa67108806a95f8b5f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 21 Jul 2026 07:21:51 +0000 Subject: [PATCH 1/6] Optimize test-unit with impacted-first execution path Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- Makefile | 44 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index d1ef62a770f..f84d817d909 100644 --- a/Makefile +++ b/Makefile @@ -22,6 +22,10 @@ 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 ?= 5 +TEST_UNIT_MAX_SECONDS ?= 30 +TEST_UNIT_RUN_FULL ?= 0 # Build flags LDFLAGS=-ldflags "-s -w -X main.version=$(VERSION)" @@ -77,12 +81,22 @@ build-wasm: # Test the code (runs both unlabelled unit tests and integration tests and long tests) .PHONY: test -test: test-unit test-integration +test: test-unit-all 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 (target 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=sample 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: @@ -414,6 +428,27 @@ 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]*) SAMPLE_PER_PACKAGE=5 ;; \ + esac; \ + if [ "$$SAMPLE_PER_PACKAGE" -le 0 ]; then \ + SAMPLE_PER_PACKAGE=5; \ + fi; \ + echo "No timing-aware impacted test 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 | grep '^Test' | 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 @@ -1197,7 +1232,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 (target ~30s); set TEST_UNIT_RUN_FULL=1 to append full suite" + @echo " test-unit-all - Run full Go unit test suite" @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" From 89c88f8ff51c8edfcad603d0258aa86e10e2c813 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 21 Jul 2026 07:27:18 +0000 Subject: [PATCH 2/6] Refine impacted test-unit messaging and fallback sampling defaults Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- Makefile | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index f84d817d909..87463306c72 100644 --- a/Makefile +++ b/Makefile @@ -23,7 +23,8 @@ 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 ?= 5 +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 @@ -91,7 +92,7 @@ test-unit-all: # Test impacted Go unit tests first for faster feedback (target budget: ~30s) .PHONY: test-unit test-unit: - @echo "Running impacted Go unit tests first (target budget: $(TEST_UNIT_MAX_SECONDS)s)..."; \ + @echo "Running impacted Go unit tests first (timing-aware target 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=sample 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."; \ @@ -431,15 +432,15 @@ test-impacted-go: if [ "$(GO_IMPACTED_TEST_FALLBACK_MODE)" = "sample" ]; then \ SAMPLE_PER_PACKAGE="$(GO_IMPACTED_TEST_SAMPLE_PER_PACKAGE)"; \ case "$$SAMPLE_PER_PACKAGE" in \ - ''|*[!0-9]*) SAMPLE_PER_PACKAGE=5 ;; \ + ''|*[!0-9]*) SAMPLE_PER_PACKAGE="$(GO_IMPACTED_TEST_SAMPLE_PER_PACKAGE_DEFAULT)" ;; \ esac; \ if [ "$$SAMPLE_PER_PACKAGE" -le 0 ]; then \ - SAMPLE_PER_PACKAGE=5; \ + SAMPLE_PER_PACKAGE="$(GO_IMPACTED_TEST_SAMPLE_PER_PACKAGE_DEFAULT)"; \ fi; \ echo "No timing-aware impacted test 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 | grep '^Test' | head -n "$$SAMPLE_PER_PACKAGE" | paste -sd'|' -); \ + 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; \ @@ -1232,7 +1233,7 @@ 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 impacted Go unit tests first (target ~30s); set TEST_UNIT_RUN_FULL=1 to append full suite" + @echo " test-unit - Run impacted Go unit tests first (target ~$(TEST_UNIT_MAX_SECONDS)s); configurable via TEST_UNIT_MAX_SECONDS and TEST_UNIT_RUN_FULL=1 for full suite" @echo " test-unit-all - Run full Go unit test suite" @echo " test-security - Run security regression tests" @echo " test-js - Run JavaScript tests" From e1baa9dd36b796705e60793ed368166c70ae37df Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 21 Jul 2026 07:32:06 +0000 Subject: [PATCH 3/6] Polish test-unit messaging for impacted-first flow Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 87463306c72..198dc566a53 100644 --- a/Makefile +++ b/Makefile @@ -92,7 +92,7 @@ test-unit-all: # Test impacted Go unit tests first for faster feedback (target budget: ~30s) .PHONY: test-unit test-unit: - @echo "Running impacted Go unit tests first (timing-aware target budget: $(TEST_UNIT_MAX_SECONDS)s)..."; \ + @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=sample 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."; \ @@ -437,7 +437,7 @@ test-impacted-go: if [ "$$SAMPLE_PER_PACKAGE" -le 0 ]; then \ SAMPLE_PER_PACKAGE="$(GO_IMPACTED_TEST_SAMPLE_PER_PACKAGE_DEFAULT)"; \ fi; \ - echo "No timing-aware impacted test data available; running up to $$SAMPLE_PER_PACKAGE sampled top-level tests per impacted package."; \ + 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'|' -); \ @@ -1233,7 +1233,7 @@ 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 impacted Go unit tests first (target ~$(TEST_UNIT_MAX_SECONDS)s); configurable via TEST_UNIT_MAX_SECONDS and TEST_UNIT_RUN_FULL=1 for full suite" + @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" @echo " test-security - Run security regression tests" @echo " test-js - Run JavaScript tests" From 02e2c5f75419651241ab210b8e27d2703261f907 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 21 Jul 2026 07:42:07 +0000 Subject: [PATCH 4/6] Finalize impacted-first test-unit optimization in Makefile Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- Makefile | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 198dc566a53..f416afcca04 100644 --- a/Makefile +++ b/Makefile @@ -27,6 +27,7 @@ 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)" @@ -82,7 +83,7 @@ build-wasm: # Test the code (runs both unlabelled unit tests and integration tests and long tests) .PHONY: test -test: test-unit-all test-integration +test: test-unit test-integration # Test all Go unit tests only (excludes labelled integration tests and long tests) .PHONY: test-unit-all @@ -93,7 +94,7 @@ test-unit-all: .PHONY: test-unit test-unit: @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=sample GO_IMPACTED_TEST_SAMPLE_PER_PACKAGE=$(GO_IMPACTED_TEST_SAMPLE_PER_PACKAGE); \ + $(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; \ @@ -432,11 +433,8 @@ test-impacted-go: if [ "$(GO_IMPACTED_TEST_FALLBACK_MODE)" = "sample" ]; then \ SAMPLE_PER_PACKAGE="$(GO_IMPACTED_TEST_SAMPLE_PER_PACKAGE)"; \ case "$$SAMPLE_PER_PACKAGE" in \ - ''|*[!0-9]*) SAMPLE_PER_PACKAGE="$(GO_IMPACTED_TEST_SAMPLE_PER_PACKAGE_DEFAULT)" ;; \ + ''|*[!0-9]*|0) SAMPLE_PER_PACKAGE="$(GO_IMPACTED_TEST_SAMPLE_PER_PACKAGE_DEFAULT)" ;; \ esac; \ - if [ "$$SAMPLE_PER_PACKAGE" -le 0 ]; then \ - SAMPLE_PER_PACKAGE="$(GO_IMPACTED_TEST_SAMPLE_PER_PACKAGE_DEFAULT)"; \ - fi; \ 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; \ From 6255319787a2b7c8695a99c4d79f50d2761f70ff Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 22 Jul 2026 06:02:44 +0000 Subject: [PATCH 5/6] docs: clarify impacted-first test-unit guidance for agents Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- .github/aw/instructions.md | 1 + AGENTS.md | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/aw/instructions.md b/.github/aw/instructions.md index 9162d255f45..9a33a354dda 100644 --- a/.github/aw/instructions.md +++ b/.github/aw/instructions.md @@ -19,5 +19,6 @@ Add your repository-specific standards here, for example: - Standard frontmatter defaults - Frontmatter ordering/style conventions - Security or policy constraints specific to this repository +- For agent validation guidance, treat `make test-unit` as impacted-first (~30s target); use `TEST_UNIT_RUN_FULL=1 make test-unit` or `make test-unit-all` when you need full Go unit-suite coverage. - When documenting or recommending Copilot authentication, state that `permissions: { copilot-requests: write }` uses `${{ github.token }}` for inference and does not require a PAT or `COPILOT_GITHUB_TOKEN` secret - When you need prior art for workflow design, shared components, tool configuration, or safe-output patterns, use GitHub APIs or `gh` to inspect `https://github.com/gm3dmo/the-power` before inventing a new pattern diff --git a/AGENTS.md b/AGENTS.md index 41463da2d02..48ed2de6654 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -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`. From 2a8c00a307730f5769e1d4b27f4141efafdb4ff6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 22 Jul 2026 07:34:28 +0000 Subject: [PATCH 6/6] docs: revert aw instructions update per review Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- .github/aw/instructions.md | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/aw/instructions.md b/.github/aw/instructions.md index 9a33a354dda..9162d255f45 100644 --- a/.github/aw/instructions.md +++ b/.github/aw/instructions.md @@ -19,6 +19,5 @@ Add your repository-specific standards here, for example: - Standard frontmatter defaults - Frontmatter ordering/style conventions - Security or policy constraints specific to this repository -- For agent validation guidance, treat `make test-unit` as impacted-first (~30s target); use `TEST_UNIT_RUN_FULL=1 make test-unit` or `make test-unit-all` when you need full Go unit-suite coverage. - When documenting or recommending Copilot authentication, state that `permissions: { copilot-requests: write }` uses `${{ github.token }}` for inference and does not require a PAT or `COPILOT_GITHUB_TOKEN` secret - When you need prior art for workflow design, shared components, tool configuration, or safe-output patterns, use GitHub APIs or `gh` to inspect `https://github.com/gm3dmo/the-power` before inventing a new pattern