Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved Logging/Error Handling during SwiftTemplate Processing #1320

Merged
merged 3 commits into from
Mar 30, 2024

Conversation

art-divin
Copy link
Collaborator

Context

This PR addresses the fact that when executing Sourcery from multiple processes (i.e. running sourcery executable from other scripts), mock generation fails if cacheBasePath is the same between these concurrent processes.
In actuality, the only reason the swifttemplate processing fails is because one process is trying to cache SwiftTemplate binary in parallel with another process doing the same for the same SwiftTemplate, i.e. when cacheKey is exactly the same between these executables.

Description

This PR does the following:

  • Adds more logs for time measurement in SwiftTemplate
  • Adds a note how exactly cacheKey is calculated and its intended usage
  • Adds possibility to pass Log configuration when using SourceryLib instead of executable for logging setup

Added more logs for time measurement in SwiftTemplate; added a note how exactly cacheKey is calculated and it's intended usage; added possibility to pass Log configuration when using SourceryLib instead of executable for logging setup.
@art-divin art-divin self-assigned this Mar 30, 2024
do {
try build().move(binaryPath)
} catch let error as NSError {
if error.domain == "NSCocoaErrorDomain", error.code == 516 {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what now allows to execute Sourcery from multiple processes in parallel, generating code into different directories when swifttemplate is shared across these executions (i.e. cached and reused).

@art-divin art-divin changed the title Improved Logging for SwiftTemplate Processing Improved Logging/Error Handling during SwiftTemplate Processing Mar 30, 2024
@art-divin art-divin merged commit 53c1f8f into master Mar 30, 2024
2 checks passed
@art-divin art-divin deleted the swifttemplate-compilation-concurrency-support branch March 30, 2024 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant