Skip to content

ci: selective unit testing based on changed packages#4815

Draft
walldiss wants to merge 1 commit intocelestiaorg:mainfrom
walldiss:ci/selective-package-testing
Draft

ci: selective unit testing based on changed packages#4815
walldiss wants to merge 1 commit intocelestiaorg:mainfrom
walldiss:ci/selective-package-testing

Conversation

@walldiss
Copy link
Member

@walldiss walldiss commented Mar 2, 2026

Summary

  • Adds scripts/affected-packages.sh: computes which Go packages need testing based on what files changed in the PR
  • On pull_request events: only packages that changed, plus any package that (transitively) imports a changed package, are tested
  • On push to main: full test suite runs unchanged
  • Automatic fallback to full suite when go.mod/go.sum changes

How it works

  1. Collect changed .go files vs github.base_ref
  2. Map each file to its Go package
  3. BFS over the import graph to find all packages that depend on any changed package (reverse transitive closure)
  4. Run go test on that set only

Fallback conditions (runs all packages)

  • go.mod or go.sum changed — dependency graph may have shifted
  • No Go files changed — non-code PR, safest to run everything
  • Any push to main — always validate the full suite

Untested

Add scripts/affected-packages.sh which computes the set of directly
changed Go packages plus their transitive reverse dependencies.
On pull_request events the CI tests only the affected set; on pushes
to main all packages are tested. Falls back to the full package list
when go.mod/go.sum changes or no Go files were modified.
@walldiss walldiss marked this pull request as draft March 2, 2026 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant