SwiftPM uses caches heavily to reduce compilation and download time. Before this change, we through these caches away with each container.
40 lines
1.2 KiB
Swift
40 lines
1.2 KiB
Swift
import Foundation
|
|
import Script
|
|
import Noora
|
|
|
|
struct TestCommand: Script {
|
|
static let configuration = CommandConfiguration(
|
|
commandName: "test",
|
|
abstract: "Run swift test in a linux container.",
|
|
aliases: ["t"],
|
|
)
|
|
|
|
@OptionGroup var global: GlobalOptions
|
|
|
|
// MARK: - Run
|
|
|
|
func run() async throws {
|
|
let noora = Noora()
|
|
let logger = global.makeLogger(labeled: "swift-inotify.cli.task.test")
|
|
let currentDirectory = FileManager.default.currentDirectoryPath
|
|
let docker = try await executable(named: "docker")
|
|
|
|
noora.info("Running tests on Linux.")
|
|
logger.debug("Current directory", metadata: ["current-directory": "\(currentDirectory)"])
|
|
do {
|
|
try await docker(
|
|
"run",
|
|
"-v", "\(currentDirectory):/code",
|
|
"-v", "swift-inotify-build-cache:/code/.build",
|
|
"--security-opt", "systempaths=unconfined",
|
|
"--platform", Docker.getLinuxPlatformStringWithHostArchitecture(),
|
|
"-w", "/code", "swift:latest",
|
|
"/bin/bash", "-c", "swift test --skip InotifyLimitTests; swift test --skip-build --filter InotifyLimitTests"
|
|
)
|
|
noora.success("All tests completed successfully.")
|
|
} catch {
|
|
noora.error("Not all tests completed successfully.")
|
|
}
|
|
}
|
|
}
|