diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index adc919372bd..50b9d883b5b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -57,9 +57,10 @@ jobs: matrix: item: - { runner: sonar-m-public, profile: without-sonarqube-project, sq_version: LATEST_RELEASE } - - { runner: sonar-m-public, profile: only-sonarqube-project, sq_version: LATEST_RELEASE } - - { runner: github-windows-latest-m, profile: without-sonarqube-project, sq_version: LATEST_RELEASE } - - { runner: github-windows-latest-m, profile: only-sonarqube-project, sq_version: LATEST_RELEASE } + # Temporarily disabled for testing ruling-update-notify action: + # - { runner: sonar-m-public, profile: only-sonarqube-project, sq_version: LATEST_RELEASE } + # - { runner: github-windows-latest-m, profile: without-sonarqube-project, sq_version: LATEST_RELEASE } + # - { runner: github-windows-latest-m, profile: only-sonarqube-project, sq_version: LATEST_RELEASE } name: Ruling QA needs: - build @@ -117,6 +118,48 @@ jobs: expected-dir: src/test/resources actual-dir: target/actual + ruling-update-notify: + name: Ruling Update and Notify + needs: ruling-qa + if: always() && github.event_name == 'pull_request' + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + submodules: recursive + + - name: Install uv + uses: astral-sh/setup-uv@v5 + with: + enable-cache: true + + - name: Check ruling-qa results + id: check-ruling + run: | + # Check if any ruling-qa job failed + # For matrix jobs, needs.ruling-qa.result can be 'success' only if ALL jobs succeeded + RULING_FAILED=false + if [[ "${{ needs.ruling-qa.result }}" != "success" ]]; then + RULING_FAILED=true + fi + echo "ruling-failed=$RULING_FAILED" >> "$GITHUB_OUTPUT" + echo "Ruling QA result: ${{ needs.ruling-qa.result }}, failed=$RULING_FAILED" + + - name: Update ruling and notify + uses: SonarSource/core-languages-tooling-public/ruling-update-and-notify@romain/ruling-sync-PR + with: + pr-number: ${{ github.event.pull_request.number }} + ruling-failed: ${{ steps.check-ruling.outputs.ruling-failed }} + ruling-root: 'its/ruling/src/test/resources' + sources-root: 'its/sources' + env: + GH_TOKEN: ${{ github.token }} + plugin-qa: strategy: fail-fast: false diff --git a/.github/workflows/ruling-diff-comment.yml b/.github/workflows/ruling-diff-comment.yml new file mode 100644 index 00000000000..c436cdc8322 --- /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@v5 + 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@romain/ruling-diff-action + 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 }} 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 ], diff --git a/its/ruling/src/test/resources/commons-beanutils/java-S1448.json b/its/ruling/src/test/resources/commons-beanutils/java-S1448.json index 9beb36ea03f..2fddb4d5525 100644 --- a/its/ruling/src/test/resources/commons-beanutils/java-S1448.json +++ b/its/ruling/src/test/resources/commons-beanutils/java-S1448.json @@ -2,4 +2,4 @@ "commons-beanutils:commons-beanutils:src/main/java/org/apache/commons/beanutils2/PropertyUtilsBean.java": [ 93 ] -} +} \ No newline at end of file diff --git a/its/ruling/src/test/resources/commons-beanutils/java-S1488.json b/its/ruling/src/test/resources/commons-beanutils/java-S1488.json deleted file mode 100644 index 44950c34791..00000000000 --- a/its/ruling/src/test/resources/commons-beanutils/java-S1488.json +++ /dev/null @@ -1,32 +0,0 @@ -{ -"commons-beanutils:commons-beanutils:src/main/java/org/apache/commons/beanutils2/BeanMap.java": [ -766 -], -"commons-beanutils:commons-beanutils:src/main/java/org/apache/commons/beanutils2/PropertyUtilsBean.java": [ -1265 -], -"commons-beanutils:commons-beanutils:src/main/java/org/apache/commons/beanutils2/converters/DateTimeConverter.java": [ -528, -570 -], -"commons-beanutils:commons-beanutils:src/test/java/org/apache/commons/beanutils2/BasicDynaBeanTestCase.java": [ -986 -], -"commons-beanutils:commons-beanutils:src/test/java/org/apache/commons/beanutils2/BeanMapTestCase.java": [ -181, -208, -226 -], -"commons-beanutils:commons-beanutils:src/test/java/org/apache/commons/beanutils2/DynaBeanUtilsTestCase.java": [ -1237 -], -"commons-beanutils:commons-beanutils:src/test/java/org/apache/commons/beanutils2/DynaPropertyUtilsTestCase.java": [ -2614 -], -"commons-beanutils:commons-beanutils:src/test/java/org/apache/commons/beanutils2/bugs/Jira347TestCase.java": [ -150 -], -"commons-beanutils:commons-beanutils:src/test/java/org/apache/commons/beanutils2/memoryleaktests/MemoryLeakTestCase.java": [ -528 -] -} diff --git a/its/ruling/src/test/resources/test-project/java-S1234.json b/its/ruling/src/test/resources/test-project/java-S1234.json new file mode 100644 index 00000000000..b33572d2528 --- /dev/null +++ b/its/ruling/src/test/resources/test-project/java-S1234.json @@ -0,0 +1 @@ +{"test:test.java": [42]}