mirror of
https://github.com/realm/SwiftLint.git
synced 2026-05-07 20:12:49 +00:00
Explicitely disable cache for SwiftLintPlugin runs on Xcode Cloud (#5287)
In Xcode Cloud environment, SwiftLint’s cache cannot be written. When using the SwiftLintPlugin, there is no way to disable the cache. Previously, a solution was made for the SwiftLint CLI itself where it looks at a set of environment variables (#4485). This solution offers a cleaner approach where the plugin itself decides whether it needs to enable or disable the cache based on the `CI_XCODE_CLOUD` environment variable. In the long run, SwiftLint should get rid of `isLikelyXcodeCloudEnvironment` entirely. The caller should always decide if caching is possible or not, while SwiftLint itself should be platform-agnostic.
This commit is contained in:
@@ -32,10 +32,17 @@ struct SwiftLintPlugin: BuildToolPlugin {
|
||||
// We always pass all of the Swift source files in the target to the tool,
|
||||
// so we need to ensure that any exclusion rules in the configuration are
|
||||
// respected.
|
||||
"--force-exclude",
|
||||
"--cache-path", "\(workingDirectory)"
|
||||
"--force-exclude"
|
||||
]
|
||||
|
||||
// Determine whether we need to enable cache or not (for Xcode Cloud we don't)
|
||||
if ProcessInfo.processInfo.environment["CI_XCODE_CLOUD"] == "TRUE" {
|
||||
arguments.append("--no-cache")
|
||||
} else {
|
||||
arguments.append("--cache-path")
|
||||
arguments.append("\(workingDirectory)")
|
||||
}
|
||||
|
||||
// Manually look for configuration files, to avoid issues when the plugin does not execute our tool from the
|
||||
// package source directory.
|
||||
if let configuration = packageDirectory.firstConfigurationFileInParentDirectories() {
|
||||
|
||||
Reference in New Issue
Block a user