https://pantsbuild.org/ logo
#general
Title
# general
s

stale-nightfall-29801

10/22/2021, 8:16 AM
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

clean-city-64472

10/22/2021, 2:57 PM
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

stale-nightfall-29801

10/22/2021, 3:08 PM
That's ace thank you 🙏
h

happy-kitchen-89482

10/22/2021, 3:39 PM
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

witty-crayon-22786

10/22/2021, 4:22 PM
and both of these approaches are discussed here: https://www.pantsbuild.org/docs/using-pants-in-ci !
4 Views