target-determinator
target-determinator copied to clipboard
CLI support base commit hash file as an input
We are considering trying out target-determinator in Diff CI, but we have some performance constraints.
Can we add CLI that supports taking in an already computed hash file from master to avoid git checkout base commit and perform a cquery on the base commit for comparison? This is a feature in https://github.com/Tinder/bazel-diff#get-impacted-targets-command
With this feature, we can compute hash file in master CI and reuse the result in diff CI and save us seconds to minutes.
Thanks for filing this issue! I think this makes a lot of sense - definitely being able to cache these values across runs is very sensible.
Would you be interested in trying to put together a PR to implement this? The key pieces of code to affect would be:
- The entry-point here should optionally take a path to a hash file instead of a
RevisionBefore
- I'd probably introduce a new structHashFileOrRevision
which has either aHashFile
orRevision
set, and populate that onconfig
. - This calls into
WalkAffectedTargets
- accept aHashFileOrRevision
forcommitishBefore
and pass it through toFullyProcess
. - In
FullyProcess
, populatequeryInfoBefore
by optionally deserializing JSON instead of callingfullyProcessRevision
.
As far as I know, everything in QueryResults
should be trivially JSON serializable (I think we'd need to add a Marshall implementation to MatchingTargets
, but it's just a wrapper around a slice, so should be trivial).
We may want to nil-out any instances of analysis.ConfiguredTarget
because they're probably very large and not useful other than for explaining why something changed. In fact, maybe all we want is to serialize MatchingTargets
and TargetHashCache.cache
, which maybe calls for its own struct purpose made for serialization/deserialization? We may also want to add some schema version number or similar but we can probably worry about that kind of thing in the future.