disneystreaming / smithy4s

https://disneystreaming.github.io/smithy4s/
Other
351 stars 71 forks source link

Log the args diff when re-running the smithy4s codegen #1559

Closed majk-p closed 5 months ago

majk-p commented 5 months ago

This PR introduces a change in Smithy4s sbt codegen plugin that would allow users to see what caused the codegen to re-execute. It is done by replacing sbt.util.Tracked.inputChanged with a similar implementation that keeps the entire codegen args serialized in cache, and when codegen needs to be rerun, plugin will print the diff of the values to debug log. The diff is calculated using munit-diff.

When running sbt with set logLevel := Level.Debug, user will notice a diff like this when codegen needs to rerun:

obraz

PR Checklist (not all items are relevant to all PRs)

Baccata commented 5 months ago

out of curiosity, what's the motivation for this change ?

majk-p commented 5 months ago

out of curiosity, what's the motivation for this change ?

With the extensive use of smithy4s at $work, both my coworkers and myself we have noticed unexpected re-compilation of smithy sources. I'm not sure what caused it yet, I had no luck reproducing it with small projects, but it seems to happen in more complex sbt setups.

A way to debug when and what exactly triggers smithy4s code generation would be a very helpful tool to proceed with the investigation.