Skip to content

chore(ci): skip Sonar analysis when SONAR_TOKEN is unavailable - #426

Merged
dmihalcik-virtru merged 1 commit into
mainfrom
chore/skip-sonar-without-token
Oct 21, 2026
Merged

dmihalcik-virtru merged 1 commit into
mainfrom
chore/skip-sonar-without-token

Conversation

@dmihalcik-virtru

Copy link
Copy Markdown
Member

Summary

  • checks.yaml / mavenverify: pass -Dsonar.skip=true when SONAR_TOKEN is empty. Pushes to main and same-repo PRs still run the Sonar analysis.
  • codeql.yaml: pass github_token to buf-setup-action, as checks.yaml already does.

Rationale

Dependabot and fork PRs can't read Actions secrets. On #408, #407 and #387, mavenverify gets through the build and all tests, then fails in the Sonar goal:

[ERROR] Not authorized. Please check the 'sonar.token' property or the 'SONAR_TOKEN' environment variable ...

sonar-maven-plugin checks sonar.skip before it starts the scanner (source), so the job now passes or fails on the build and tests alone. I put the change in the workflow instead of pom.xml because it depends on the CI environment.

CodeQL on #407 failed with API rate limit exceeded inside the buf setup step. Without a token, that step calls the GitHub API unauthenticated and shares the runner IP's rate limit.

Test plan

  • YAML parses; checked the skip logic for empty and non-empty SONAR_TOKEN
  • This PR's own mavenverify still runs Sonar (token available)
  • After merge, the recreated Dependabot PRs show sonar.skip = true: Skipping analysis and mavenverify passes

Companion PR: #425 (Dependabot PR titles).

Dependabot and fork PRs can't read the SONAR_TOKEN secret, so the Sonar
goal in mavenverify fails with "Not authorized" after the tests have
passed, and the PR shows red. Pass -Dsonar.skip when the token is empty
so the job reflects the build and test result. Pushes to main and
same-repo PRs still run the analysis.

Also pass GITHUB_TOKEN to buf-setup-action in the CodeQL workflow, as
checks.yaml already does; without it the action calls the GitHub API
unauthenticated and can fail on the shared runner rate limit.

Signed-off-by: Dave Mihalcik <dmihalcik@virtru.com>
@dmihalcik-virtru
dmihalcik-virtru requested review from a team as code owners October 20, 2026 20:44
@coderabbitai

coderabbitai Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 59 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ea97ebe5-3b04-4557-b57a-50e5cb6463b9
📥 Commits

Reviewing files that changed from the base of the PR and between 525e5b0 and 6d3ef65.

📒 Files selected for processing: 2
  • .github/workflows/checks.yaml
  • .github/workflows/codeql.yaml
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Comment @coderabbitai help to get the list of available commands.

@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown
Contributor

@dmihalcik-virtru
dmihalcik-virtru merged commit bb581b5 into main Oct 21, 2026
24 checks passed
@dmihalcik-virtru
dmihalcik-virtru deleted the chore/skip-sonar-without-token branch October 21, 2026 00:38
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.

3 participants