Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 46 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@
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
Expand Down Expand Up @@ -117,6 +118,48 @@
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

Check warning on line 137 in .github/workflows/build.yml

View check run for this annotation

SonarQube-Next / SonarQube Code Analysis

Use full commit SHA hash for this dependency.

[S7637] External GitHub Actions and workflows should be pinned to a commit hash See more on https://next.sonarqube.com/sonarqube/project/issues?id=org.sonarsource.java%3Ajava&pullRequest=5762&issues=c7f0eca4-dba4-4ac5-b12c-bf1bb840f69d&open=c7f0eca4-dba4-4ac5-b12c-bf1bb840f69d
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
Expand Down
59 changes: 59 additions & 0 deletions .github/workflows/ruling-diff-comment.yml
Original file line number Diff line number Diff line change
@@ -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

Check warning on line 44 in .github/workflows/ruling-diff-comment.yml

View check run for this annotation

SonarQube-Next / SonarQube Code Analysis

Use full commit SHA hash for this dependency.

[S7637] External GitHub Actions and workflows should be pinned to a commit hash See more on https://next.sonarqube.com/sonarqube/project/issues?id=org.sonarsource.java%3Ajava&pullRequest=5762&issues=b0c96ddf-cdaa-4178-b6a9-2a3b05eda69d&open=b0c96ddf-cdaa-4178-b6a9-2a3b05eda69d
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 }}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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";
Expand All @@ -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";
Expand All @@ -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)
Expand All @@ -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();
Expand Down
11 changes: 4 additions & 7 deletions its/ruling/src/test/resources/commons-beanutils/java-S1134.json
Original file line number Diff line number Diff line change
@@ -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
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"commons-beanutils:commons-beanutils:src/main/java/org/apache/commons/beanutils2/PropertyUtilsBean.java": [
93
]
}
}
32 changes: 0 additions & 32 deletions its/ruling/src/test/resources/commons-beanutils/java-S1488.json

This file was deleted.

1 change: 1 addition & 0 deletions its/ruling/src/test/resources/test-project/java-S1234.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"test:test.java": [42]}
Loading