Open markst opened 3 months ago
This repeatedly occurs when attempting to build using Bitrise continuous integration platform
We're currently using Sourcery 2.2.2.
I've attempting passing buildPath
arguments to sourcery using both outputDirectory
and NSTemporaryDirectory()
private func createBuildCommands(
tool: PluginContext.Tool,
configPath: Path,
outputDirectory: Path
) -> [Command] {
let cachePath = outputDirectory.appending(subpath: "SourceryPlugin/Cache")
let buildPath = outputDirectory.appending(subpath: "SourceryPlugin/Build")
return [
.prebuildCommand(
displayName: "Generate mocked types for target",
executable: tool.path,
arguments: [
"--config", configPath,
"--cacheBasePath", cachePath,
"--buildPath", buildPath,
"--disableCache",
"--verbose"
],
environment: ["DERIVED_SOURCES_DIR": outputDirectory],
outputFilesDirectory: outputDirectory
)
I'm now struggling to reproduce locally, the output appears to succeed:
Raw compilation of SwiftTemplate took: 7.120736837387085
as a sidenote, the SwiftTemplate
binary is built each time which leads me to think the executableCacheKey
is changing despite no change in code?
as a sidenote, the
SwiftTemplate
binary is built each time which leads me to think theexecutableCacheKey
is changing despite no change in code?![]()
Hi @markst , aside from other issues you've reported, for which there are billions of thanks ❤️ , SwiftTemplate binary is compiled once (in single threaded mode of running Sourcery), and then re-used. Other components are cached on per-execution basis.
You can verify this by using --verbose
flag when running Sourcery starting 2.2.2 release. It is clearly shown when SwiftTemplate is reused from cache, and when it is re-compiled again due to a different cacheKey.
You can normally resolve this issue using swift package purge-cache
@art-divin possibly it's failing to get the cached build since it's failing to complete the build?
might be worth mentioning if I try to open the generated Package.swift
in xcode it complains:
Hello @markst ,
I wonder, can you try using Sourcery 2.2.1 version?
There is one concurrency issue to be resolved by the end of the upcoming week (next release should be done on the next weekend). Maybe it is related to the issue you are facing, but I suspect it is not. 🕵🏻♂️
Investigating 🕵🏻
We're currently using Sourcery 2.2.2.
I've attempting passing
buildPath
arguments to sourcery using bothoutputDirectory
andNSTemporaryDirectory()
private func createBuildCommands( tool: PluginContext.Tool, configPath: Path, outputDirectory: Path ) -> [Command] { let cachePath = outputDirectory.appending(subpath: "SourceryPlugin/Cache") let buildPath = outputDirectory.appending(subpath: "SourceryPlugin/Build") return [ .prebuildCommand( displayName: "Generate mocked types for target", executable: tool.path, arguments: [ "--config", configPath, "--cacheBasePath", cachePath, "--buildPath", buildPath, "--disableCache", "--verbose" ], environment: ["DERIVED_SOURCES_DIR": outputDirectory], outputFilesDirectory: outputDirectory )
Hello @markst ,
first thing I notice, is that you are using --disableCache
flag. When this flag is set, cacheKey
is ignored and SwiftTemplate is recompiled for every run.
This is not the root cause of your issue, but thing is, --cacheBasePath
is ignored and unused because of the --disableCache
flag.
@markst by the way, the speed with which in the gif you've shared the build is failing, tells me that the compilation of SwiftTemplate fails for one or the other reason. Flag verbose
should expose some details about these processes, would you mind checking the raw log output in Xcode's Report Navigator for this exact build phase - plugin containing sourcery invocation?
That would help a lot 👍🏻
We're using a
XcodeBuildToolPlugin
to generate mocks using Sourcery as mentioned in this issue: https://github.com/krzysztofzablocki/Sourcery/issues/1229This works when running in Xcode, however occasionally when running tests using xcodebuild the following can occur: