Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SLE-1000: Embed CFamily analyzer #781

Merged
merged 4 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
88 changes: 85 additions & 3 deletions .cirrus.default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ qa_connectedModeSonarQube_task:
cd its/
mvn -B -e -V org.jacoco:jacoco-maven-plugin:prepare-agent verify \
-s ${HOME}/.m2/settings-public-auth.xml \
-P coverage,\!standaloneMode,\!connectedModeSc \
-P coverage,\!standaloneMode,\!connectedModeSc,\!cdtIntegration \
-Declipse.p2.mirrors=false \
-Dtarget.platform=latest-java-17_e431 \
-Dtycho.localArtifacts=ignore \
Expand Down Expand Up @@ -310,7 +310,7 @@ qa_connectedModeSonarCloud_task:
env SONARCLOUD_IT_PASSWORD=$SONARCLOUD_IT_PASSWORD \
mvn -B -e -V org.jacoco:jacoco-maven-plugin:prepare-agent verify \
-s ${HOME}/.m2/settings-public-auth.xml \
-P coverage,\!standaloneMode,\!connectedModeSq \
-P coverage,\!standaloneMode,\!connectedModeSq,\!cdtIntegration \
-Declipse.p2.mirrors=false \
-Dtarget.platform=latest-java-21 \
-Dtycho.localArtifacts=ignore \
Expand Down Expand Up @@ -389,7 +389,7 @@ qa_standaloneMode_task:
cd its/
mvn -B -e -V org.jacoco:jacoco-maven-plugin:prepare-agent verify \
-s ${HOME}/.m2/settings-public-auth.xml \
-P coverage,\!connectedModeSq,\!connectedModeSc \
-P coverage,\!connectedModeSq,\!connectedModeSc,\!cdtIntegration \
-Declipse.p2.mirrors=false \
-Dtarget.platform=${TARGET_PLATFORM} \
-Dtycho.localArtifacts=ignore \
Expand Down Expand Up @@ -424,6 +424,85 @@ qa_standaloneMode_task:
slack_notification_script: |
source slack-failure-notification "Cirrus CI build failure on pipeline: $CIRRUS_PIPELINE_NAME"

qa_cdtIntegration_task:
# name: "Run ITs for CDT integration"
depends_on:
- build
<<: *ONLY_IF_EXCEPT_NIGHTLY
eks_container:
<<: *BUILDER_CONTAINER_DEFINITION
cpu: 4
memory: 12G
type: m6a.large
env:
ARTIFACTORY_API_KEY: VAULT[development/artifactory/token/${CIRRUS_REPO_OWNER}-${CIRRUS_REPO_NAME}-private-reader access_token]
GITHUB_TOKEN: VAULT[development/github/token/licenses-ro token]
DISPLAY: :10
MAVEN_OPTS: -Xmx3072m
matrix:
- env:
TARGET_PLATFORM: 'oldest-java-11_e48'
- env:
TARGET_PLATFORM: 'latest-java-17_e431'
- env:
TARGET_PLATFORM: 'latest-java-21'
<<: *SETUP_MAVEN_CACHE_QA
download_staged_update_site_script: |
set -euo pipefail
source cirrus-env QA
source .cirrus/set_maven_build_version $BUILD_NUMBER
mvn -B -e -V dependency:unpack \
-Declipse.p2.mirrors=false \
-Dtycho.mode=maven \
-Dartifact=org.sonarsource.sonarlint.eclipse:org.sonarlint.eclipse.site:${PROJECT_VERSION}:zip \
-DoutputDirectory=${CIRRUS_WORKING_DIR}/staged-repository
prepare_background_script: |
set -euo pipefail
/etc/init.d/xvfb start
metacity --sm-disable --replace &
sleep 10 # give metacity some time to start
echo 'Recording tests on video'
ffmpeg -loglevel warning -f x11grab -video_size 1920x1080 -i ${DISPLAY} -codec:v libx264 -r 12 ${CIRRUS_WORKING_DIR}/recording_${TARGET_PLATFORM}.mp4
run_its_script: |
echo "Run Maven ITs for CDT integration on Eclipse '${TARGET_PLATFORM}'"
cd its/
mvn -B -e -V org.jacoco:jacoco-maven-plugin:prepare-agent verify \
-s ${HOME}/.m2/settings-public-auth.xml \
-P coverage,\!standaloneMode,\!connectedModeSq,\!connectedModeSc \
-Declipse.p2.mirrors=false \
-Dtarget.platform=${TARGET_PLATFORM} \
-Dtycho.localArtifacts=ignore \
-Dsonarlint-eclipse.p2.url="file://${CIRRUS_WORKING_DIR}/staged-repository" \
-Djacoco.append=true \
-Djacoco.destFile=${CIRRUS_WORKING_DIR}/it-coverage.exec
mv ${CIRRUS_WORKING_DIR}/it-coverage.exec ${CIRRUS_WORKING_DIR}/it-coverage-cdt-${TARGET_PLATFORM}.exec
cleanup_before_cache_script: cleanup_maven_repository
always:
stop_recording_script: |
pkill -SIGINT -f ffmpeg
while pgrep ffmpeg >/dev/null; do sleep 1; done
/etc/init.d/xvfb stop
test_recording_artifacts:
path: "${CIRRUS_WORKING_DIR}/recording_${TARGET_PLATFORM}.mp4"
jacoco_it_cdt_artifacts:
path: "${CIRRUS_WORKING_DIR}/it-coverage*.exec"
mvn_startTestLog_artifacts:
path: "${CIRRUS_WORKING_DIR}/its/**/target/work/configuration/*.log"
mvn_runTestLog_artifacts:
path: "${CIRRUS_WORKING_DIR}/its/**/target/work/data/.metadata/.log"
on_failure:
xvfb_log_artifacts:
path: "${CIRRUS_WORKING_DIR}/Xvfb.out"
reports_artifacts:
path: "**/reports/**/*"
junit_artifacts:
paths:
- "**/test-results/**/*.xml"
- "**/target/surefire-reports/TEST-*.xml"
format: junit
slack_notification_script: |
source slack-failure-notification "Cirrus CI build failure on pipeline: $CIRRUS_PIPELINE_NAME"

inspect_orchestrator_cache_task:
<<: *ONLY_IF
depends_on: qa_connectedModeSonarQube
Expand All @@ -446,6 +525,7 @@ sonarqube_task:
- qa_connectedModeSonarQube
- qa_connectedModeSonarCloud
- qa_standaloneMode
- qa_cdtIntegration
<<: *ONLY_IF_EXCEPT_NIGHTLY
eks_container:
<<: *BUILDER_CONTAINER_DEFINITION
Expand All @@ -468,10 +548,12 @@ sonarqube_task:
curl --no-progress-meter https://api.cirrus-ci.com/v1/artifact/build/$CIRRUS_BUILD_ID/jacoco_it.zip -o jacoco_it.zip
curl --no-progress-meter https://api.cirrus-ci.com/v1/artifact/build/$CIRRUS_BUILD_ID/jacoco_it_sq.zip -o jacoco_it_sq.zip
curl --no-progress-meter https://api.cirrus-ci.com/v1/artifact/build/$CIRRUS_BUILD_ID/jacoco_it_sc.zip -o jacoco_it_sc.zip
curl --no-progress-meter https://api.cirrus-ci.com/v1/artifact/build/$CIRRUS_BUILD_ID/jacoco_it_cdt.zip -o jacoco_it_cdt.zip
unzip jacoco_ut.zip -d ${CIRRUS_WORKING_DIR}/org.sonarlint.eclipse.core.tests/target/
unzip jacoco_it.zip -d ${CIRRUS_WORKING_DIR}/org.sonarlint.eclipse.core.tests/target/
unzip jacoco_it_sq.zip -d ${CIRRUS_WORKING_DIR}/org.sonarlint.eclipse.core.tests/target/
unzip jacoco_it_sc.zip -d ${CIRRUS_WORKING_DIR}/org.sonarlint.eclipse.core.tests/target/
unzip jacoco_it_cdt.zip -d ${CIRRUS_WORKING_DIR}/org.sonarlint.eclipse.core.tests/target/
source cirrus-env QA
.cirrus/regular_mvn_build_deploy_analyze \
-P-deploy-sonarsource,-release,-sign \
Expand Down
2 changes: 1 addition & 1 deletion .cirrus.ibuilds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ qa_ibuilds_task:
cd its/
mvn -B -e -V verify \
-s ${HOME}/.m2/settings-public-auth.xml \
-P \!connectedModeSq,\!connectedModeSc \
-P \!connectedModeSq,\!connectedModeSc,\!cdtIntegration \
-Declipse.p2.mirrors=false \
-Dtarget.platform=ibuilds \
-Dtycho.localArtifacts=ignore \
Expand Down
4 changes: 3 additions & 1 deletion NOTICE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ mailto:info AT sonarsource DOT com

This program is distributed with SonarQube analyzers that are subject to specific license terms.

All of the analyzers distributed with this program are published under the terms of the Sonar Source-Available License Version 1, as published by SonarSource SA. For more details see https://sonarsource.com/license/ssal/
The sonar-cfamily-plugin is a SonarQube analyzer published under the following proprietary license: SonarSource SA grants you a non-transferable, non-sublicensable, limited license to use the aforementioned plugins solely as part of this program. Any use, reproduction, distribution, or modification of the plugins outside the scope of this program is strictly prohibited.

All of the other analyzers distributed with this program are published under the terms of the Sonar Source-Available License Version 1, as published by SonarSource SA. For more details see https://sonarsource.com/license/ssal/
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Normally, m2e will automatically suggest to install missing connectors (Tycho co
missing lifecycle mappings. This can all be done later.

1. Run `mvn clean verify -DskipTests` on the command line to fetch artifacts referenced in the parent pom
- for forks use `-Dskip-sonarsource-repo` as the reference to the CFamily analyzer is not available on Maven Central
2. In Eclipse, import the project root as a Maven project
3. In Eclipse, import the project root of the ITs as a Maven project and add them to the main project
4. Open `target-platforms/dev.target` with the target platform editor
Expand Down Expand Up @@ -69,6 +70,8 @@ With Maven:

mvn clean verify

- for forks use `-Dskip-sonarsource-repo` as the reference to the CFamily analyzer is not available on Maven Central

Running ITs
-----------

Expand Down
76 changes: 46 additions & 30 deletions its/README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# SonarLint for Eclipse: Integration tests
# SonarQube for Eclipse: Integration tests

This project including its modules contains the integration tests (including compatibility against
[iBuilds](https://download.eclipse.org/eclipse/downloads/), the in-development version of the Eclipse IDE) for
SonarLint that are relying on [Eclipse RedDeer](https://github.com/eclipse/reddeer) as the test framework connected
SonarQube that are relying on [Eclipse RedDeer](https://github.com/eclipse/reddeer) as the test framework connected
to [Eclipse Tycho](https://github.com/eclipse-tycho/tycho).

The tests are split into separate modules for testing in Standalone Mode only, in Connected Mode with SonarQube and
SonarCloud. Additionally, one module is used for shared logic. This Maven/Tycho project is completely decoupled from
the main SonarLint for Eclipse project.
The tests are split into separate modules for testing in Standalone Mode only, with the integration into CDT (which is
also in Standalone Mode), in Connected Mode with SonarQube Server and SonarQube Cloud. Additionally, one module is used
for shared logic. This Maven/Tycho project is completely decoupled from the main SonarQube for Eclipse project.

## Building

In order to build the integration tests, the main SonarLint for Eclipse project must be build first to create the
In order to build the integration tests, the main SonarQube for Eclipse project must be build first to create the
Eclipse Update Site. On the CI/CD pipeline this is not done in one step, but locally it has to be done.

The target platform provided must be one of the supported in the `target-platforms` folder inside the main SonarLint
The target platform provided must be one of the supported in the `target-platforms` folder inside the main SonarQube
for Eclipse project directory.

```
Expand All @@ -25,7 +25,7 @@ mvn clean verify -Dtarget.platform=latest-java-17_e431 -Dtycho.localArtifacts=ig
```

When all the projects are opened inside Eclipse and the target platform correctly configured, this is done in the
background (not for the main SonarLint for Eclipse project tho if not also imported into Eclipse, which is required).
background (not for the main SonarQube for Eclipse project tho if not also imported into Eclipse, which is required).

## Running the Tests

Expand All @@ -37,48 +37,64 @@ instance.
### Standalone Mode / iBuilds compatibility

To run all the tests, or a specific one with the additionally command line option `-Dtest={TestClassName}`, for the
Standalone Mode, the following command has to be run that excludes the tests for the Connected Mode with SonarQube and
SonarCloud.
Standalone Mode, the following command has to be run that excludes the tests for the Connected Mode with SonarQube
Server and SonarQube Cloud and the integration into CDT.

The target platform provided must be one of the supported in the `target-platforms` folder inside the main SonarLint
The target platform provided must be one of the supported in the `target-platforms` folder inside the main SonarQube
for Eclipse project directory. For Standalone Mode all target platforms are useful, for the iBuilds compatibility the
`ibuilds` target platform must be used.

```
mvn clean verify -Dtarget.platform=latest-java-17_e431 -Dtycho.localArtifacts=ignore -Dsonarlint-eclipse.p2.url="file://{path to repo}/org.sonarlint.eclipse.site/target/repository" -P \!connectedModeSc,\!connectedModeSq
mvn clean verify -Dtarget.platform=latest-java-17_e431 -Dtycho.localArtifacts=ignore -Dsonarlint-eclipse.p2.url="file://{path to repo}/org.sonarlint.eclipse.site/target/repository" -P \!connectedModeSc,\!connectedModeSq,\!cdtIntegration
```

### Connected Mode (SQ)
### Connected Mode (SonarQube Server)

To run all the tests, or a specific one with the additionally command line option `-Dtest={TestClassName}`, for the
Connected Mode with SonarQube, the following command has to be run that excludes the tests for the Standalone Mode and
the Connected Mode with SonarCloud. With the additional command line option `-Dsonar.runtimeVersion={version alias}`
(see [Orchestrator documentation](https://github.com/SonarSource/orchestrator?tab=readme-ov-file#version-aliases)) the
specific SonarQube version can be configured, the default one is `LATEST_RELEASE`.
Connected Mode with SonarQube Server, the following command has to be run that excludes the tests for the Standalone
Mode and the Connected Mode with SonarQube Cloud and the integration into CDT. With the additional command line option
`-Dsonar.runtimeVersion={version alias}` (see
[Orchestrator documentation](https://github.com/SonarSource/orchestrator?tab=readme-ov-file#version-aliases)) the
specific SonarQube Server version can be configured, the default one is `LATEST_RELEASE`.

The target platform provided should be run against the latest one linked to the Eclipse IDE that is shipped with Java
17 (Eclipse IDE 2024-03 / 4.31). This is also what the CI/CD pipeline is doing in order to provide the correct runtime
for the SonarQube instance provided via [Orchestrator](https://github.com/SonarSource/orchestrator) for the latest
supported LTA version, the latest supported version and the currently in-development version (of SonarQube).
for the SonarQube Server instance provided via [Orchestrator](https://github.com/SonarSource/orchestrator) for the
latest supported LTA version, the latest supported version and the currently in-development version (of SonarQube
Server).

```
mvn clean verify -Dtarget.platform=latest-java-17_e431 -Dtycho.localArtifacts=ignore -Dsonarlint-eclipse.p2.url="file://{path to repo}/org.sonarlint.eclipse.site/target/repository" -P \!standaloneMode,\!connectedModeSc
mvn clean verify -Dtarget.platform=latest-java-17_e431 -Dtycho.localArtifacts=ignore -Dsonarlint-eclipse.p2.url="file://{path to repo}/org.sonarlint.eclipse.site/target/repository" -P \!standaloneMode,\!connectedModeSc,\!cdtIntegration
```

### Connected Mode (SC)
### Connected Mode (SonarQube Cloud)

To run all the tests, or a specific one with the additionally command line option `-Dtest={TestClassName}`, for the
Connected Mode with SonarCloud, the following command has to be run that excludes the tests for the Standalone Mode and
the Connected Mode with SonarQube.
Connected Mode with SonarQube Cloud, the following command has to be run that excludes the tests for the Standalone
Mode and the Connected Mode with SonarQube Server and the integration into CDT.

The target platform provided must be one of the supported in the `target-platforms` folder inside the main SonarLint
for Eclipse project directory. Compared to the integration tests for the Connected Mode with SonarCloud there is no
dependency on the Java version and the CI/CD pipeline will run against the latest one linked to the Eclipse IDE that is
shipped with Java 21 (the current Java runtime used for upcoming releases as well).
The target platform provided must be one of the supported in the `target-platforms` folder inside the main SonarQube
for Eclipse project directory. Compared to the integration tests for the Connected Mode with SonarQube Cloud there is
no dependency on the Java version and the CI/CD pipeline will run against the latest one linked to the Eclipse IDE that
is shipped with Java 21 (the current Java runtime used for upcoming releases as well).

Due to us requiring the password for the SonarCloud staging environment, we have to pass it directly to the command as
the Eclipse IDE runtime won't pick it up otherwise via `System.getenv("SONARCLOUD_IT_PASSWORD")`!
Due to us requiring the password for the SonarQube Cloud staging environment, we have to pass it directly to the
command as the Eclipse IDE runtime won't pick it up otherwise via `System.getenv("SONARCLOUD_IT_PASSWORD")`!

```
env SONARCLOUD_IT_PASSWORD=$SONARCLOUD_IT_PASSWORD mvn clean verify -Dtarget.platform=latest-java-21 -Dtycho.localArtifacts=ignore -Dsonarlint-eclipse.p2.url="file://{path to repo}/org.sonarlint.eclipse.site/target/repository" -P \!standaloneMode,\!connectedModeSq
env SONARCLOUD_IT_PASSWORD=$SONARCLOUD_IT_PASSWORD mvn clean verify -Dtarget.platform=latest-java-21 -Dtycho.localArtifacts=ignore -Dsonarlint-eclipse.p2.url="file://{path to repo}/org.sonarlint.eclipse.site/target/repository" -P \!standaloneMode,\!connectedModeSq,\!cdtIntegration
```

### CDT integration

To run all the tests, or a specific one with the additionally command line option `-Dtest={TestClassName}`, for the
integration into CDT, the following command has to be run that excludes the tests for the Standalone
Mode and the Connected Mode with SonarQube Server and the Connected Mode with SonarQube Cloud.

The target platform provided must be one of the supported in the `target-platforms` folder inside the main SonarQube
for Eclipse project directory. For the integration into CDT, all target platforms are useful, for the iBuilds
compatibility the `ibuilds` target platform must be used.

```
mvn clean verify -Dtarget.platform=latest-java-17_e431 -Dtycho.localArtifacts=ignore -Dsonarlint-eclipse.p2.url="file://{path to repo}/org.sonarlint.eclipse.site/target/repository" -P \!standaloneMode,\!connectedModeSc,\!connectedModeSq
```
47 changes: 47 additions & 0 deletions its/org.sonarlint.eclipse.its.cdt/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: SonarLint for Eclipse ITs (CDT integration)
Bundle-SymbolicName: org.sonarlint.eclipse.its.cdt;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-ClassPath: .
Bundle-Vendor: SonarSource
Require-Bundle: org.eclipse.jdt.core,
org.eclipse.jdt.ui,
org.eclipse.debug.core,
org.eclipse.jdt.launching,
org.eclipse.jface,
org.eclipse.jface.text,
org.eclipse.ui.workbench,
org.eclipse.ui,
org.eclipse.ui.ide,
org.eclipse.core.runtime,
org.eclipse.core.resources,
org.eclipse.swt,
org.eclipse.ui.forms,
org.eclipse.search,
org.eclipse.ui.editors,
org.junit;bundle-version="4.11.0",
org.eclipse.equinox.security,
org.eclipse.ui.console,
assertj-core,
org.eclipse.reddeer.junit,
org.eclipse.reddeer.requirements,
org.eclipse.reddeer.eclipse,
org.eclipse.reddeer.swt,
org.eclipse.reddeer.common,
org.eclipse.reddeer.workbench.core,
org.eclipse.reddeer.workbench,
org.eclipse.reddeer.jface,
org.eclipse.reddeer.core,
com.google.gson;bundle-version="2.9.1",
org.apache.commons.commons-io;bundle-version="2.16.1",
org.awaitility;bundle-version="4.2.2",
org.hamcrest;bundle-version="2.2.0",
minimal-json;bundle-version="0.9.5",
org.apache.commons.exec;bundle-version="1.3.0",
com.google.protobuf;bundle-version="3.25.1",
org.sonarlint.eclipse.its.shared
Import-Package: org.sonarlint.eclipse.ui.internal.views.issues
Bundle-RequiredExecutionEnvironment: JavaSE-11
Bundle-ActivationPolicy: lazy
Export-Package: org.sonarlint.eclipse.its.cdt
4 changes: 4 additions & 0 deletions its/org.sonarlint.eclipse.its.cdt/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source.. = src/
output.. = target/classes/
bin.includes = META-INF/,\
.
Loading
Loading