From 729872c01e49e6fc1e10d371e456215de8824753 Mon Sep 17 00:00:00 2001 From: Romain Brenguier Date: Wed, 8 Jul 2026 15:54:29 +0200 Subject: [PATCH 1/3] Add ruling diff comment workflow Based on action from core-languages-tooling. Parametrize action for sonar-java Initialize submodules for ruling diff workflow The submodules must be initialized to access source files for generating code snippets in ruling diff comments. Co-Authored-By: Claude Sonnet 4.5 --- .github/workflows/ruling-diff-comment.yml | 59 +++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 .github/workflows/ruling-diff-comment.yml diff --git a/.github/workflows/ruling-diff-comment.yml b/.github/workflows/ruling-diff-comment.yml new file mode 100644 index 00000000000..59ffa7316ad --- /dev/null +++ b/.github/workflows/ruling-diff-comment.yml @@ -0,0 +1,59 @@ +name: Ruling Diff Comment + +on: + pull_request: + types: [opened, synchronize, reopened] + paths: + # Trigger on ruling JSON file changes + - 'its/ruling/src/test/resources/**/*.json' + # Uncomment to test action changes + - '.github/workflows/ruling-diff-comment.yml' + workflow_dispatch: + inputs: + pr-number: + description: 'Pull request number' + required: true + type: string + base-sha: + description: 'Base commit SHA for diff' + required: true + type: string + head-sha: + description: 'Head commit SHA for diff' + required: true + type: string + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +permissions: + contents: read + pull-requests: write + +jobs: + ruling-diff-comment: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + submodules: true + + - name: Install uv + uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0 + with: + enable-cache: true + + # Use the action from the branch we just pushed + - name: Post ruling diff comment + uses: SonarSource/core-languages-tooling-public/ruling-diff-comment@master + with: + pr-number: ${{ inputs.pr-number || github.event.pull_request.number }} + repository: ${{ github.repository }} + base-sha: ${{ inputs.base-sha || github.event.pull_request.base.sha }} + head-sha: ${{ inputs.head-sha || github.event.pull_request.head.sha }} + ruling-root: 'its/ruling/src/test/resources' + sources-root: 'its/sources' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} From ac526fae7a7388f477a9ab9c808d65e58a80a159 Mon Sep 17 00:00:00 2001 From: Romain Brenguier Date: Wed, 8 Jul 2026 15:56:00 +0200 Subject: [PATCH 2/3] DO NOT MERGE Introduce some diff for testing. Optimize ruling tests for faster CI - Exclude most ruling tests (guava, mall, jetty, etc.) using @Ignore - Keep only commons-beanutils test active for PR validation - Add test changes to commons-beanutils S1134 to demonstrate diff comments This is a temporary change to speed up CI for demonstrating the ruling diff comment feature. Not intended for merge to master. Co-Authored-By: Claude Sonnet 4.5 --- .../test/java/org/sonar/java/it/JavaRulingTest.java | 8 ++++++++ .../test/resources/commons-beanutils/java-S1134.json | 11 ++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/its/ruling/src/test/java/org/sonar/java/it/JavaRulingTest.java b/its/ruling/src/test/java/org/sonar/java/it/JavaRulingTest.java index 41f81ec4652..fb1644f3e7d 100644 --- a/its/ruling/src/test/java/org/sonar/java/it/JavaRulingTest.java +++ b/its/ruling/src/test/java/org/sonar/java/it/JavaRulingTest.java @@ -48,6 +48,7 @@ import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.ClassRule; +import org.junit.Ignore; import org.junit.Test; import org.junit.rules.TemporaryFolder; import org.slf4j.Logger; @@ -189,6 +190,7 @@ private static void copyFile(Path source, Path targetDir) { } @Test + @Ignore("Excluded to speed up CI for PR demo") public void spring_mall() throws Exception { String projectName = "mall"; MavenBuild build = test_project("com.macro.mall:mall", projectName); @@ -201,6 +203,7 @@ public void spring_mall() throws Exception { } @Test + @Ignore("Excluded to speed up CI for PR demo") public void guava() throws Exception { String projectName = "guava"; MavenBuild build = test_project("com.google.guava:guava", projectName); @@ -227,6 +230,7 @@ public void apache_commons_beanutils() throws Exception { } @Test + @Ignore("Excluded to speed up CI for PR demo") public void eclipse_jetty_incremental() throws Exception { if (isCommunityEditionTestsOnly()) { return; @@ -346,6 +350,7 @@ private static String getFileLocationAbsolutePath(FileLocation location) { } @Test + @Ignore("Excluded to speed up CI for PR demo") public void sonarqube_server() throws Exception { // sonarqube-6.5/server/sonar-server (v.6.5) String projectName = "sonar-server"; @@ -355,6 +360,7 @@ public void sonarqube_server() throws Exception { } @Test + @Ignore("Excluded to speed up CI for PR demo") public void jboss_ejb3_tutorial() throws Exception { // https://github.com/jbossejb3/jboss-ejb3-tutorial (18/01/2015) String projectName = "jboss-ejb3-tutorial"; @@ -374,6 +380,7 @@ public void jboss_ejb3_tutorial() throws Exception { } @Test + @Ignore("Excluded to speed up CI for PR demo") public void regex_examples() throws IOException { String projectName = "regex-examples"; MavenBuild build = test_project("org.regex-examples:regex-examples", projectName) @@ -385,6 +392,7 @@ public void regex_examples() throws IOException { * Vibe-bot runs this test when testing samples; so it's excluded from the GitHub Actions workflow. */ @Test + @Ignore("Excluded to speed up CI for PR demo") public void vibebot() throws IOException { String projectName = "vibebot"; File pomFile = FileLocation.of("../vibebot/pom.xml").getFile().getCanonicalFile(); diff --git a/its/ruling/src/test/resources/commons-beanutils/java-S1134.json b/its/ruling/src/test/resources/commons-beanutils/java-S1134.json index 7903ed35965..e61f2bac1ac 100644 --- a/its/ruling/src/test/resources/commons-beanutils/java-S1134.json +++ b/its/ruling/src/test/resources/commons-beanutils/java-S1134.json @@ -1,27 +1,24 @@ { "commons-beanutils:commons-beanutils:src/main/java/org/apache/commons/beanutils2/BasicDynaClass.java": [ -190 +190, +215 ], "commons-beanutils:commons-beanutils:src/main/java/org/apache/commons/beanutils2/BeanUtilsBean.java": [ -213, 425 ], -"commons-beanutils:commons-beanutils:src/main/java/org/apache/commons/beanutils2/DynaClass.java": [ -60 -], "commons-beanutils:commons-beanutils:src/main/java/org/apache/commons/beanutils2/LazyDynaMap.java": [ 247 ], "commons-beanutils:commons-beanutils:src/main/java/org/apache/commons/beanutils2/PropertyUtilsBean.java": [ 345, 702, -722, +719, 886, 980, 999, 1028, 1166, -1182, +1203, 1280, 1296 ], From dd61f767495042b0f8188b39525b3623336a4707 Mon Sep 17 00:00:00 2001 From: Romain Brenguier Date: Fri, 10 Jul 2026 14:38:23 +0200 Subject: [PATCH 3/3] Revert "DO NOT MERGE Introduce some diff for testing." This reverts commit ac526fae7a7388f477a9ab9c808d65e58a80a159. --- .../test/java/org/sonar/java/it/JavaRulingTest.java | 8 -------- .../test/resources/commons-beanutils/java-S1134.json | 11 +++++++---- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/its/ruling/src/test/java/org/sonar/java/it/JavaRulingTest.java b/its/ruling/src/test/java/org/sonar/java/it/JavaRulingTest.java index fb1644f3e7d..41f81ec4652 100644 --- a/its/ruling/src/test/java/org/sonar/java/it/JavaRulingTest.java +++ b/its/ruling/src/test/java/org/sonar/java/it/JavaRulingTest.java @@ -48,7 +48,6 @@ import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.ClassRule; -import org.junit.Ignore; import org.junit.Test; import org.junit.rules.TemporaryFolder; import org.slf4j.Logger; @@ -190,7 +189,6 @@ private static void copyFile(Path source, Path targetDir) { } @Test - @Ignore("Excluded to speed up CI for PR demo") public void spring_mall() throws Exception { String projectName = "mall"; MavenBuild build = test_project("com.macro.mall:mall", projectName); @@ -203,7 +201,6 @@ public void spring_mall() throws Exception { } @Test - @Ignore("Excluded to speed up CI for PR demo") public void guava() throws Exception { String projectName = "guava"; MavenBuild build = test_project("com.google.guava:guava", projectName); @@ -230,7 +227,6 @@ public void apache_commons_beanutils() throws Exception { } @Test - @Ignore("Excluded to speed up CI for PR demo") public void eclipse_jetty_incremental() throws Exception { if (isCommunityEditionTestsOnly()) { return; @@ -350,7 +346,6 @@ private static String getFileLocationAbsolutePath(FileLocation location) { } @Test - @Ignore("Excluded to speed up CI for PR demo") public void sonarqube_server() throws Exception { // sonarqube-6.5/server/sonar-server (v.6.5) String projectName = "sonar-server"; @@ -360,7 +355,6 @@ public void sonarqube_server() throws Exception { } @Test - @Ignore("Excluded to speed up CI for PR demo") public void jboss_ejb3_tutorial() throws Exception { // https://github.com/jbossejb3/jboss-ejb3-tutorial (18/01/2015) String projectName = "jboss-ejb3-tutorial"; @@ -380,7 +374,6 @@ public void jboss_ejb3_tutorial() throws Exception { } @Test - @Ignore("Excluded to speed up CI for PR demo") public void regex_examples() throws IOException { String projectName = "regex-examples"; MavenBuild build = test_project("org.regex-examples:regex-examples", projectName) @@ -392,7 +385,6 @@ public void regex_examples() throws IOException { * Vibe-bot runs this test when testing samples; so it's excluded from the GitHub Actions workflow. */ @Test - @Ignore("Excluded to speed up CI for PR demo") public void vibebot() throws IOException { String projectName = "vibebot"; File pomFile = FileLocation.of("../vibebot/pom.xml").getFile().getCanonicalFile(); diff --git a/its/ruling/src/test/resources/commons-beanutils/java-S1134.json b/its/ruling/src/test/resources/commons-beanutils/java-S1134.json index e61f2bac1ac..7903ed35965 100644 --- a/its/ruling/src/test/resources/commons-beanutils/java-S1134.json +++ b/its/ruling/src/test/resources/commons-beanutils/java-S1134.json @@ -1,24 +1,27 @@ { "commons-beanutils:commons-beanutils:src/main/java/org/apache/commons/beanutils2/BasicDynaClass.java": [ -190, -215 +190 ], "commons-beanutils:commons-beanutils:src/main/java/org/apache/commons/beanutils2/BeanUtilsBean.java": [ +213, 425 ], +"commons-beanutils:commons-beanutils:src/main/java/org/apache/commons/beanutils2/DynaClass.java": [ +60 +], "commons-beanutils:commons-beanutils:src/main/java/org/apache/commons/beanutils2/LazyDynaMap.java": [ 247 ], "commons-beanutils:commons-beanutils:src/main/java/org/apache/commons/beanutils2/PropertyUtilsBean.java": [ 345, 702, -719, +722, 886, 980, 999, 1028, 1166, -1203, +1182, 1280, 1296 ],