On this page
- What is pre-merge verification?
- Pre-merge, post-merge and production checks
- What to run on every pull request
- Why most pull request testing stops at unit tests
- Where pull request testing can run
- Regression testing in CI that keeps up with change volume
- Keeping pre-merge verification fast
- Is it worth testing every pull request?
- What coding agents change for pre-merge verification
- How to adopt pre-merge verification
- Pre-merge verification checklist
- How Signadot runs pre-merge verification
Pre-merge verification is running the checks that prove a change works, including integration and end-to-end suites run against the services it calls, on every pull request before it merges. The main branch then receives changes that were tested in context, not changes waiting for someone to find their bugs in staging.
Most teams already run part of this. Their pull request pipelines build the code, run unit tests and maybe a contract check, then merge, and the tests that need running services happen afterwards in a shared environment. That split made sense when environments were scarce. It doesn’t hold once coding agents multiply the pull requests and iterate against the gate until it turns green, because an agent learns to pass exactly what the gate checks and nothing more.
The work is deciding what to run on every pull request, where it can run without a queue, and how to keep regression testing fast as volume grows. Verifying changes that coding agents wrote is its own topic, covered in the complete guide to verifying AI-generated code.
What is pre-merge verification?
Pre-merge verification means a pull request can’t merge until it has passed checks that show it works in the running system, not only in isolation. The checks are required, they run automatically on every pull request, and their results sit on the pull request where the reviewer and the author see them.
The difference from ordinary CI is the last part of the gate. Most CI pipelines check that code builds and that its logic holds with dependencies replaced by mocks. Pre-merge verification adds the question those checks can’t answer: does the change still behave correctly next to live versions of the services it calls and the services that call it? That question used to be answered after merge, in staging or in production.
Teams also call it pre-merge testing or pull request testing. It is not the same as code review, and it doesn’t replace it. A reviewer judges intent, design and risk. Pre-merge verification gives the reviewer evidence that the change runs, so review time goes to the questions a person is better at.
It is also not a single test suite. It’s a set of checks ordered from cheapest to most expensive, with each one required only where it earns its cost. A copy change and a change to a payment flow shouldn’t wait for the same suite.
What a passing gate should guarantee to the teams who build on main next is a decision in its own right. The four questions a merge answers are laid out in what a green check on a pull request should promise.
Pre-merge, post-merge and production checks
Pre-merge verification covers what a single change can break, post-merge checks cover how changes combine, and production checks cover what only real traffic shows. Each stage answers a different question, so moving checks earlier doesn’t remove the later stages. It changes what they’re for.
Before merge, the unit of testing is one pull request. Its environment holds that change and nothing else, so a failure belongs to its author, who still has the context to fix it. Integration, end-to-end and regression suites belong here, because this is where their failures are cheapest to attribute.
After merge, the unit is a batch. Two pull requests that passed on their own can still conflict once both land. A merge queue or a post-merge smoke suite catches those combinations. With pre-merge verification in place, that stage finds interactions between changes, not every bug from the week.
In production, canary releases, feature flags and monitoring catch what no test environment reproduces: the real traffic mix, real data volume and third-party behavior at scale. Those checks stay. They also work better when fewer defects reach them, because a canary that fails twice a week stops being trusted.
What to run on every pull request
Every pull request runs the checks that need no environment, and every change to a service that other services call also gets integration and end-to-end suites, run in its own environment. Performance and security checks run where the change gives them something to find.
This is how the layers compare.
| Check | What it proves | Needs running services | Require it when |
|---|---|---|---|
| Build, lint, static analysis | The code compiles and matches known rules | No | Every pull request |
| Unit tests | The logic holds with dependencies stubbed | No | Every pull request |
| Contract tests | API and message shapes stay compatible with their consumers | No, with a contract broker | Any change to an API or event schema |
| Integration tests | The change works through real calls to its neighbors | Yes | Any change to a service others call |
| End-to-end tests | User flows still complete across services | Yes | Changes on a flow with an end-to-end suite |
| Performance and security | Latency, load behavior and exposure stay within limits | Yes | Hot paths, authentication, data handling |
The first three rows are cheap and run anywhere. Contract checks sit at the boundary: a tool such as Pact compares the pact the consumer published with the provider’s behavior, without a running copy of the consumer. How consumer-driven and provider-driven contracts compare is covered in the contract testing guide.
The highlighted rows are where pull request testing usually stops short. They need the services the change talks to, running, at versions close to production. Those rows catch the failures that cost the most later: a field a consumer still reads, a retry loop that triples traffic downstream, a query that times out on production-shaped data.
Why most pull request testing stops at unit tests
Pull request pipelines stop at unit tests because integration tests need running dependencies, and for most of the last decade a running copy of the system was too slow and too expensive to give each pull request. The checks that needed one moved to the other side of the merge.
That move was never a design choice. Teams had one or two shared environments, so changes merged once they cleared the cheap checks, and integration testing happened later in staging, where every team’s untested work piled up. Release managers, code freezes and long debugging sessions grew up around that pile.
Here is the difference in where failures surface.
The arrangement shows up in the CI configuration. Pipelines built for one repository and one deployable treat each service in isolation, which is why CI/CD pipelines weren’t built for microservices. Teams that test after merge pay for it in rework and blocked queues, the cost traced in merging to test is killing your microservices velocity.
Mocks were the usual compromise. They let integration-shaped tests run on the CI runner, but a mock encodes what its author believed another service did when they wrote it. That service keeps changing, the mock doesn’t, and the suite stays green until the two meet after merge.
The constraint behind all of this was infrastructure, not testing practice. Once a pull request can get a production-like environment in seconds, the reason to test after merge goes away.
Where pull request testing can run
There are four places to run a pull request’s integration and end-to-end tests: the CI runner with mocks or containers, a shared staging environment, a complete stack for each pull request, or a lightweight ephemeral environment holding only the changed services on a shared cluster. They differ in fidelity, cost and how well they hold up as pull requests multiply.
| Where tests run | Fidelity | Cost and wait | Best fit |
|---|---|---|---|
| CI runner, mocks or containers | Low: dependencies are stand-ins | Cheap, no queue | A handful of services with stable interfaces |
| Shared staging, after merge | High, but mixed with other changes | One at a time, failures hard to attribute | Final checks before release, not per pull request |
| Complete stack per pull request | High, isolated | Grows with services times open pull requests | Small stacks, or teams with budget to spare |
| Lightweight ephemeral environment | High, isolated per change | Only the changed services run, starts in seconds | Many services and many concurrent pull requests |
The last two rows are the two shapes of ephemeral environments: a full copy per change, or only the changed services on shared infrastructure. Both give a pull request its own place to run. How to build each shape on Kubernetes is laid out in the ephemeral environments guide.
Mocks and containers on the CI runner
Running dependencies as mocks or containers on the runner is the cheapest way to get integration-shaped tests into the pipeline. Tools like Testcontainers or a compose file start a database and a few stubbed services next to the code under test.
It works while the system is small. With thirty or more services, nobody can start the full graph on a runner, so the suite stubs most of it, and the stubs drift from the real services. The result is a green pipeline that tells you the change agrees with its mocks.
Shared staging after merge
Shared staging has the highest fidelity of the four, because it runs everything. It also serializes testing: one environment, many changes, and every failure starts with working out whose change caused it.
Used as a pre-merge environment, staging becomes a queue that every pull request waits in. Used after merge, it finds failures days after the author has moved on.
The complete guide to staging environments explains why the queue forms and what replaces it. Staging still has a role as a final release check. It can’t be where each pull request gets verified.
A complete stack for each pull request
A namespace or cluster per pull request gives each change an isolated, complete system. Fidelity is high and nothing queues.
The bill scales with services multiplied by open pull requests, and the start time is the start time of the slowest service in the stack. Each copy also starts drifting from production the moment it’s created. For a ten-service application with a few open pull requests that’s fine. For a hundred services and a team running coding agents, the bill and the wait decide the matter.
A lightweight ephemeral environment per pull request
A lightweight ephemeral environment deploys only the services a pull request changed and sends every other call to the shared stable services already running in the cluster. Each pull request gets a production-like system in which its own code is the only change.
Test requests carry the pull request’s routing key in a header. Services pass the header along through context propagation, often with OpenTelemetry, so a request reaches the pull request’s version of a changed service and the shared version of everything else. Changes that can’t share a database or queue declare their own copy for the life of the environment.
Because only the changed services start, the environment is ready in seconds, and dozens run side by side on one cluster. That is the property that makes pre-merge verification affordable on every pull request rather than on the few that someone flags as risky.
Databases, queues and test data
Integration tests at the pull request need data, and data is where shared environments get fragile. Most changes can share the cluster’s databases when tests create their own records, scoped to a tenant or user the test owns, and clean them up afterwards. That keeps concurrent pull requests out of each other’s way without a database per change.
Some changes can’t share. A schema migration, a destructive test, a seed dataset the test depends on or a new cloud resource needs its own copy for the life of the pull request. The environment should create that copy when it starts and delete it when the pull request closes, for example a database branch from Neon or a logical database on a shared instance.
Message queues follow the same split. A consumer under test should process only the messages its own pull request produced. On a shared broker, that means each message carries the pull request’s routing key and each consumer version takes only its own, so the broker isn’t duplicated per change.
Decide per suite, not per team. The default is shared data with test-owned records, and a dedicated copy is the exception a change asks for.
Regression testing in CI that keeps up with change volume
Regression testing in CI keeps existing behavior intact by running the tests that protect it on every pull request, against the change’s own environment, before merge. The hard part at scale isn’t running regression tests. It’s running the right ones fast, and catching the regressions nobody has a test for yet.
Automated regression testing has three jobs at the pull request: pick the suites that cover what the change can break, run them in parallel against the change’s environment, and flag behavior that changed even where no assertion looks. Each of those gets harder as the number of services and pull requests grows.
Choosing which regression tests run on a pull request
Run the regression suites that cover the services a pull request touched and the services that call them. Running everything on every change stops scaling long before a team reaches a hundred services, and running only the changed service’s own suite misses the consumer that breaks.
The selection can be coarse and still work. Map suites to the services and flows they cover, then let the pull request’s changed paths choose. A change to the orders service runs the orders integration suite and the checkout end-to-end flow that calls it. A copy change in the frontend runs the frontend’s suite and nothing downstream.
Keep a full run on a schedule, nightly or before a release, so a gap in the mapping gets caught within a day instead of never. Treat a regression found only by the full run as a bug in the mapping and fix it. How to layer integration and end-to-end tests across many services is covered in the microservices testing guide.
Catching regressions nobody wrote a test for
Compare the pull request version’s responses with the stable version’s, for the same requests, and flag what changed. Assertions only catch what someone thought to assert. A comparison catches a renamed field, a changed type or a new status code that no test checks.
The difficulty is noise. Timestamps, IDs and ordering differ between any two runs, so a raw diff flags everything and gets ignored. Signadot’s SmartTests handle this with Smart Diff, which captures the requests and responses between services and scores each difference for relevance, red, yellow or green, so a removed field stands out from a new request ID.
Performance and security regressions
Performance and security regressions need the running change too, and both can run against a single pull request’s environment. A slower query returns correct results, so functional tests pass while latency doubles.
Grafana k6 can load test the pull request’s version and the stable version under the same load, and fail the check when a latency threshold slips. A dynamic scan with ZAP against one change’s environment finds an injection flaw before merge instead of in a weekly scan of staging. Both cost more than a functional suite, so require them on the paths where they find something.
Keeping pre-merge verification fast
Pre-merge verification has to finish in minutes, or people and agents route around it. Set a time budget for the whole gate, then design the order and parallelism to fit inside it.
Order the checks so the cheap ones fail first. A lint error should never wait for an end-to-end suite. Run the environment-dependent suites in parallel once the change’s environment is up, and run them close to the services they call.
Running test pods inside the cluster removes the network hop between a CI runner and the services, and pre-warmed runners remove the start-up wait. Earnest ran its end-to-end suites in parallel against per-change environments and cut test cycles from 30 to 60 minutes down to 10.
Speed also depends on trust. A required check that fails at random teaches everyone to press rerun, and a rerun habit turns a gate into a delay. At Atlassian, flaky tests were responsible for as much as 21% of master build failures in the Jira Frontend repository, and the reruns they forced waste over 150,000 hours of developer time each year (Atlassian). Integration suites are more exposed than unit tests, because shared state and timing play a bigger part.
Quarantine flaky tests out of the required set until they’re fixed, and track the rate. Detection, quarantine and the common root causes are covered in how to fix flaky tests.
Is it worth testing every pull request?
Yes, for any pull request that changes a service other services call. Pre-merge verification costs an environment and a few minutes of test time per pull request. Finding the same failure after merge costs a shared environment’s worth of blocked engineers, a hunt through every change merged since the last green run, and a revert.
The objection is usually about cost at scale, and it’s a fair one for the full-copy shape. Spinning up every service for every pull request is expensive, and teams that tried it often fell back to testing only flagged changes. That fallback recreates the original problem, because the change nobody flagged is the one that breaks staging.
The cost argument changes when the environment holds only the changed services. The per-pull-request cost is then the changed services plus the test run, which is small enough to stop rationing. Levo runs its end-to-end suite in a per-change environment ahead of each merge and reports fewer rollbacks, because developers find and fix their own issues before others build on them.
Two kinds of change don’t need the full gate. Documentation and configuration with no runtime effect can stop after the cheap checks. Experimental branches that will never merge don’t need it either. Everything else does, and the gate should decide which category a change falls in from the paths it touches, not from the author’s opinion of their own change.
What coding agents change for pre-merge verification
Coding agents treat the pre-merge gate as the definition of done. They push, read the result and push again until the required checks pass, which raises CI load and makes the gate’s coverage the limit on what the agent verifies.
The gate becomes the agent’s objective
An agent working on a pull request doesn’t stop at “looks right”. It stops when the required checks go green. That makes the gate’s coverage the agent’s coverage: a pipeline that runs only unit tests teaches the agent to satisfy unit tests, and the integration failure it can’t see ships with a green check beside it.
The loop also multiplies runs. Every failed check is another push, and every push is another pipeline. GitHub reports that Actions ran a job 1,440 times every second in 2026, 124 million times a day and more than three times the previous year’s total (GitHub Octoverse 2026). A gate whose environment-dependent checks take an hour, or wait for a shared environment, can’t absorb that.
Both effects point the same way. Pre-merge verification for agent-written changes needs integration and end-to-end checks in the required set, in an environment that starts fast enough to run on every push.
What agents make easier
Agents also remove the oldest reason regression suites rot: nobody had time to write and maintain them. An agent that changes a behavior can update the integration test that covers it in the same pull request, and keep end-to-end flows current as the interface moves. Review those test changes as carefully as the code, because a test the agent edited to pass proves nothing.
The bigger change is where verification happens. An agent with access to an ephemeral environment can run the same suites before it opens the pull request, read the failures and fix them in its own loop. Claude Code, Codex and Cursor can do this through a CLI or MCP server.
Why that feedback matters more than model choice is argued in agent loops have a feedback problem, not a token problem. The pre-merge gate then confirms what the agent already checked, which is cheaper than finding out at the gate.
How to adopt pre-merge verification
Start with one service whose changes break staging most often, make its integration suite a required check against each pull request’s environment, and widen from there. A narrow, trusted gate does more than a broad one people bypass.
Rolling it out one service at a time
- Pick the first service. Choose one with frequent changes, callers in other teams and an existing integration or end-to-end suite. The suite matters more than the service.
- Give its pull requests an environment. Create one from CI on every pull request and delete it when the pull request closes.
- Run the existing suite there. Point the suite at the environment and post results on the pull request. Don’t rewrite tests yet.
- Make it required. Turn the check into a required status check once it has run clean for a couple of weeks and flaky tests are quarantined.
- Add the consumers. Run the suites of the services that call the first one, selected by changed paths.
- Widen by service. Repeat for the next team, and keep a nightly full run as the backstop.
Moving tests earlier in the lifecycle is a broader change than one gate. The tactical models, from developer-run tests to CI-run suites, are covered in shift-left testing in Kubernetes. The mechanics of running integration and end-to-end suites from CI against a cluster are in the complete guide to Kubernetes testing.
Expect the merge queue to need attention once the gate is in place. Pull requests that each passed on their own can still conflict once both merge. GitHub’s merge queue runs the required checks again against the combined result before it lands.
Who owns the gate
The platform team owns the gate, and service teams own the suites. The platform team runs the environments, the pipeline templates, the time budget and the quarantine list, the same way it runs CI. Each service team owns the integration and end-to-end tests for its service and decides which consumers’ suites run when it changes.
That split keeps the gate consistent across services without the platform team writing everyone’s tests. It also gives a failing required check an obvious owner: the suite’s team if the test is wrong, the author if the change is. Whether developers or QA should run those tests is its own argument, made in who should run tests.
Pre-merge verification checklist
Answer each with yes or no. Every no is a gap in the gate.
- Do build, lint, static analysis and unit tests run on every pull request and block on failure?
- Do changes to an API or event schema run a contract check?
- Does every pull request that changes a service get its own environment with the services it calls?
- Do integration tests run against that environment before merge, not in staging after it?
- Do end-to-end flows that cross the changed service run before merge?
- Are regression suites selected by the services a change touched and the services that call them?
- Does a comparison against the stable version catch behavior changes no test asserts?
- Do performance and security checks run on pull requests that touch hot paths, authentication or data handling?
- Does the whole gate finish within its time budget?
- Are flaky tests quarantined out of the required set and tracked until fixed?
- Are the results posted on the pull request, where the reviewer sees them?
- Can coding agents run the same checks before they open a pull request?
How Signadot runs pre-merge verification
Signadot is the verification layer for the AI software development lifecycle (SDLC). It gives every pull request a Sandbox, Signadot’s lightweight ephemeral environment, on the Kubernetes cluster you already run, and runs your checks against it before merge.
A Sandbox holds only the workloads a pull request modified. Every other call goes to the shared stable services in the cluster, carried by the routing key in the request header, so the change runs in a production-like system without a copy of the stack.
Routing works through Signadot’s DevMesh sidecar, Istio, Linkerd or the Kubernetes Gateway API (in alpha). When a change can’t share a database or queue, the Sandbox declares its own copy as a resource, created and deleted with it. CI creates Sandboxes on every pull request through the GitHub Actions integration, or through the CLI in GitLab, Bitbucket, Jenkins and Argo CD, and they’re deleted with the pull request.
Checks run as Jobs: your existing Playwright, Cypress, Postman or k6 suites, in pre-warmed pods inside the cluster, with output streamed back to CI. SmartTests compare the Sandbox with the stable version and score the differences, which is how regressions without a test get caught. Coding agents create Sandboxes and run the same checks through Signadot’s MCP server and agent skills, so the gate in CI confirms what the agent has already verified.
ShareChat, with more than 100 microservices on Kubernetes, gives every pull request its own Sandbox, as described in how ShareChat tests every pull request on Kubernetes. The setup for your own services is on the microservices testing solution page.
Related reading
- What a Green Check on a Pull Request Should Promise
- Shift-Left Testing for Kubernetes Microservices: What Moves to the Pull Request
- Your CI/CD Pipeline Wasn’t Built for Microservices
- How to Fix Flaky Tests: Detect, Quarantine and Remove the Cause
- Merging To Test Is Killing Your Microservices Velocity
- Jobs: Run Your Test Suites Inside the Cluster
- Microservices Testing with Ephemeral Environments
Frequently asked questions
What is pre-merge verification?
Pre-merge verification is the practice of proving a change works before it reaches the main branch. Every pull request runs build, unit and contract checks, then integration and end-to-end tests against running versions of the services it calls. The pull request merges only when those checks pass, so main holds changes that were tested in context rather than changes waiting for someone to test them in staging.
What tests should run on every pull request?
Run build, lint and static analysis, unit tests and contract checks on every pull request, because they are cheap and need no environment. Add integration and end-to-end tests for any change to a service other services call, run against that change's own environment. Performance and security checks belong on pull requests that touch hot paths, authentication or data handling. Pull request testing should cover what the change could break, not every suite you own.
Our PR pipeline only runs unit tests. What should we add first?
Add integration tests that call the changed service through its real neighbors, in an environment created for that pull request. That one step catches the failures a unit-only pipeline hands to staging: renamed fields, changed status codes, new call patterns and query behavior on realistic data. Start with the services that break staging most often, make the check required, and grow pre-merge verification from there.
What is regression testing in CI?
Regression testing in CI means running the tests that protect existing behavior on every change, automatically, before it merges. The point is to catch a change that breaks something that used to work, such as an endpoint another service depends on. At microservice scale, the useful version runs those suites against the changed service with its real dependencies, and compares its responses to the stable version to flag differences nobody wrote a test for.
How do you automate regression testing for microservices?
Automate it in three layers. Keep unit and contract regressions in the build. Run integration and end-to-end regression suites from CI against each pull request's own environment, selected by which services the change touched. Then compare the changed service's responses with the stable version's, so automated regression testing also catches changed fields and status codes that no existing assertion checks.
Does every pull request need its own environment?
Every pull request that changes a running service needs somewhere its integration tests can run alone, or concurrent changes break each other's results. It doesn't have to be a full copy of the stack. A lightweight ephemeral environment deploys the services a pull request changed and sends every other call to the shared stable services, which makes pre-merge verification affordable on every pull request.
How long should pre-merge checks take?
Minutes, not an hour. Set a budget for the whole gate and keep it short enough that nobody is tempted to merge around it. Fast checks run first and fail early. Integration and end-to-end suites run in parallel against an environment that starts in seconds. Pre-merge verification that takes an hour gets bypassed, and a bypassed gate verifies nothing.
How do coding agents change pull request testing?
Coding agents raise the number of pull requests and pushes, and they iterate against whatever the required checks measure. A gate that only runs unit tests teaches agents to satisfy unit tests. Pull request testing therefore has to include integration and end-to-end checks in a production-like environment, and it has to be cheap enough to run on every push an agent makes.
Can a coding agent run pre-merge checks before it opens a pull request?
Yes, when the agent's session can reach the environment and the test suites. Claude Code, Cursor or Codex can create an ephemeral environment through a CLI or MCP server, run the same integration suites CI would, read the failures and fix them before pushing. Pre-merge verification in CI then confirms what the agent already checked, instead of being the first place the change meets real services.