Skip to content

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

Open
aleksandar-apostolov wants to merge 1 commit into
developfrom
ci/sonar-analyse-on-push
Open

aleksandar-apostolov wants to merge 1 commit into
developfrom
ci/sonar-analyse-on-push

Conversation

@aleksandar-apostolov

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.

Implementation

Scope the fork check to pull_request events; keep the Dependabot guard on all
events. The same condition made the sibling "skipped because the PR comes from a
fork" notice fire on every push, so that one is scoped too.

SONAR_TOKEN is a repo secret in all three consuming repos and already passed into
this workflow, so it is available to push-event runs.

Testing

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

Evaluated both conditions per event type: push and workflow_dispatch now run Sonar;
same-repo PRs unchanged; fork and Dependabot PRs still skipped, with the correct
notice.

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: 04a54db1-26f0-462b-b0f5-ad3d5c475ab2


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 on lines +72 to +75
if: >-
github.actor != 'dependabot[bot]' &&
(github.event_name != 'pull_request' ||
github.event.pull_request.head.repo.full_name == github.repository)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This gate is "not a PR" rather than "is a push", so it also admits merge_group and workflow_dispatch, both of which were skipped before.

merge_group matters in one consumer: stream-chat-android's pr-checks.yml triggers on pull_request and merge_group, and that repo has a real coverage { includedModules = ... } block, so ./gradlew sonar does real work there. On a merge-queue run GITHUB_REF is refs/heads/gh-readonly-queue/develop/pr-N-<sha>, and CoverageConfiguration.kt sets no sonar.branch.name, so the scanner auto-detects that throwaway ref. Net effect: a second full Sonar run per PR, a junk SonarCloud branch per queue entry, and a Sonar failure inside the already-required unit-test job can block the merge queue. Chat gains nothing in exchange, since it already runs Sonar on push through its own build-and-test.yml.

workflow_dispatch has the same shape in feeds, core and video: dispatching CI on a feature branch would register that branch in SonarCloud.

Suggesting the explicit push form. I checked what it costs: nothing for core, video and feeds, whose push triggers are exactly develop/main, and it restores today's behaviour for chat's merge queue.

Suggested change
if: >-
github.actor != 'dependabot[bot]' &&
(github.event_name != 'pull_request' ||
github.event.pull_request.head.repo.full_name == github.repository)
if: >-
github.actor != 'dependabot[bot]' &&
(github.event_name == 'push' ||
(github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name == github.repository))

This branch has not been deployed

No deployments
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants