Skip to content

Commit c9ca88d

Browse files
committed
Fix SonarQube error and refine trigger conditions
The SonarQube weekly analysis workflow was failing due to a missing `compile_commands.json` file. This occurs because the build-wrapper output directory was previously referenced with an incorrect path containing an unintended quotation mark, causing the CFamily plugin to abort with a NoSuchFileException. This change fixes the failure by aligning the workflow with SonarCloud recommended usage. Additionally, this commit updates the workflow triggers and execution conditions: - Added explicit triggers for push/PR events when the workflow file itself is modified, enabling validation of workflow changes - Allow PRs to validate the build process while preventing unauthorized SonarCloud access The workflow will now: - Run all build steps in PRs for validation purposes - Execute SonarQube scans only on: * Weekly scheduled runs (apache/cloudberry only) * Manual workflow dispatch (apache/cloudberry only) * Push to main branch when workflow file changes (apache/cloudberry only)
1 parent 5f591f2 commit c9ca88d

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

.github/workflows/sonarqube.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
# Triggers:
3333
# - Weekly schedule
3434
# - optional manual dispatch.
35+
# - Changes on sonarqube.yml file
3536
#
3637
# Notes:
3738
# - SONARCLOUD_TOKEN secret is provided by the ASF Infra team
@@ -42,6 +43,14 @@ on:
4243
schedule:
4344
- cron: "0 0 * * 1"
4445
workflow_dispatch:
46+
push:
47+
branches:
48+
- main
49+
paths:
50+
- '.github/workflows/sonarqube.yml'
51+
pull_request:
52+
paths:
53+
- '.github/workflows/sonarqube.yml'
4554

4655
permissions:
4756
contents: read
@@ -112,9 +121,10 @@ jobs:
112121
build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} make -j$(nproc)
113122
114123
- name: SonarQube Scan
124+
if: ${{ github.event_name != 'pull_request' }}
115125
uses: SonarSource/sonarqube-scan-action@v6
116126
env:
117127
SONAR_TOKEN: ${{ secrets.SONARCLOUD_TOKEN }}
118128
with:
119129
args: >
120-
--define sonar.cfamily.compile-commands="${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json"
130+
--define "sonar.cfamily.compile-commands=${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json"

0 commit comments

Comments
 (0)