Add coverage-aware impacted-unit-test Makefile targets and run them in CGO/CJS workflows#37952
Conversation
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>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot use tools that leverage code coverage to correlate modified source files to impacted tests. you can download coverage data from the ci workflow runs. |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot add a job in cgo.yml and cjs.yml to run these targets. Make sure the coverage artifacts comes from a workflow run in main branch. |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Implemented in 47bc2cf (with follow-up polish in b5091ed). |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Implemented in c101ed5. I added |
|
🧪 Test Quality Sentinel completed test quality analysis. No test files were added or modified in this PR. The PR only modifies .github/workflows/cgo.yml, .github/workflows/ci.yml, .github/workflows/cjs.yml, and Makefile — none of which are Go (_test.go) or JavaScript (.test.cjs, *.test.js) test files. Test Quality Sentinel skipped. |
|
✅ Design Decision Gate 🏗️ completed the design decision gate check. No ADR enforcement needed: PR #37952 does not have the 'implementation' label and has 0 new lines of code in default business logic directories (≤100 threshold). The changed files are shell/python scripts under .github/skills and .github/workflows, which are outside the monitored business-logic paths. |
|
|
|
🧠 Matt Pocock Skills Reviewer failed during the skills-based review. |
There was a problem hiding this comment.
Pull request overview
This PR introduces “impacted unit test” Makefile targets that run a minimal subset of unit tests based on files changed on the current branch, and wires those targets into the CGO (Go) and CJS (JavaScript) workflows. It also adds CI support for uploading integration coverage artifacts so Go impacted-test selection can optionally correlate changes with CI coverage data.
Changes:
- Adds
test-impacted-js,test-impacted-go, andtest-impactedMakefile targets withBASE_REF-based change detection. - Uploads integration coverage + matching
go test -jsonresults as CI artifacts for downstream correlation. - Adds new workflow jobs to run impacted JS tests in
cjs.ymland impacted Go tests incgo.yml.
Show a summary per file
| File | Description |
|---|---|
| Makefile | Adds impacted-test targets for JS and Go, plus CI coverage correlation logic for Go. |
| .github/workflows/cjs.yml | Adds an impacted-js-tests job invoking make test-impacted-js with full git history. |
| .github/workflows/ci.yml | Uploads integration coverage artifacts (coverage-integration-*.out + matching test-result-integration-*.json). |
| .github/workflows/cgo.yml | Adds an impacted-go-tests job invoking make test-impacted-go with full git history. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 4/4 changed files
- Comments generated: 5
| exit 0; \ | ||
| fi; \ | ||
| echo "Running impacted JavaScript unit tests for changed files: $$CHANGED_JS_FILES"; \ | ||
| cd actions/setup/js && printf '%s\n' "$$CHANGED_JS_FILES" | sed 's|^actions/setup/js/||' | tr '\n' '\0' | xargs -0 -r npm run test:js -- --no-file-parallelism --related $(JS_IMPACTED_TEST_EXCLUDES) |
| COVERAGE_SOURCE_BRANCH="$(CI_COVERAGE_SOURCE_BRANCH)"; \ | ||
| RUN_ID="$(CI_RUN_ID)"; \ | ||
| if [ -z "$$RUN_ID" ]; then \ | ||
| RUN_ID=$$(gh run list --workflow "$(CI_WORKFLOW_FILE)" --branch "$$COVERAGE_SOURCE_BRANCH" --status success --limit 1 --json databaseId --jq '.[0].databaseId' 2>/dev/null || true); \ |
| if [ -n "$$COVERAGE_GO_PACKAGES" ]; then \ | ||
| CHANGED_GO_PACKAGES="$$COVERAGE_GO_PACKAGES"; \ | ||
| echo "Running impacted Go unit tests from CI coverage correlation: $$CHANGED_GO_PACKAGES"; \ | ||
| else \ | ||
| CHANGED_GO_PACKAGES=$$(printf '%s\n' "$$CHANGED_GO_FILES" | while IFS= read -r file; do dirname "$$file"; done | sort -u | sed 's|^|./|'); \ | ||
| echo "Running impacted Go unit tests in changed-file packages: $$CHANGED_GO_PACKAGES"; \ | ||
| fi; \ |
| echo "Running impacted Go unit tests in changed-file packages: $$CHANGED_GO_PACKAGES"; \ | ||
| 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 |
| permissions: | ||
| contents: read | ||
| concurrency: |
This PR adds branch-aware Makefile targets to run only unit tests affected by current-branch changes, with separate paths for JavaScript and Go plus a combined entrypoint. Integration tests are explicitly excluded so PR checks can run a minimal relevant subset.
Target surface
test-impacted-js,test-impacted-go, andtest-impacted.BASE_REF ?= origin/mainas the default comparison base.Changed-file detection
BASE_COMMITviagit merge-base $(BASE_REF) HEAD.BASE_COMMIT..HEADto detect changed files in each language path.JavaScript impacted unit tests
actions/setup/js.npm run test:js -- --related ...against changed JS/TS files.*.integration.test.cjs).Go impacted unit tests
.gofiles and correlates them with CI coverage data when available.ci.ymlruns onmainby default (or explicitCI_RUN_ID) and maps matched coverage to impacted Go packages via test result JSON.go test -shortto keep execution in unit-test scope.CI_COVERAGE_SOURCE_BRANCH ?= mainto make the coverage-source branch explicit and configurable.CI coverage artifact support
ci-integration-coverage-*naming.coverage-integration-*.outand matchingtest-result-integration-*.jsonto support local impacted-test correlation.Workflow integration
impacted-go-testsjob incgo.ymlto runmake test-impacted-go.impacted-js-testsjob incjs.ymlto runmake test-impacted-js.Discoverability
make helpwith the new impacted-test targets.