package testci import ( "bytes" "encoding/json" "fmt" "os/exec" "path/filepath" "testing" ) // CopyReleaseCheck is the copy release gate (make copy-release-check) for // the tree at candidate. copy-status.py verify is the one judge of reviewed // copy: pending or required copy, under either marker spelling, or stale // record-bound bookkeeping blocks a release. func CopyReleaseCheck(t testing.TB, candidate string) error { t.Helper() root, err := moduleRoot() if err != nil { return err } scripts := filepath.Join(root, "scripts") Files(t, filepath.Join(scripts, "copy-status.py"), filepath.Join(scripts, "copy-contract.py")) Tools(t, "python3") input, err := json.Marshal(map[string]string{"candidate": candidate}) if err != nil { return err } cmd := exec.Command("python3", filepath.Join(scripts, "copy-status.py"), "verify") cmd.Stdin = bytes.NewReader(input) out, err := cmd.Output() if err != nil { return fmt.Errorf("copy-status.py verify: %w %s", err, out) } var result struct { Valid bool `json:"valid"` } if err := json.Unmarshal(out, &result); err != nil { return fmt.Errorf("copy-status.py verify: %w %s", err, out) } if !result.Valid { return fmt.Errorf("COPY REVIEW REQUIRED: copy-status.py verify found copy pending review or stale bookkeeping") } return nil }