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

Improved integration tests #72

Merged
merged 53 commits into from
Nov 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
147d83a
Initial commit
dedece35 Mar 9, 2023
a91d8cc
[ISSUE 65] first commit with test files for ecocode java plugin
dedece35 Mar 9, 2023
44728f0
[ISSUE 65] optimization on ArrayCopyCheck class (to limit some useles…
dedece35 Mar 10, 2023
89e9e63
[ISSUE 65] optimization on ArrayCopyCheck class (to limit some useles…
dedece35 Mar 10, 2023
129f981
[ISSUE 65] upgrade README.md
dedece35 Mar 10, 2023
bc5ab7e
add LICENCE.md
dedece35 Mar 11, 2023
d5ca9e9
fix version project
dedece35 Mar 11, 2023
e285b39
Add tool scripts
dedece35 Mar 12, 2023
bfee59a
rename tool sonar
dedece35 Mar 12, 2023
362b8f0
upgrade doc
dedece35 Mar 12, 2023
1e49a9c
upgrade doc
dedece35 Mar 13, 2023
dab4d8b
Update source files
dedece35 Mar 17, 2023
0150479
update source test files
dedece35 Mar 17, 2023
f66a7ec
delete useless tool script
dedece35 Mar 23, 2023
7a2794b
improve shell and doc
Mar 29, 2023
ef0d508
improve shell and doc and gitignor
Mar 29, 2023
152cd89
correction of compile pbs to send to sonar next
Mar 29, 2023
48aacb3
[ISSUE 60] adding test use cases
dedece35 Apr 10, 2023
dfc12d9
[ISSUE 166] correction of wrong message (#9)
dedece35 Apr 12, 2023
78003ec
upgrade authent method for SonarQube
dedece35 Jun 8, 2023
6cf5775
update sonar scanner command
dedece35 Jul 14, 2023
37a343f
[ISSUE 216] upgrade EC2 rule pour Java (multiple If/Else/Elseif)
dedece35 Aug 15, 2023
570f1ac
Merge pull request #10 from green-code-initiative/ISSUE_216_javaMulti…
dedece35 Sep 1, 2023
a8b4dff
[ISSUE 112] add use case file for EC1 streams
dedece35 Dec 1, 2023
9e87447
[ISSUE 112] add use case file for EC1 streams - add header
dedece35 Dec 1, 2023
8ed7e92
[ISSUE 247] add 2 new use cases for switch
dedece35 Dec 3, 2023
827987b
Merge pull request #13 from green-code-initiative/ISSUE_112
dedece35 Dec 4, 2023
e6d317d
Merge branch 'main' into ISSUE_247
dedece35 Dec 4, 2023
f8f65d2
Merge pull request #14 from green-code-initiative/ISSUE_247
dedece35 Dec 4, 2023
5c920ef
[ISSUE 248] Add test to prove ISSUE 248 is already ok
dedece35 Dec 7, 2023
0047ee3
Merge pull request #15 from green-code-initiative/ISSUE_248
dedece35 Dec 15, 2023
5ce922a
[TECH] add comment
dedece35 Jan 17, 2024
89b0be4
delete unsed script for building
dedece35 Jan 19, 2024
c07d9bf
delete unsed script for building
dedece35 Jan 19, 2024
f276d96
docs: :memo: Documentation of changes
alograg Jan 19, 2024
6ada6a8
Merge branch 'main' into t213
alograg Jan 19, 2024
d9cfbd2
EC2 rule : correction NullPointer with interface (no Issue)
dedece35 Jan 22, 2024
c57f877
add new use case from ISSUE 9 of ecoCode-java repository
dedece35 Jan 25, 2024
5e52eb2
Merge pull request #17 from INTM-Group/t213
dedece35 Feb 2, 2024
8d25c52
delete test files because of PR #6 on ecoCode-java repo (deletion of …
dedece35 Feb 2, 2024
c9d40f1
[ISSUE 15] correction NullPointer in EC2
dedece35 Feb 6, 2024
30c1271
Add java rule EC80 : Optimize Database SQL Queries (Clause LIMIT) (#18)
dedece35 Mar 17, 2024
ee0836c
correction of code to be buildable to make an analysis to Sonar
dedece35 May 29, 2024
c025158
update docker port managment
dedece35 Jul 19, 2024
f0eb932
update doc
dedece35 Oct 28, 2024
85cf20a
refactor: Moves resources in dedicated subdirectory to prepare future…
jycr Oct 29, 2024
f0c0802
Merge remote-tracking branch 'ecoCode-java-test-project/main' into main
jycr Oct 29, 2024
fc369b9
Update SonarQube dependencies
jycr Oct 19, 2024
5aec7d6
Adds SonarQube integration tests
jycr Oct 29, 2024
177b20f
Updates documentation and changelog
jycr Oct 29, 2024
8a2dd08
Upgrade Java for Maven build (keep target compilation to Java 11)
jycr Oct 29, 2024
7cd4b19
Remove no longer necessary files
jycr Oct 30, 2024
61e7603
Update compatibility matrix
jycr Oct 30, 2024
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
10 changes: 2 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ jobs:
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis

- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 11
java-version: 17

- name: Cache Maven packages
uses: actions/cache@v3
Expand All @@ -40,12 +40,6 @@ jobs:
- name: Verify
run: ./mvnw -e -B verify

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 17

- name: Cache SonarQube packages
uses: actions/cache@v3
with:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

- [#59](https://github.com/green-code-initiative/ecoCode-java/pull/59) Add builtin profile `ecoCode way` to aggregate all implemented ecoCode rules by this plugin
- [#53](https://github.com/green-code-initiative/ecoCode-java/issues/53) Improve integration tests

### Changed

Expand Down
35 changes: 15 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,34 +26,28 @@ the [ecoCode repository](https://github.com/green-code-initiative/ecoCode#-sonar
🚀 Getting Started
------------------

You can give a try with a one command docker :
You can give a try with a one command:

```sh
docker run -ti --rm \
-p 9000:9000 \
--name sonarqube-ecocode-java ghcr.io/green-code-initiative/sonarqube-ecocode-java:latest
./mvnw verify -Pkeep-running
```

or (with logs and data locally stored) :
... then you can use Java test project repository to test the environment : see [Java test project in `./src/it/test-projects/ecocode-java-plugin-test-project`](./src/it/test-projects/ecocode-java-plugin-test-project)

```sh
docker run -ti --rm \
-v sq_ecocode_logs:/opt/sonarqube/logs \
-v sq_ecocode_data:/opt/sonarqube/data \
-p 9000:9000 \
--name sonarqube-ecocode-java ghcr.io/green-code-initiative/sonarqube-ecocode-java:latest
```
NB: To install other `ecocode` plugins, you can :

... and configure local SonarQube (security config and quality profile : see [configuration](https://github.com/green-code-initiative/ecoCode-common/blob/main/doc/INSTALL.md#configuration-sonarqube) for more details).
- add JAVA System properties `Dtest-it.additional-plugins` with a comma separated list of plugin IDs (`groupId:artifactId:version`), or plugins JAR (`file://....`) to install.

To install other `ecocode` plugins, you can also :
For example :

- download each plugin separatly and copy the plugin (jar file) to `$SONAR_INSTALL_DIR/extensions/plugins` and restart SonarQube.
```sh
./mvnw verify -Pkeep-running -Dtest-it.additional-plugins=org.sonarsource.javascript:sonar-plugin:10.1.0.21143
```
- install different ecocode plugins with Marketplace (inside admin panel of SonarQube)

Then you can use Java test project repository to test the environment : see README.md of [Java test project](https://github.com/green-code-initiative/ecoCode-java-test-project)
You can also directly use a [all-in-one docker-compose](https://github.com/green-code-initiative/ecoCode-common/blob/main/doc/INSTALL.md#start-sonarqube-if-first-time)

Finally, you can directly use a [all-in-one docker-compose](https://github.com/green-code-initiative/ecoCode-common/blob/main/doc/INSTALL.md#start-sonarqube-if-first-time)
... and configure local SonarQube (security config and quality profile : see [configuration](https://github.com/green-code-initiative/ecoCode-common/blob/main/doc/INSTALL.md#configuration-sonarqube) for more details).

🛒 Distribution
------------------
Expand All @@ -63,9 +57,10 @@ Ready to use binaries are available [from GitHub](https://github.com/green-code-
🧩 Compatibility
-----------------

| Plugin version | SonarQube version | Java version |
|----------------|---------------------|--------------|
| 1.6.+ | 9.4.+ LTS to 10.6.0 | 11 / 17 |
| Plugin version | SonarQube version | Java version |
|----------------|---------------------|------------------------------------------------------------------------------------------------|
| 1.6.+ | 9.4.+ LTS to 10.6.0 | 11 / 17 |
| 2.0.+ | 9.9.+ LTS to 10.6.0 | [17](https://docs.sonarsource.com/sonarqube/9.9/requirements/prerequisites-and-overview/#java) |

> Compatibility table of versions lower than 1.4.+ are available from the
> main [ecoCode repository](https://github.com/green-code-initiative/ecoCode#-plugins-version-compatibility).
Expand Down
161 changes: 154 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<groupId>io.ecocode</groupId>
<artifactId>ecocode-java-plugin</artifactId>
<version>1.6.3-SNAPSHOT</version>

<packaging>sonar-plugin</packaging>

<name>ecoCode - Java language</name>
Expand Down Expand Up @@ -53,8 +53,13 @@
<sonar.organization>green-code-initiative</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>

<sonarqube.version>9.4.0.54424</sonarqube.version>
<sonarjava.version>7.19.0.31550</sonarjava.version>
<!-- Version of SonarQube for integration tests -->
<sonarqube.version>9.9.7.96285</sonarqube.version>
jycr marked this conversation as resolved.
Show resolved Hide resolved
<!-- Version of the SonarQube APIs used by `ecocode-java-plugin` -->
<sonar.plugin.api.version>9.8.0.203</sonar.plugin.api.version>

<!-- Version of `sonar-java-plugin` that `ecocode-java-plugin` depends on -->
<sonarjava.version>7.16.0.30901</sonarjava.version>

<sonar-analyzer-commons.version>2.5.0.1358</sonar-analyzer-commons.version>

Expand All @@ -66,9 +71,22 @@

<google.re2j>1.7</google.re2j>

<!-- temporary version waiting for real automatic release in ecocode repository -->
<!-- Version of ecoCode rules specifications implemented by this plugin -->
<ecocode-rules-specifications.version>1.6.5</ecocode-rules-specifications.version>

<!-- URL of the Maven repository where sonarqube will be downloaded -->
<test-it.orchestrator.artifactory.url>https://repo1.maven.org/maven2</test-it.orchestrator.artifactory.url>
<!-- You can override this property to keep SonarQube instance running and to manually use it -->
<test-it.sonarqube.keepRunning>false</test-it.sonarqube.keepRunning>

<!-- Version of `sonarqube` used by integration tests (you can override this value to perform matrix compatibility tests) -->
<test-it.sonarqube.version>${sonarqube.version}</test-it.sonarqube.version>

<!-- Version of `sonar-java-plugin` used by integration tests (you can override this value to perform matrix compatibility tests) -->
<test-it.sonarjava.version>${sonarjava.version}</test-it.sonarjava.version>

<!-- SonarQube server listening port. Leave this property blank to automatically choose an available port. -->
<test-it.sonarqube.port />
</properties>

<dependencies>
Expand All @@ -88,9 +106,9 @@
</dependency>

<dependency>
<groupId>org.sonarsource.sonarqube</groupId>
<groupId>org.sonarsource.api.plugin</groupId>
<artifactId>sonar-plugin-api</artifactId>
<version>${sonarqube.version}</version>
<version>${sonar.plugin.api.version}</version>
<scope>provided</scope>
</dependency>

Expand Down Expand Up @@ -142,6 +160,44 @@
<version>0.10.2</version>
<scope>test</scope>
</dependency>

<!-- Dependencies used by integration tests -->
<dependency>
<groupId>org.sonarsource.orchestrator</groupId>
<artifactId>sonar-orchestrator-junit5</artifactId>
<version>4.9.0.1920</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.sonarsource.java</groupId>
<artifactId>test-classpath-reader</artifactId>
<version>8.5.0.37199</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.sonarsource.sonarqube</groupId>
<artifactId>sonar-ws</artifactId>
<version>${sonarqube.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.github.jycr</groupId>
<artifactId>java-data-url-handler</artifactId>
<version>0.0.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.13</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.5.6</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -333,8 +389,11 @@
<licenseSet>
<header>com/mycila/maven/plugin/license/templates/GPL-3.txt</header>
<includes>
<include>**/*.java</include>
<include>${project.basedir}/src/**/*.java</include>
</includes>
<excludes>
<exclude>${project.basedir}/src/it/test-projects/**</exclude>
</excludes>
</licenseSet>
</licenseSets>
</configuration>
Expand All @@ -348,6 +407,94 @@
</execution>
</executions>
</plugin>
<!-- activate integration tests -->
<plugin>
<!-- add integration test sources into test classpath -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.6.0</version>
<executions>
<execution>
<id>add-integration-test-sources</id>
<phase>process-test-sources</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>${project.basedir}/src/it/java</source>
</sources>
</configuration>
</execution>
<execution>
<id>add-integration-test-resources</id>
<phase>generate-test-resources</phase>
<goals>
<goal>add-test-resource</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>${project.basedir}/src/it/resources</directory>
</resource>
<resource>
<filtering>true</filtering>
<directory>${project.basedir}/src/it/resources-filtered</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<!-- Execute integration tests -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.2.5</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<systemPropertyVariables>
<test-it.sonarqube.keepRunning>${test-it.sonarqube.keepRunning}</test-it.sonarqube.keepRunning>
<test-it.orchestrator.artifactory.url>${test-it.orchestrator.artifactory.url}</test-it.orchestrator.artifactory.url>
<test-it.sonarqube.version>${test-it.sonarqube.version}</test-it.sonarqube.version>
<test-it.sonarqube.port>${test-it.sonarqube.port}</test-it.sonarqube.port>
<!-- Comma separated list of plugins (`groupId|artifactId|version` or `file:///`) to install in SonarQube instance before lunching integration tests -->
<test-it.plugins>
${project.baseUri}/target/${project.artifactId}-${project.version}.jar,
org.sonarsource.java:sonar-java-plugin:${test-it.sonarjava.version},
</test-it.plugins>
<!-- Comma separated JSON profile file URIs to load -->
<test-it.additional-profile-uris>
${project.baseUri}/src/main/resources/fr/greencodeinitiative/java/ecoCode_way_profile.json,
</test-it.additional-profile-uris>
<!-- Comma separated paths of "test projects" to analyze. Syntaxe: `sonar.projectKey|sonar.projectName|project.pomUri` -->
<test-it.test-projects>
io.ecocode:ecocode-java-plugin-test-project|ecoCode Java Sonar Plugin Test Project|${project.baseUri}/src/it/test-projects/ecocode-java-plugin-test-project/pom.xml,
</test-it.test-projects>
<!-- Comma separated list of profiles to associate to each "test project". Syntaxe: `language:profileName` -->
<test-it.test-project-profile-by-language>
java|ecoCode way,
</test-it.test-project-profile-by-language>
</systemPropertyVariables>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>keep-running</id>
<properties>
<test-it.sonarqube.keepRunning>true</test-it.sonarqube.keepRunning>
<test-it.sonarqube.port>9000</test-it.sonarqube.port>
</properties>
</profile>
</profiles>
</project>
Loading
Loading