Hey all :wave:, I've a question about how Pant's c...
# general
s
Hey all 👋, I've a question about how Pant's can help our CI pipeline... Given Pants knows that: project-c depends on library-b that depends on library-a and project-d also relies on library-a Is there anything I need to do to help my CI tool (TeamCity) use Pants to know that if library-a changes it only needs to retest and rebuild library-b, project-c&d? OR is all this done with Pants' caching?
👋 1
c
We have come up with some useful commands to accomplish what you are talking about. Most of the pants goals will take the
--changed-since
argument which can be any gitref. So if you are on a PR you might want to run
./pants test --changed-since=origin/main --changed-dependees=transitive
to run all tests that have changes (directly or indirectly) since your main branch.
s
That's ace thank you 🙏
h
So you can just do
./pants test ::
which means "get me test results for everything" and rely on pants caching to skip actually running tests whose inputs haven't changed. But, this is tricky to do in CI because you have to preserve the local cache across runs, and while all CI providers I'm familiar with (I don't know TeamCity) have some mechanism for doing this, it's usually pretty clunky, and it gets slow as the cache grows, so then you have to prune it, and it becomes a whole thing...
Shameless plug: my company, Toolchain, has a remote caching SaaS, currently in beta, that solves that whole problem. If you have that (or similar), you can just do
./pants test ::
and be done with it. Plus, your desktop runs get to share that cache, so those get a lot faster too - when you start work in the morning and pull from main, CI has already populated the cache with results for all those changes...
But absent that, what @clean-city-64472 suggests is very effective as well!
w
and both of these approaches are discussed here: https://www.pantsbuild.org/docs/using-pants-in-ci !