What’s my best option for detecting changes to tar...
# general
h
What’s my best option for detecting changes to target versions in BUILD files that is general to target type?
Bump
w
Can you give an example of this? I'm not precisely sure what you mean.
h
For instance, I might want to trigger releases of packages via CI when their target version is bumped e.g. the
version
property of a
python_distribution
target. I could do a
pants peek
of two compared commits and query the property myself to detect this - but I was wondering if there’s anything more functional I could achieve via pants.
w
I can't say if there is anything else that's intended for the purpose, as for that type of thing, I always use
peek
- reason being, whenever I've needed to do that, there's always more than just the version (or single field) that I'm interested in. I'm assuming the vcs_version isn't of interest, as that's more git-specific
You could also filter on them, to speed up peek. https://www.pantsbuild.org/stable/docs/using-pants/advanced-target-selection#--spec-files But in general, I almost always do something like this: https://www.pantsbuild.org/stable/docs/using-pants/advanced-target-selection#piping-to-other-pants-runs So yeah, filtering by target types, or specifying them explicitly, and/or peek - that's how I would do it. There might be a more "native" way to do it, just none that I know of off the top of my head. Maybe a macro or plugin could work, but that feels like overkill compared to a pipe. I could imagine something that tells you that certain targets have changed their definition - but I'd assume you'd still only want that on version changes...
h
I thought that might be the most appropriate option at the mo, I have quite a few scripts that make use of piping pants commands together and jq’ing
pants peek
output which works very well. What I’d be looking is essentially extended functionality on top of
--changed-since
so additionally to mapping git diff onto the target dependency graph, we could map it onto the properties of targets themselves.
w
That's an interesting idea. Maybe ticket it, if it doesnt exist? Someone else might be able to chime in if they do it similarly
h
I’ll do that! I would like to contribute features like this myself, but haven’t quite got to grips with the pants internal code just yet.
w
👍 Who knows, maybe something like this exists already - there's a loooot of stuff in Pants
h
Definitely, it would be great if an “awesome-pants” type repo existed for showing off some advanced possible features.
w
I'm hoping to do that in the docs - where we have a grab-bag of just random ideas
h
It’s definitely useful in its own way, sometimes improving your understanding comes from just being able to see what’s possible and building on it
w
h
Similar but not exactly the same. Worth opening a separate issue do you think?
w
Or tacking on that issue - it sounded like a generalized version of what you were suggesting
h
I guess that’s a question of what the internal implementation would look like. • “Hey you are about to deploy X, this is what changed since the last deploy” ^ To me is being able to gather commits containing “changed” targets, with the ability to use Pants’ existing query options to filter them. Whereas what I’m proposing, is for the properties of targets to also be subject to these queries, but namely the
--changed-since
filter. I’ll open a separate issue for now but will be happy if it’s closed off as duplicate. 🙂 Thanks for your help.
w
👍