chore: sync generated file immediately (#4538)

A CI failure was observed where a generated file was only partly written
when the CI job immediately tried to read it. Put in an fs.Sync call to
eliminate this flakiness.

Signed-off-by: Will Murphy <willmurphyscode@users.noreply.github.com>
This commit is contained in:
Will Murphy 2026-01-08 09:01:17 -05:00 committed by GitHub
parent 11e871566b
commit 83a4528fff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -31,6 +31,13 @@ func writeYAMLToFile(path string, rootNode *yaml.Node) error {
return fmt.Errorf("failed to close encoder: %w", err) return fmt.Errorf("failed to close encoder: %w", err)
} }
// Sync to ensure data is flushed to disk before subsequent reads.
// This prevents flaky test failures on tmpfs where file contents
// may not be immediately visible after Close() returns.
if err := f.Sync(); err != nil {
return fmt.Errorf("failed to sync file: %w", err)
}
return nil return nil
} }