pantsbuild / pants

The Pants Build System
https://www.pantsbuild.org
Apache License 2.0
3.32k stars 636 forks source link

Expose the hash of a given target #8445

Open ns-cweber opened 5 years ago

ns-cweber commented 5 years ago

This has come up several times for our team, but it would be nice to have access to the hash of a given target. Most recently, we're building PEX files with pants and then dropping them into Docker Images--we'd like to tag the Docker Image with the hash of the PEX's inputs so our deploy pipeline will see that the image tags are the same and not trigger a redeploy.

We could hash the PEX file, but then we're at the mercy of pants to produce exactly (bit for bit) the same PEX file with each build. Admittedly, a shared cache probably makes this mostly an academic concern.

I'm not familiar with pants internals, but ideally this would be agnostic to the type of target--the same use case could easily apply to Node or Go images as for Python.

cosmicexplorer commented 5 years ago

This is actually something that would be immediately useful for IDE support in Metals too (from scalameta/metals#935), and it would almost definitely be generically useful in the way you describe.

kaos commented 8 months ago

N.b. for those coming here, tagging images built with the docker_image target, there is a pants.hash value for the images inputs: https://www.pantsbuild.org/2.19/docs/docker/tagging-docker-images#string-interpolation-using-placeholder-values