Forji/integration/forgejo-seed/Sources/Main.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

34 lines
964 B
Swift

import Foundation
@main
struct ForgejeSeed {
static func main() async throws {
// Line-buffer stdout so seed progress streams live instead of being held in a
// block buffer (and dumped all at once) when stdout is a pipe rather than a TTY.
setvbuf(stdout, nil, _IOLBF, 0)
let args = CommandLine.arguments
guard args.count >= 3 else {
throw SeedError.missingArguments
}
let baseURL = args[1]
let serviceName = args[2]
// Compose file path: passed as 3rd arg, or derived from cwd
let composeFile: String = if args.count >= 4 {
args[3]
} else {
FileManager.default.currentDirectoryPath
+ "/integration/docker-compose.yml"
}
let seeder = Seeder(
baseURL: baseURL,
serviceName: serviceName,
composeFile: composeFile,
)
try await seeder.seed()
}
}