r/Python • • Jun 25 '26

Discussion Monorepo, testing and deployment

Hi

I'm currently working on a codebase that has become a little annoying to deal with when updating dependecies as so on. The choices were made before I started working here, so I cant really comment on the why they choose to do it this way.

We haveabout 12 microservices now. And some of the pipelines for the microservices build clients from the openapi specs, that again are used in other services. Also more or less all the services rely on a utility package containing models for configs, Enums, utility packages for authentication, and more. Which has worked fine until now.

But now we have cases like this, I do changes in services A, a new client is built and pushed to feed, and service A is tested and it works like intended. However a few days later, I need to do work on service B, that also needs to up Service client As version. This change in client breaks service B, and I have to go back to change Service A to build a new client that works with service B. And the same applies to the utils that most of the service rely on.

I'm trying to find a setup where I can test this fully before its deployed to the test enviorment. Not a big deal to catch this in the test enviorment I know, but in some cases a defect like this makes it through undetected into production.

The developer that made 99% of the choice for this setup is vehemntly opposed to testing, and the entire codebase lacks any form tests. All my colleagues who write python are in data, and this scenario doesnt really apply to them, so not much help to get there.

For another part of my job, I work in an angular monorepo, where we have established testing to catch a lot of this in pipelines and automated testing.

I'm just curious what are common practicies in cases like this. For me right now, it looks like we could catch most of this in test pipelines, but its going to be a fair bit of work. Does anyone work in similar setup? Is there any tool commonly used for bigger codebases in python?

0 Upvotes

11 comments sorted by

View all comments

1

u/EdwardAF-IT Jul 17 '26

A lot of good suggestions here (contract tests, affected-only CI, versioned clients) share one assumption: that tests exist to run. With a testing-hostile codebase owner, I'd solve that problem first, and there's a specific kind of test that's much easier to land politically: characterization tests.

Instead of arguing about what the code should do, you write tests that pin what it currently does — right or wrong, no judgment. You're not fixing anyone's design or implying it's broken; you're recording today's behavior so tomorrow's change can't silently alter it. I've used this to make changes in legacy services safely, and it maps exactly onto your service A / service B case: if a regenerated client changes behavior a consumer depends on, something goes red before it ships instead of three days later in someone else's pipeline. (This is also the one place I've found AI code assistants genuinely uncontroversial — generating the tedious pin-current-behavior tests is exactly the grunt work they're good at, and you review the assertions rather than write them all.)

The second thing I'd change is the direction of the check. Right now service A publishes a client and finds out later whether it broke anyone. Flip it: when A regenerates its client, CI runs the consumers' tests against the new client before it hits the feed. The producer discovers the breaking change, not whoever happens to bump the version next week. Pact-style contract tests (already mentioned in the thread) are the formal version of this; a homegrown "run downstream suites against the candidate client" job gets you most of the value sooner.

On the "fair bit of work" worry — it's less than it looks if you only cover the shared seams first. The utils package and each generated client get tests; service internals can wait. Your incidents are all coming from the shared stuff anyway.