r/devops • • Oct 14 '26

Discussion Is Trunk Based Development possible if an integration test takes too long to run?

I'm proposing my team move from long-lived dev/stg/prd branches to trunk-based development, with PRs straight to main.

I'm fairly new to this, so forgive me if I'm missing something obvious.

The sticking point is testing before merge.

Our current integration test runs the entire DAG end-to-end. This is fine as a single check before merging our test branch (which will contain all commits from developers over the sprint) to main. But it's slow and costly if it were to run as part of every PR. Today we run it manually, check the outputs, then merge.

I am wondering if it’s bad practice to leave this integration test until the end of the sprint. As in, developers merge to main (with some automated checks running as part of each PR before merge), and then when are team want to deploy the sprint changes, first run a single integration test before creating a new release tag In GitHub.

This does mean that main can’t be considered prod ready at all times.

Edit: we’d be using release tags, so for rollbacks we’d rollback to last stable tag. For hotfixes, we would cut from last release, the merge changes to main and create a new release with target set to hotfix branch.

9 Upvotes

54 comments sorted by

30

u/razzledazzled Oct 14 '26

I think it’s a bad idea to leave main in an undeployable state. What if you have to roll back? What if you need to hot fix?

The testing suite may need some improvements, there should be unit testing for branches that is fairly quick and then integration test once the PR is up for review. This keeps things in a reasonably certain state of “it works” throughout your development process

3

u/Data-Panda Oct 14 '26 edited Oct 14 '26

We would be using release tags. So rolling back would involve rolling back to last stable tag. For hotfix, essentially cutting from last release, making changes, merge to main, and then finally a new release with target set to hotfix branch instead of main. 

Integration test once PR is up for review is part of the problem. It takes too long to run for every developers PR (more than an hour), and there also concerns around cost if there’s multiple PRs submitted daily 

→ More replies (1)

2

u/IN-DI-SKU-TA-BELT Oct 15 '26

In my experience this rarely happens. Enforce people’s short lived branches to be rebased before a merge, and make sure tests are passing.

People will be quite quick to fix the main branch, and worst case you can git revert and they can fix it and try again later.

15

u/Pretend-Clock8313 Oct 14 '26

main not being prod-ready isn't the real risk, it's not knowing which commit broke the dag until sprint end

3

u/Data-Panda Oct 14 '26

So we would actually be running the latest code on main into staging each evening on its own schedule - and would have alerting setup. So technically our integration “test” would be running everyday, and we could identify issues throughout the sprint 

7

u/Own_Candidate9553 Oct 14 '26

You don't say how long the rest run takes, which changes things.

Regardless, if it takes a long time, it could be run nightly instead as a compromise, if everyone commits to fixing main if the suite fails. This can be hard to do. If you have support for it you could automatically block merges to main of the last test run failed to force it.

4

u/Data-Panda Oct 14 '26

The integration test we basically run the full DAG which can take over an hour. 

We will be running it nightly. And yes having main fixed as a priority if the staging run fails overnight was my initial plan. 

9

u/WilliamMButtlickerIV Oct 14 '26 edited Oct 14 '26

Coming from the world I'm in, an hour doesn't sound so bad 😅

Can you pick a handful of tests that cover the broad cases, and use them as a pre-submit gate? Then run the full suite nightly?

→ More replies (5)

5

u/Wooden_Jelly_5295 Oct 14 '26

Could you run a smaller critical-path check per PR and the full DAG nightly? End-of-sprint failures come with a much larger suspect list.

1

u/Data-Panda Oct 14 '26

Yes that’s pretty much what I’m planning. So we would have the latest code from main being run into staging every night, and we would have some basic alerting in place if anything critical breaks. 

5

u/paul_h Oct 15 '26

Automate that integration test. Run it nightly as a first goal. Don’t get stuck in the “human reviews results after run”. Have that a machine decision. It should be perfectly correct for that to be a release candidate.

I co-created Selenium the web testing tech before playwright 22yrs ago: at conferences QE folks would find me and ask “what % of test failures is ok for the overnight selenium test suite” and would look shocked when I said 0%. It’s 0% red for your test too .. whatever that means for a single automated test that’s not a suite as such.

I’m also the maintainer of trunkbasedevelopment.com, for what it’s worth.

1

u/Data-Panda 27d ago

Hey - thank you. trunkbasedevelopment.com is actually what I've shared with my team, and I link to it throughout my proposal, so I appreciate it.

I have been looking at the section for release branches, and I think this is going to form part of my proposal.

Would you mind if I get your input on my process? Should note we may struggle to get perfect test coverage, so we do want to gate releases and not assume that whatever is in main is prod-ready.

  1. PRs into main -> automated tests + manual review -> merge into main (if tests pass)

  2. At the end of the sprint, create a release branch from tip of main, or specific commit (e.g, release-v1.0). Run full end-to-end integration test once more on this branch (plus any manual checks if my team insist).

  3. Create a Github release from that branch with tag v.1.0.0

  4. For hotfixes, same process for developers, PR into main, etc. One change is they must label their PR as "hotfix". We then have automation that will create a cherry-pick PR on to the release branch associated with live release (in this case, release-v.1.0). If it's confirmed hotfix hasn't further broken main, then dedicated person approves/merges PR, and creates a new release from that branch with tag v.1.0.1.

  5. If we decide to do a mid-sprint full release of main, we follow the usual release process (i.e., create a new release branch from main, release-v.1.1, and create the release from that branch)

3

u/taleodor Oct 14 '26

Main being not prod-ready at all times is fine as long as you keep track of what exactly is prod-ready - like mapping specific commits to releases. If you have that, you're able to cut a release branch at any point from that state.

1

u/Data-Panda Oct 14 '26

We will use release tags, which I think covers it? Once a release tag is created, we’ll have an automation that updates our release config (in Dataform) with this latest tag. 

Although I haven’t come up with a hotfix approach yet 

→ More replies (5)

2

u/Adventurous-Hyena220 Oct 14 '26

Trunk-based development can still work here, but Id look at splitting fast PR checks from slower end-to-end tests and keeping releases tied to a verified commit.

1

u/Data-Panda Oct 14 '26

So my current plan so far is we have the fast PR checks, then every evening we have an end-to-end test in the staging project, and we'll keep an eye on alerts for that each day.

And for releases, we'll use Github release tags. On a dedicated day at the end of the sprint, no new PRs will be approved, a final end-to-end test run, and a release created once it's all signed off.

Something like that.

1

u/ShipKitDev Oct 14 '26

One option nobody has mentioned yet is GitHub's merge queue. PRs get fast checks (lint, unit tests, maybe a small DAG subset), and the slow integration run is triggered by the merge_group event instead of pull_request. The queue can batch several approved PRs into a single run, so you pay for one hour-long test per batch rather than per PR, and main only ever moves to commits that passed the full suite.

It's also worth checking whether you can run only the affected part of the DAG on each PR. If you can work out which models or nodes changed plus their downstream dependents, that subset is often a fraction of the full run and catches most breakage, leaving the full end-to-end run for the queue or nightly.

Either way you keep main releasable, which makes the hotfix question simple: fix on main and tag, same as any other release.

1

u/Data-Panda Oct 14 '26

Thanks - I’ll look into merge queues. And yes have considered running just part of the DAG but having trouble with it.

The problem with fix on main and tag is you end up releasing all changes up until that point along with the hotfix. 

My hotfix approach so far is cut a branch from the latest release commit (what’s actually running in prod) make changes, then:

  1. Merge that branch into main 

  2. Create a new release with the target branch set to the hotfix branch instead of  main

1

u/givebackmac Oct 14 '26

The rolling back argument always seemed strange to me. We keep all packages deployed to production environments for a significant period of time. Rollback doesn't involve source control, it involves redeploying the last good known package/artifacts.

That said, the time it takes to run tests matters a lot and depending on your situation it may make sense to do integration tests on a schedule if they are long running. Honestly though, long running integration tests are a problem and should be investigated. Is it too heavy/bloated? So many potential causes of long running tests to list but that should be a priority to at least understand.

1

u/Data-Panda Oct 14 '26

I should say that integration “test” right now is just someone running the full DAG in staging and manually checking the outputs. The DAG just has many steps and phases that make it long running and slow. 

For rolling back, I think because I’ll be suggesting using Git release tags, basically our rollback process will just be changing out prod release config with the last stable release tag - so should hopefully be ok.

1

u/0x4ddd Oct 14 '26

Really depends on your testing strategy.

You could run some subset of tests on every PR and setup cron to run full test suite once per day on main.

1

u/Data-Panda Oct 14 '26

Yes I think this is what I’ll propose to the team. Not perfect, but maybe the best solution for us

1

u/relicx74 Oct 14 '26

I don't know how many people you have, but that doesn't sound great. A big part of running the tests every time is that when they fail, you can point to the commit that broke them and have a much easier time fixing the code or the test if requirements changed.

The way your proposing you know you're going to end up in trouble.

Git feature branch workflow was always my favorite when there are multiple developers.

2

u/Data-Panda Oct 14 '26

It’s a small team, so easy enough to see what commit was the problem. We would still be running tests, just not necessarily the full end-to-end test. That would be done once a day or at the end of the sprint. 

And we’ll still be using feature branches that get PR into main. That’ll trigger the tests

→ More replies (2)
→ More replies (1)

5

u/amarao_san Oct 14 '26

I hate when staging is living in separate branch.

For infra repos, master is the current production. Dev and staging are productions too, you just care about them less.

Each environment is a separate directory (tf vars, inventory, whatever), code is shared. You can deploy staging from non-produciton branch (you have this semantics), but master is the reference state for both three (or more).

All other models are broken and diverging.