Merge remote-tracking branch 'origin/main' into fix/canonical-agent-skills

This commit is contained in:
玉澜
2026-08-17 12:30:34 +08:00
29 changed files with 1104 additions and 162 deletions
+21 -15
View File
@@ -1157,7 +1157,7 @@ func TestChangelogPRFastPathWorkflowContract(t *testing.T) {
`test "$(git rev-parse HEAD^1)" = "$PR_BASE_SHA"`,
`test "$(git rev-parse HEAD^2)" = "$PR_HEAD_SHA"`,
`echo "TEST_HEAD_REF=$(git rev-parse HEAD)"`,
`list-shard "$TEST_SHARD" "$TEST_BASE_REF" "$TEST_HEAD_REF"`,
`list-shard "$package_shard" "$TEST_BASE_REF" "$TEST_HEAD_REF"`,
"needs.lint.outputs.full_suite != 'true'",
`name: "Test (race: ${{ matrix.shard }})"`,
"name: Test (workflow and release contracts)",
@@ -1219,16 +1219,20 @@ func TestChangelogPRFastPathWorkflowContract(t *testing.T) {
}
// The focused path fans the impacted set across the same shards as test-race
// and runs each shard the way test-race runs it, so no single job carries
// internal/app together with its reverse dependencies. internal/app keeps its
// package-level headroom through the process-isolating helper instead of one
// long -timeout, which is strictly stronger: every process releases the
// framework registries it populated. release-scripts is asserted because its
// dedicated job only runs at full-suite or release-sensitive scope, so losing
// it here would silently stop testing test/scripts changes.
// internal/app together with its reverse dependencies. internal/app is split
// further into one shard per bounded partition, which keeps its package-level
// headroom through the process-isolating helper instead of one long -timeout
// and is strictly stronger than a single app job: every partition process
// releases the framework registries it populated, and the partitions run
// concurrently rather than end to end. Each partition shard still selects the
// same single internal/app package, so the impacted-package query maps the
// shard name back to app. release-scripts is asserted because its dedicated
// job only runs at full-suite or release-sensitive scope, so losing it here
// would silently stop testing test/scripts changes.
for _, want := range []string{
`if [ "$TEST_SHARD" = "app" ]; then`,
`app-*) package_shard=app ;;`,
`test "${#packages[@]}" -eq 1`,
`./scripts/ci/run-app-race-tests.sh run "${packages[0]}"`,
`./scripts/ci/run-app-race-tests.sh run "${packages[0]}" "${TEST_SHARD#app-}"`,
`if [ "$TEST_SHARD" = "release-scripts" ]; then`,
`go test -v -count=1 -timeout=10m "${packages[@]}"`,
"timeout_budget=12m",
@@ -1249,14 +1253,16 @@ func TestChangelogPRFastPathWorkflowContract(t *testing.T) {
t.Fatal("Code Admission workflow missing race test job boundaries")
}
raceJob := admission[raceStart:raceEnd]
// The app shard uses independently bounded test processes so process-global
// command registries are released before the Schema assembly peak. Other full
// race shards retain the dynamic package timeout: default/floor 12m, with
// cli/smoke raised to 15m on slower hosted runners.
// internal/app is carried by one shard per bounded partition, so process-global
// command registries are released with each partition process and the Schema
// assembly peak no longer sits in front of the other partitions. Each
// partition shard resolves back to the same single internal/app package.
// Other full race shards retain the dynamic package timeout: default/floor
// 12m, with cli/smoke raised to 15m on slower hosted runners.
for _, want := range []string{
`if [ "$TEST_SHARD" = "app" ]; then`,
`app-*) package_shard=app ;;`,
`test "${#packages[@]}" -eq 1`,
`./scripts/ci/run-app-race-tests.sh run "${packages[0]}"`,
`./scripts/ci/run-app-race-tests.sh run "${packages[0]}" "${TEST_SHARD#app-}"`,
"timeout_budget=12m",
`if [ "$TEST_SHARD" = "cli" ] ||`,
`[ "$TEST_SHARD" = "smoke" ]; then`,
+68
View File
@@ -99,6 +99,74 @@ func TestCIAppRacePartitionsCoverTopLevelTestsExactlyOnce(t *testing.T) {
}
}
// TestCIAppRacePartitionMatrixMatchesHelper pins the workflow's app partition
// shards to the partition set the helper actually runs. The partitions are
// separate CI jobs now, so the helper's own "covered exactly once" check can no
// longer prove the whole package ran: a partition the helper knows about but no
// matrix shard dispatches would silently stop running while every job stays
// green. Both directions are asserted so a stale matrix shard fails too.
func TestCIAppRacePartitionMatrixMatchesHelper(t *testing.T) {
root := testPackagePlanRoot(t)
script := filepath.Join(root, "scripts", "ci", "run-app-race-tests.sh")
cmd := exec.Command("sh", script, "list-partitions")
cmd.Dir = root
output, err := cmd.CombinedOutput()
if err != nil {
t.Fatalf("%s list-partitions failed: %v\n%s", script, err, output)
}
partitions := strings.Fields(string(output))
if len(partitions) == 0 {
t.Fatalf("list-partitions returned no partitions: %q", output)
}
workflow, err := os.ReadFile(filepath.Join(root, ".github", "workflows", "ci.yml"))
if err != nil {
t.Fatalf("read ci.yml: %v", err)
}
admission := string(workflow)
for _, job := range []struct {
name string
startMark string
endMark string
}{
{"test-focused", "\n test-focused:\n", "\n test-race:\n"},
{"test-race", "\n test-race:\n", "\n test-release-scripts:\n"},
} {
start := strings.Index(admission, job.startMark)
end := strings.Index(admission, job.endMark)
if start < 0 || end <= start {
t.Fatalf("ci.yml is missing %s job boundaries", job.name)
}
body := admission[start:end]
for _, partition := range partitions {
want := "- app-" + partition
if !strings.Contains(body, want) {
t.Errorf("%s matrix is missing shard %q for a partition the helper runs", job.name, want)
}
}
for _, line := range strings.Split(body, "\n") {
shard := strings.TrimSpace(line)
if !strings.HasPrefix(shard, "- app-") {
continue
}
name := strings.TrimPrefix(shard, "- app-")
matched := false
for _, partition := range partitions {
if partition == name {
matched = true
break
}
}
if !matched {
t.Errorf("%s matrix shard %q has no matching helper partition", job.name, shard)
}
}
}
}
func TestCITestPackagePlanFailsClosedWhenGoListFails(t *testing.T) {
root := testPackagePlanRoot(t)
fakeBin := t.TempDir()