Skip to content

CLI-1557 Add bulk GitHub CI onboarding command - #1318

Merged
zglicz merged 14 commits into
codex/CLI-1556-github-lifecyclefrom
codex/CLI-1557-github-command
Nov 26, 2026
Merged

zglicz merged 14 commits into
codex/CLI-1556-github-lifecyclefrom
codex/CLI-1557-github-command

Conversation

@zglicz

@zglicz zglicz commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Adds sonar admin onboard-ci github --org <org> to open CI configuration PRs for repositories already bound in SonarQube Server (CLI-1557).

  • Support repository lists, complete workflow templates, dry runs and JSON reports. Check Server permissions before prompting for the GitHub token.
  • Share common options, the concurrent repository runner, project-existence and analysis-history checks, readable skip messages, and final summaries/report writing with GitLab. Continue the batch after repository failures and show progress and retry warnings.
  • Preserve all distinct project bindings and skip repositories bound to multiple project keys with MULTIPLE_PROJECT_KEYS, rather than choosing one arbitrarily.
  • Keep provider-specific workflow handling and existing report formats, including GitLab's mrUrl keys. Dry-run summaries describe what would happen without making repository changes.

Focused integration tests cover both providers' eligibility, existing analysis, reruns, reports and partial failures. In-process integration coverage is included in LCOV. User documentation and opt-in live tests are tracked in CLI-1558.

Stacked on #1311. Telemetry follows in #1333; shared write pacing and rate-limit cooldowns for both providers are handled separately in #1383.

@zglicz
zglicz added this pull request to stack #1297 November 19, 2026 14:41
@netlify

netlify Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for sonarqube-cli canceled.

Name Link
🔨 Latest commit 508cb33
🔍 Latest deploy log https://app.netlify.com/projects/sonarqube-cli/deploys/6b0801d9bf73bf95ba4adc8f

@hashicorp-vault-sonar-prod

hashicorp-vault-sonar-prod Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

CLI-1557

Comment thread src/commands/command-tree.ts Resolved
@zglicz
zglicz force-pushed the codex/CLI-1557-github-command branch from 6e87d50 to f01f451 Compare November 19, 2026 14:53
Comment thread src/commands/command-tree.ts Resolved
Comment thread src/commands/admin/onboard-ci/types.ts Resolved
@zglicz
zglicz marked this pull request as ready for review November 20, 2026 08:45
@zglicz
zglicz requested review from a team as code owners November 20, 2026 08:45
Comment thread src/commands/admin/onboard-ci/shared.ts Resolved
@zglicz
zglicz force-pushed the codex/CLI-1557-github-command branch 3 times, most recently from 4f024c9 to 48e431f Compare November 24, 2026 15:12
@zglicz
zglicz force-pushed the codex/CLI-1557-github-command branch from a26ad4a to fb0801c Compare November 25, 2026 15:01
@zglicz
zglicz force-pushed the codex/CLI-1557-github-command branch from fb0801c to 471d5d3 Compare November 25, 2026 17:14
@gitar-bot

gitar-bot Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Code Review ✅ Approved 🟡 Medium risk 4 closed / 4 findings

Bulk onboarding creates CI workflow branches and pull requests across bound repositories; a misconfigured template could propose unintended pipeline changes.

Adds sonar admin onboard-ci github --org <org> to open CI configuration PRs for repositories bound in SonarQube Server, sharing the runner, eligibility checks, and reports with GitLab. Resolved the double workflow template read/validation per run, retry warnings being erased by TTY progress redraws, the GitLab mrUrl report key being renamed to prUrl despite the preserve claim, and the server-side import breakage for #1325 once this stack merges. No open issues remain.

✅ 4 closed
✅ Quality: Workflow template is read and validated twice per GitHub run

📄 src/commands/command-tree.ts:1401-1406 📄 src/commands/admin/onboard-ci/github/index.ts:64-76 📄 src/commands/admin/onboard-ci/github/index.ts:160
The GitHub action handler calls validateOnboardCiGithubOptions(options) and throws away the template it returns (command-tree.ts:1402). onboardCiGithub then calls the same function again (index.ts:160), which reads and validates --workflow-template a second time. If the file changes between the two reads, the content that passed the pre-prompt check may not be the content that gets used. Either pass the template string from the first call into onboardCiGithub, or drop the second call and accept a pre-read template parameter.

✅ Bug: Retry warnings get erased by live progress redraw in TTY mode

📄 src/commands/command-tree.ts:1406-1410 📄 src/commands/admin/onboard-ci/shared.ts:114-128
The new onRetry hook calls ctx.console.warn. TerminalConsole.warn writes the line straight to stderr, and ConcurrentProgress (used by runWithRepoProgress for every repository) has no way of knowing that happened. On its next render(), erase() moves the cursor up only linesRendered lines, then calls clearScreenDown. In a TTY that clears the retry notice along with the old rows. It also leaves the first progress row behind as a stale duplicate, and each retry adds another. So in interactive mode, the main use case, this commit doesn't actually show the retry notices: they flash and disappear, and the progress block gets corrupted. To fix it, route the message through the progress component, e.g. add a ConcurrentProgress.log() that calls erase(), writes the line, then render(). Another option is to collect retry notices and print them once the progress block finishes.

✅ Bug: GitLab report key renamed from mrUrl to prUrl despite 'preserve' claim

📄 src/commands/admin/onboard-ci/types.ts:32-40 📄 src/commands/admin/onboard-ci/gitlab/processor.ts:70 📄 src/commands/admin/onboard-ci/gitlab/processor.ts:78 📄 src/commands/admin/onboard-ci/gitlab/processor.ts:217 📄 src/commands/admin/onboard-ci/gitlab/processor.ts:282 📄 src/commands/admin/onboard-ci/gitlab/index.ts:319 📄 src/commands/admin/onboard-ci/gitlab/index.ts:323 📄 src/commands/admin/onboard-ci/gitlab/types.ts:62-64 📄 tests/integration/specs/admin/onboard-ci-gitlab.test.ts:437-443 📄 tests/integration/specs/admin/onboard-ci-gitlab.test.ts:1246-1254
This commit renames the GitLab report field from mrUrl to prUrl in opened[] and skipped[] (gitlab/processor.ts:70,78,217,282; gitlab/index.ts:319,323), because the shared OpenedResult/SkippedResult in types.ts:32-40 now hard-code prUrl. The GitLab command already ships with mrUrl in sonar-onboard-ci-report.json (on master since e5b27c5 and in tags 1.10.0 and later, behind the Alpha stage). Any script that reads opened[].mrUrl or skipped[].mrUrl will now get undefined. That goes against the PR description, which says it will 'preserve ... existing GitLab report fields', and the updated integration tests (onboard-ci-gitlab.test.ts:437-443,1246-1254) lock in the new key. Fix: either keep a provider-specific URL key (make the shared result types generic over the key, or keep the GitLab-local mrUrl interfaces), or treat this as a deliberate breaking rename and update the PR description and release notes to say so.

✅ Cross-PR: #1325's GitLab server-side imports break once this stack merges

📄 src/commands/admin/onboard-ci/gitlab/types.ts:21 📄 src/commands/admin/onboard-ci/gitlab/index.ts:280-294
Breaks when this stack and #1325 both land on the same mainline, and #1325 has not been rebased onto onboard-ci/shared.ts and onboard-ci/types.ts.

How

  1. In this PR, gitlab/types.ts:21-55 exports only stages, TriggerOn, SkipReason and the option interfaces. DryRunResults and OnboardCiResults are gone, and gitlab/report.ts and gitlab/dry-run.ts no longer exist.
  2. GROW-703 Run onboard-ci gitlab on the server when available #1325's gitlab/server-side.ts:50 imports DryRunResults/OnboardCiResults from ./types.ts and buildOutroMessage/repositoriesFailedError/writeReportFile from ./report.ts. Neither import resolves, so the typecheck fails.
  3. GROW-703 Run onboard-ci gitlab on the server when available #1325's gitlab/index.ts still calls runLive/runDryRun/classifyRepo. This PR replaced them with runRepos and assessRepo (gitlab/index.ts:280-292).
  4. This PR maps the shared prUrl back to mrUrl for GitLab reports (gitlab/index.ts:321-329). If GROW-703 Run onboard-ci gitlab on the server when available #1325's results move to the shared RepoRunResults without the same mapping, server-side reports will use different keys from client-side ones.

Fix

Compared 3d84828 with #1325 at b8c1171

Verification Rules 1/2 met PRs 3 inspected
Rules 1 failed 1 passed 3 not applicable

❌ Repository license compliance - Unable to verify: no LICENSE/LICENCE file or .github/sonarsource.yml could be located or read in the workspace, so license compliance cannot be confirmed; please confirm a valid LICENSE exists at the repo root.
✅ Internal artifact registries

Functional validation No results

Broader impact PRs 3 inspected
Cross-PR 3 PRs inspected 0 open impacts

PR 1333: CLI-1575 Track CI onboarding PR and MR creations Inspected
PR 1383: Share DevOps write pacing and rate-limit cooldowns Inspected
PR 1296: CLI-1554 Share Server integration discovery for GitHub onboarding Inspected

Auto-approval Withheld

For more verification details, comment gitar display:verbose.

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

@datadog-sonarsource

This comment has been minimized.

@sonarqubecloud

Copy link
Copy Markdown

@zglicz
zglicz merged commit 455dc93 into master Nov 26, 2026
46 of 47 checks passed
@zglicz
zglicz deleted the codex/CLI-1557-github-command branch November 26, 2026 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants