Is it possible to scan "development" and "UAT" environments in a repo that follows the GitHub Flow pattern? #209004
Replies: 2 comments 5 replies
|
Correction: the above is only fully true for SonarCloud. SonarQube Server Community Build (the free self-hosted edition) analyzes the main branch only — branch analysis is a Developer Edition+ feature. If you set sonar.branch.name on a non-main branch against Community Build, you get a license warning and the scan falls back onto the main branch, overwriting main's results. So the per-branch setup described below works on SonarCloud (branch analysis included on all plans, free tier included), but on a self-hosted Community Build you'd need Developer Edition for real per-branch analysis of development/uat/production. Yes, this is absolutely doable — SonarQube (and SonarCloud) treat every branch scan as branch analysis, so your long-lived Two practical things to set up:
One governance tip given your environment: since you're defending isolated development in short-lived branches plus environment branches, scanning the long-lived environment branches is actually what gives you the audit trail — each environment's scan history shows exactly what was deployed there. That maps nicely onto your TFS-migration narrative about environments being represented by branches. If you're scanning PRs as well, keep both: PR analysis for pre-merge quality gates, and branch analysis on |
|
@Rod-at-DOH reading your follow-up — I think the real blocker isn't SonarQube, it's the "a branch mirrors a deployment" habit. What helped convince people in my experience: GitHub Flow doesn't remove any of their gates, it just moves them from branches to environments. Your current process maps pretty much 1:1:
Same weeks of testing, same CAB approval, just in Settings → Environments instead of merge PRs. And the same artifact goes to all three environments, so no more "UAT build differs from prod build". jobs:
build: # sonar scan + build + upload-artifact
runs-on: ubuntu-latest
steps: [ ... ]
deploy-dev:
needs: build
environment: development
runs-on: ubuntu-latest
steps: [ ... ]
deploy-uat:
needs: deploy-dev
environment: uat
runs-on: ubuntu-latest
steps: [ ... ]
deploy-prod:
needs: deploy-uat
environment: production
runs-on: ubuntu-latest
steps: [ ... ]Two gotchas:
I'd pilot it on one small repo with the same approvers your CAB uses today. People buy it faster when they see their own approvals, just in a different place. |
Uh oh!
There was an error while loading. Please reload this page.
🏷️ Discussion Type
Question
💬 Feature/Topic Area
Other
Discussion Details
Three years ago, another GitHub Admin and I worked on migrating hundreds of TFS repos (TFVC) from an old, on-prem server to our GitHub.com GitHub Enterprise/Organization environment. One pattern, which survives to this day here, is having a branching strategy which mirrors our deployments. Thus, we have a Development branch, UAT (or uat, or test, or Test), and Production (or production) branches. This is so engrained into our culture that the
mainbranch is either ignored or in a few repos, completely removed.We are beginning a project of incorporating SonarQube into our CI GitHub Workflows. Because of the dominate paradigm, this is easy to do since the test, and development branches are never deleted.
I've known for a long time that it is better to have short lived child branches and only one branch, the
mainbranch, which is the only permanent branch in a repo. I started to learn Git Flow pattern. Then I learned of GitHub Flow, which I now favor. That pattern is very different, treating branches as a means of isolating software development. Whereas environments are for deployments using GitHub environments. But it took me a long time to finally get around to thinking like that, rather than insisting on branches isolate software features in development, and environments control deployments, but all deployments no matter however environments you have, all go through themainbranch when deploying. Because it took me so long to rethink that, I lost a lot of mindshare ground, and all the other developers are chasing the proliferation of long lives branches.If I am to show that software development is isolated in short-lived branches, and environments are used to deploy through the
mainbranches, I will now have to do that using SonarQube. At this point I am not exactly sure how I will do that. I know that if I cannot demonstrate that, then no one will ever consider GitHub Flow.All reactions