fix: improve pnpm hash extraction + log oracle build output on failure

This commit is contained in:
joshp123 2026-02-14 18:44:29 -08:00
parent 8911e699d8
commit 2674adf777
2 changed files with 12 additions and 1 deletions

View File

@ -200,7 +200,15 @@ func updateOracle(repoRoot string) error {
logText, buildErr := internal.NixBuildOracle()
pnpmHash := internal.ExtractGotHash(logText)
if pnpmHash == "" {
// Restore original file so we don't leave a broken placeholder hash behind.
_ = os.WriteFile(oracleFile, orig, 0644)
// Surface some context in CI logs. This is usually a hash-mismatch line we failed to parse.
lines := strings.Split(logText, "\n")
start := 0
if len(lines) > 200 {
start = len(lines) - 200
}
log.Printf("[update-tools] oracle build output (last %d lines):\n%s", len(lines)-start, strings.Join(lines[start:], "\n"))
return fmt.Errorf("oracle pnpm hash not found (build err: %v)", buildErr)
}
if err := internal.ReplaceOnceFunc(oracleFile, pnpmRe, func(s string) string {

View File

@ -88,7 +88,10 @@ func NixBuildSummarizeSystem(system string) (string, error) {
}
func ExtractGotHash(log string) string {
re := regexp.MustCompile(`got:\s*(sha256-[A-Za-z0-9+/=]+)`)
// Nix typically prints something like:
// got: sha256-....
// but sometimes wraps/indents. Keep this forgiving.
re := regexp.MustCompile(`(?i)got:\s*"?(sha256-[A-Za-z0-9+/=]+)"?`)
for _, line := range strings.Split(log, "\n") {
match := re.FindStringSubmatch(line)
if len(match) > 1 {