Skip to content

docs: do the SonarCloud main-branch setup before the first merge to main - #170

Merged
cuioss-oliver merged 2 commits into
mainfrom
fix/sonar-main-branch-order
Nov 20, 2026
Merged

cuioss-oliver merged 2 commits into
mainfrom
fix/sonar-main-branch-order

Conversation

@cuioss-oliver

@cuioss-oliver cuioss-oliver commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

Following the README, derived repositories ended up with a Sonar main branch called master: the step said "before the first analysis", but CI auto-creates a missing project with master as soon as the first merge to main runs. Seen in cuioss/TrailHand and cuioss/git-document-repository (fixed there by deleting the short-lived main and renaming master). A project was also created in the wrong organization.

Change

  • README, "After creating the repository": the SonarCloud step happens before the first push or merge to main, names the organization cuioss-github, and ends with a verification (project_branches/list, isMain must be main).
  • customize.sh: the printed next steps say the same.

No change to .github/project.yml or the release workflow, so nothing reaches the release guard.

🤖 Generated with Claude Code

https://claude.ai/code/session_01AEE74wh8Lty7n7shHcsVCX

CI creates a missing Sonar project itself with the main branch master, so
the rename must happen before the first push or merge to main. State the
organization (cuioss-github) and add a verification command, in the README
and in the customize.sh next steps.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AEE74wh8Lty7n7shHcsVCX
@cuioss-oliver cuioss-oliver added the skip-bot-review Skip automated bot code review (Gemini/CodeRabbit/Sourcery) label Nov 20, 2026
@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are limited based on label configuration.

🚫 Excluded labels (none allowed): 1

  • skip-bot-review

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Central YAML; Path: .coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d384b466-1883-4240-9f8d-7756643d8944

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 2 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="customize.sh" line_range="121" />
<code_context>
 echo "Next steps (see README.adoc, 'After creating the repository'):"
 echo " - Do NOT change release.current-version in .github/project.yml: merging that change IS a release."
-echo " - SonarCloud: create ${PROJECT_SONAR_ID} and rename its main branch 'master' to 'main' before the first analysis."
+echo " - SonarCloud, BEFORE the first push or merge to main (CI would create the project itself with main branch 'master'):"
+echo "   create ${PROJECT_SONAR_ID} in organization cuioss-github and rename its main branch 'master' to 'main'."
+echo "   Verify: curl -s \"https://sonarcloud.io/api/project_branches/list?project=${PROJECT_SONAR_ID}\" (isMain must be 'main')"
</code_context>
<issue_to_address>
**SonarCloud project gets wrong main branch**

When a pull request targeting `main` is the first event to run CI, the Maven workflow runs Sonar analysis before the prescribed setup, so SonarCloud creates the project with `master` as its main branch. The project overview then uses the wrong branch.

Require creating the SonarCloud project and renaming its main branch to `main` before any analysis, including pull-request analysis.

Also at `customize.sh:122`.
</issue_to_address>

### Comment 2
<location path="customize.sh" line_range="123" />
<code_context>
-echo " - SonarCloud: create ${PROJECT_SONAR_ID} and rename its main branch 'master' to 'main' before the first analysis."
+echo " - SonarCloud, BEFORE the first push or merge to main (CI would create the project itself with main branch 'master'):"
+echo "   create ${PROJECT_SONAR_ID} in organization cuioss-github and rename its main branch 'master' to 'main'."
+echo "   Verify: curl -s \"https://sonarcloud.io/api/project_branches/list?project=${PROJECT_SONAR_ID}\" (isMain must be 'main')"
 echo " - Add ${PROJECT_KEY} to 'consumers:' in cuioss-organization/.github/project.yml."
 echo " - Apply branch protection / merge queue with cuioss-organization/branch-protection."
</code_context>
<issue_to_address>
**SonarCloud verification gives an impossible check**

When users follow the printed verification instructions, the SonarCloud API returns `isMain` as a boolean and reports the branch name separately, so checking whether `isMain` is `'main'` cannot verify the configuration. Users can reject a correctly configured `main` branch or fail to notice that it is not the main branch.

Tell users to verify that the branch named `main` has `isMain: true`.

Also at `customize.sh:124`.
</issue_to_address>

Sourcery assessment

Approval pending. 2 findings to address first.

Blocking findings: customize.sh:121, customize.sh:123


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread customize.sh Resolved
Comment thread customize.sh Resolved

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sourcery assessment

Approved.

@cuioss-oliver
cuioss-oliver merged commit 9df205f into main Nov 20, 2026
17 checks passed
@cuioss-oliver
cuioss-oliver deleted the fix/sonar-main-branch-order branch November 20, 2026 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-bot-review Skip automated bot code review (Gemini/CodeRabbit/Sourcery)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant