Forji/integration/forgejo-seed/Sources/SeedError.swift
Stefan Hausotte 2a679140e6 test: stream seed progress and add a docker exec timeout (#69)
The integration seeder gave no visible progress and could hang
indefinitely. A `docker compose exec` for the admin-user step wedged on
a transient Docker-on-macOS flake, and `DockerExec.run` waited on it
with no timeout, blocking the whole UI test suite forever with no output
(stdout was block-buffered, so the existing phase prints never flushed).

- Line-buffer the seeder's stdout so phase progress streams live instead
  of being dumped all at once when stdout is a pipe.
- Add numbered "[n/7] <phase> (Ns elapsed)" headers for a clear progress
  and timing signal.
- Add a 60s timeout to `docker compose exec` and retry the admin-user
  step, so a hung exec fails fast and recovers instead of wedging the
  suite.

Reviewed-on: https://codeberg.org/secana/Forji/pulls/69
2026-06-09 12:55:45 +02:00

21 lines
840 B
Swift

import Foundation
enum SeedError: LocalizedError {
case missingArguments
case dockerExecFailed(command: String, exitCode: Int32, stderr: String)
case dockerExecTimedOut(command: String, seconds: TimeInterval)
case retryExhausted(operation: String, attempts: Int)
var errorDescription: String? {
switch self {
case .missingArguments:
"Usage: forgejo-seed <base-url> <service-name> [compose-file]"
case let .dockerExecFailed(command, exitCode, stderr):
"Docker exec failed (\(exitCode)): \(command)\n\(stderr)"
case let .dockerExecTimedOut(command, seconds):
"Docker exec timed out after \(Int(seconds))s: \(command)"
case let .retryExhausted(operation, attempts):
"\(operation) failed after \(attempts) attempts"
}
}
}