Skip to content

Optimize make test-unit for sub-30s feedback via impacted-first execution - #47200

Merged
pelikhan merged 6 commits into
mainfrom
copilot/optimize-test-unit-duration
Jul 22, 2026
Merged

Optimize make test-unit for sub-30s feedback via impacted-first execution#47200
pelikhan merged 6 commits into
mainfrom
copilot/optimize-test-unit-duration

Conversation

Copilot AI commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

make test-unit currently runs the full Go unit suite, which is too slow for iteration. This update shifts the default path to impacted-first execution with a ~30s budget target, while preserving an explicit full-suite option.

  • Default test-unit behavior: impacted-first, budget-oriented

    • test-unit now delegates to test-impacted-go with:
      • GO_IMPACTED_TEST_MAX_SECONDS=$(TEST_UNIT_MAX_SECONDS) (default 30s)
      • coverage-correlation disabled for local speed (CI_COVERAGE_ENABLED=0)
    • Added TEST_UNIT_MAX_SECONDS and TEST_UNIT_IMPACTED_FALLBACK_MODE knobs.
  • Deterministic fallback when timing artifacts are unavailable

    • Extended test-impacted-go with fallback mode sample:
      • runs up to GO_IMPACTED_TEST_SAMPLE_PER_PACKAGE top-level tests per impacted package
      • avoids falling back to full-package execution for the default test-unit path
    • Centralized fallback defaults with GO_IMPACTED_TEST_SAMPLE_PER_PACKAGE_DEFAULT.
  • Explicit full-suite path preserved

    • Added test-unit-all for full Go unit coverage (go test ./... -short).
    • test-unit can append full coverage via TEST_UNIT_RUN_FULL=1.
    • test continues to run test-unit + test-integration (now benefits from impacted-first unit pass).
  • Developer UX updates

    • Help text now reflects impacted-first semantics and the full-suite toggle.
# Fast default
make test-unit

# Fast path with custom budget
make test-unit TEST_UNIT_MAX_SECONDS=45

# Fast path + full suite
TEST_UNIT_RUN_FULL=1 make test-unit

# Full suite only
make test-unit-all

Copilot AI and others added 4 commits July 21, 2026 07:21
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot update agents.md and agent instructions

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

@copilot update agents.md and agent instructions

Updated both /home/runner/work/gh-aw/gh-aw/AGENTS.md and /home/runner/work/gh-aw/gh-aw/.github/aw/instructions.md with the impacted-first test-unit guidance and the explicit full-suite options (TEST_UNIT_RUN_FULL=1 make test-unit / make test-unit-all) in commit 6255319.

@github-actions

Copy link
Copy Markdown
Contributor

🤖 PR Triage

Field Value
Category chore
Risk 🟡 Medium
Score 52/100 (impact: 22, urgency: 15, quality: 15)
Action 📦 batch_review — batch: go-code

Changes make test-unit behavior to impacted-first execution with a ~30s budget. Medium risk as it alters the test execution strategy. Review alongside other go-code PRs.

Generated by 🔧 PR Triage Agent · sonnet46 35.2 AIC · ⌖ 7.92 AIC · ⊞ 5.6K ·

Comment thread .github/aw/instructions.md Outdated
- 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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot revert changes in this file

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in commit 2a8c00a.

@pelikhan
pelikhan marked this pull request as ready for review July 22, 2026 07:27
Copilot AI review requested due to automatic review settings July 22, 2026 07:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Changes unit-test validation to prioritize impacted Go tests within a configurable time budget.

Changes:

  • Adds impacted-first and full-suite test modes.
  • Adds deterministic sampled fallback behavior.
  • Updates agent guidance and Make help text.
Show a summary per file
File Description
Makefile Implements impacted-first testing, sampling, and full-suite targets.
AGENTS.md Documents the revised validation workflow.
.github/aw/instructions.md Adds repository-specific test guidance.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 3/3 changed files
  • Comments generated: 4
  • Review effort level: Medium

Comment thread Makefile
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); \
Comment thread Makefile
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); \
Comment thread Makefile
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'|' -); \
Comment thread Makefile
Comment on lines +1234 to +1235
@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"
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI requested a review from pelikhan July 22, 2026 07:35
@pelikhan
pelikhan merged commit 83199f4 into main Jul 22, 2026
26 checks passed
@pelikhan
pelikhan deleted the copilot/optimize-test-unit-duration branch July 22, 2026 07:36
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.83.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants