Skip to content

Commit

Permalink
Explicitely disable cache for SwiftLintPlugin runs on Xcode Cloud (#5287
Browse files Browse the repository at this point in the history
)

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.
  • Loading branch information
Slava Karpenko authored Nov 5, 2023
1 parent e746033 commit 91c0240
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Plugins/SwiftLintPlugin/SwiftLintPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 91c0240

Please sign in to comment.