From e310cc59d21d90cf59da44497a802dc76d3c38ba Mon Sep 17 00:00:00 2001 From: donpetry-bot <281750570+donpetry-bot@users.noreply.github.com> Date: Wed, 15 Jul 2026 09:00:19 +0000 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20implement=20issue=20#400=20?= =?UTF-8?q?=E2=80=94=20[Fleet=20Monitor]=20petry-projects/broodly=20?= =?UTF-8?q?=E2=80=94=20.github/workflows/sonarcloud.yml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/sonarcloud.yml | 5 +++ tests/integration/sonarcloud-workflow.bats | 36 ++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 tests/integration/sonarcloud-workflow.bats diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 6ad823cc..1452f0eb 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -28,6 +28,11 @@ jobs: - run: pnpm install --frozen-lockfile - name: Generate JS/TS coverage report working-directory: apps/mobile + # Non-blocking: a failing/flaky mobile test must not sink SonarCloud + # analysis. ci.yml is the authoritative test gate; here jest still + # writes lcov for the tests that ran, and SonarCloud ingests it and + # enforces its own quality gate regardless of this step's exit code. + continue-on-error: true run: pnpm exec jest --coverage --coverageReporters=lcov --coverageDirectory=coverage - name: SonarCloud Scan (attempt 1) id: sonar_1 diff --git a/tests/integration/sonarcloud-workflow.bats b/tests/integration/sonarcloud-workflow.bats new file mode 100644 index 00000000..813c052a --- /dev/null +++ b/tests/integration/sonarcloud-workflow.bats @@ -0,0 +1,36 @@ +#!/usr/bin/env bats +# Integration tests for .github/workflows/sonarcloud.yml +# +# The SonarCloud workflow re-runs the mobile jest suite solely to produce a +# coverage report for analysis. When that suite fails or flakes, the whole +# analysis job used to go red — even though ci.yml already runs and gates the +# same tests. These tests assert the coverage step is non-blocking so a test +# failure no longer sinks SonarCloud analysis, while confirming the scan step +# and its retry/backoff logic remain intact. + +setup() { + REPO_ROOT="$(cd "$BATS_TEST_DIRNAME/../.." && pwd)" + WORKFLOW="$REPO_ROOT/.github/workflows/sonarcloud.yml" +} + +@test "coverage generation step is non-blocking (continue-on-error)" { + run yq '.jobs.sonarcloud.steps[] | select(.name == "Generate JS/TS coverage report") | .["continue-on-error"]' "$WORKFLOW" + [ "$status" -eq 0 ] + [ "$output" = "true" ] +} + +@test "SonarCloud scan runs and is guarded by the SONAR_TOKEN secret" { + run yq '[.jobs.sonarcloud.steps[] | select(.uses | test("SonarSource/sonarqube-scan-action"))] | length' "$WORKFLOW" + [ "$status" -eq 0 ] + [ "$output" -ge 1 ] + + run yq '.jobs.sonarcloud.steps[] | select(.id == "sonar_1") | .if | contains("SONAR_TOKEN")' "$WORKFLOW" + [ "$status" -eq 0 ] + [ "$output" = "true" ] +} + +@test "SonarCloud scan retry/backoff attempts remain intact" { + run yq '[.jobs.sonarcloud.steps[] | select(.uses | test("SonarSource/sonarqube-scan-action"))] | length' "$WORKFLOW" + [ "$status" -eq 0 ] + [ "$output" -eq 3 ] +} From 197613dec56c6f3327dc6a430dc884fc3d2b9d2a Mon Sep 17 00:00:00 2001 From: donpetry-bot <281750570+donpetry-bot@users.noreply.github.com> Date: Wed, 15 Jul 2026 09:03:13 +0000 Subject: [PATCH 2/3] fix(reviews): address review comments [skip ci-relay] --- tests/integration/sonarcloud-workflow.bats | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/integration/sonarcloud-workflow.bats b/tests/integration/sonarcloud-workflow.bats index 813c052a..e192daca 100644 --- a/tests/integration/sonarcloud-workflow.bats +++ b/tests/integration/sonarcloud-workflow.bats @@ -24,9 +24,9 @@ setup() { [ "$status" -eq 0 ] [ "$output" -ge 1 ] - run yq '.jobs.sonarcloud.steps[] | select(.id == "sonar_1") | .if | contains("SONAR_TOKEN")' "$WORKFLOW" + run yq '[.jobs.sonarcloud.steps[] | select(.uses | test("SonarSource/sonarqube-scan-action")) | select((.if // "") | contains("SONAR_TOKEN") | not)] | length' "$WORKFLOW" [ "$status" -eq 0 ] - [ "$output" = "true" ] + [ "$output" -eq 0 ] } @test "SonarCloud scan retry/backoff attempts remain intact" { From 3950323ac5ea37509f12c46e09e821dad87055ee Mon Sep 17 00:00:00 2001 From: donpetry-bot <281750570+donpetry-bot@users.noreply.github.com> Date: Wed, 15 Jul 2026 09:05:01 +0000 Subject: [PATCH 3/3] chore: dev-lead update (review-changes) [skip ci-relay] --- tests/integration/sonarcloud-workflow.bats | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/integration/sonarcloud-workflow.bats b/tests/integration/sonarcloud-workflow.bats index e192daca..6a957ae3 100644 --- a/tests/integration/sonarcloud-workflow.bats +++ b/tests/integration/sonarcloud-workflow.bats @@ -9,6 +9,9 @@ # and its retry/backoff logic remain intact. setup() { + if ! command -v yq &>/dev/null; then + skip "yq is not installed — install yq (https://github.com/mikefarah/yq) to run these tests" + fi REPO_ROOT="$(cd "$BATS_TEST_DIRNAME/../.." && pwd)" WORKFLOW="$REPO_ROOT/.github/workflows/sonarcloud.yml" }