(filePath string, timeout time.Duration)
| 372 | } |
| 373 | |
| 374 | func validateFileWithTimeout(filePath string, timeout time.Duration) error { |
| 375 | type result struct { |
| 376 | err error |
| 377 | } |
| 378 | ch := make(chan result, 1) |
| 379 | |
| 380 | go func() { |
| 381 | data, err := os.ReadFile(filepath.Clean(filePath)) |
| 382 | if err != nil { |
| 383 | ch <- result{err: fmt.Errorf("cannot read file: %w", err)} |
| 384 | return |
| 385 | } |
| 386 | ch <- result{err: parser.ValidateBytes(data)} |
| 387 | }() |
| 388 | |
| 389 | select { |
| 390 | case r := <-ch: |
| 391 | return r.err |
| 392 | case <-time.After(timeout): |
| 393 | return fmt.Errorf("timeout after %v", timeout) |
| 394 | } |
| 395 | } |
| 396 | |
| 397 | func writeStepSummary(path string, total, valid, valErrors, lintErrors, lintWarnings int) { |
| 398 | f, err := os.OpenFile(filepath.Clean(path), os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0o600) |
no test coverage detected