Run Sonar on push so branch baselines stop going stale by aleksandar-apostolov · Pull Request #78 · GetStream/stream-build-conventions-android · GitHub
Skip to content

Run Sonar on push so branch baselines stop going stale - #78

Merged
gpunto merged 2 commits into
developfrom
ci/sonar-analyse-on-push
Sep 22, 2026
Merged

gpunto merged 2 commits into
developfrom
ci/sonar-analyse-on-push

Conversation

@aleksandar-apostolov

@aleksandar-apostolov aleksandar-apostolov commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Goal

Fixes AND-1443

The Sonar step is gated on github.event.pull_request.head.repo.full_name == github.repository. On a push there is no pull_request object, so the guard is
always false and Sonar only ever runs on PRs — which never refreshes the branch
baseline. Consumers have been measuring new code against a baseline frozen since
they adopted this workflow: core 2025-12-23, video 2025-12-19, feeds 2025-10-15.

stream-chat-android also consumes this workflow, from pr-checks.yml, but is not
affected by the staleness — it gets branch analysis from its own build-and-test.yml,
which runs Sonar on push unconditionally.

Implementation

Gate the Sonar step on push explicitly and scope the fork check to pull_request;
the Dependabot guard stays on all events.

The old condition also made the sibling "skipped because the PR comes from a fork"
notice fire on pushes, merge-queue runs and manual dispatches, reporting the wrong
reason in the log. That one is scoped too.

SONAR_TOKEN is a repo secret in core, video and feeds and is already passed into
this workflow, so it is available to push-event runs.

Testing

actionlint .github/workflows/android-ci.yml — clean.

Both conditions evaluated per event type:

Event Sonar "from a fork" notice
push to develop/main skipped → runs printed → silent
PR, same repo runs → runs silent → silent
PR, from fork skipped → skipped printed → printed
PR, dependabot skipped → skipped silent (Dependabot notice instead)
merge_group skipped → skipped printed → silent
workflow_dispatch skipped → skipped printed → silent

Consumers pin this workflow by SHA, so each repo needs its android.yml bumped
before it takes effect.

The Sonar step was gated on `github.event.pull_request.head.repo.full_name
== github.repository`. On a push there is no pull_request object, so the
left side is the empty string and the guard is always false. Sonar has
therefore only ever run on pull requests, and a PR analysis does not
refresh the branch baseline.

Consumers have been measuring "new code" against a baseline frozen at the
day they adopted this workflow: stream-core-android last analysed
2025-12-23 (the day it was created), stream-video-android 2025-12-19,
stream-feeds-android 2025-10-15.

Keep the fork and Dependabot guards, but apply the fork check only to
pull_request events. The same stale condition also made the sibling
"skipped because the PR comes from a fork" notice fire on every push,
reporting the wrong reason in the log.
@aleksandar-apostolov aleksandar-apostolov added the pr:workflows The PR includes changes to GitHub actions & workflows label Sep 21, 2026
@coderabbitai

coderabbitai Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 915babe1-b0f3-46bd-8b39-e96d76f8aa3f


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.

@github-actions

Copy link
Copy Markdown
Contributor

PR checklist ✅

All required conditions are satisfied:

  • Title length is OK (or ignored by label).
  • At least one pr: label exists.
  • Sections ### Goal, ### Implementation, and ### Testing are filled, or the PR is bot-authored.
  • An issue is linked (Linear ticket or GitHub issue), or the PR is bot-authored.

🎉 Great job! This PR is ready for review.

Comment thread .github/workflows/android-ci.yml Outdated
Review feedback from @gpunto. The previous form admitted merge_group and
workflow_dispatch, both of which were skipped before.

merge_group reaches one consumer: stream-chat-android calls this workflow
from pr-checks.yml, which triggers on pull_request and merge_group, and
that repo has a real coverage { includedModules = ... } block. On a
merge-queue run GITHUB_REF is refs/heads/gh-readonly-queue/..., and the
plugin sets no sonar.branch.name, so the scanner would register that
throwaway ref as a SonarCloud branch — and a Sonar failure inside the
required unit-test job could block the queue. Chat already gets branch
analysis from its own build-and-test.yml.

workflow_dispatch has the same shape in core, video and feeds: dispatching
CI on a feature branch would register that branch in SonarCloud.
@gpunto
gpunto merged commit 68c8917 into develop Sep 22, 2026
8 checks passed
@gpunto
gpunto deleted the ci/sonar-analyse-on-push branch September 22, 2026 12:59
@stream-public-bot stream-public-bot added the released Included in a release label Sep 22, 2026
@stream-public-bot

Copy link
Copy Markdown
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:workflows The PR includes changes to GitHub actions & workflows released Included in a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants