Skip to content

Commit

Permalink
chore: update to latest IJ and bump to gradle 8.5 (#648)
Browse files Browse the repository at this point in the history
* chore: update to latest IJ

fix sonar coverage to include integration tests

Signed-off-by: Stephane Bouchet <[email protected]>

* chore: update to latest IJ

added version in validation, too

Signed-off-by: Stephane Bouchet <[email protected]>

* chore: update to latest IJ

fix gradle-wrapper.jar

Signed-off-by: Stephane Bouchet <[email protected]>

---------

Signed-off-by: Stephane Bouchet <[email protected]>
  • Loading branch information
sbouchet authored Dec 13, 2023
1 parent 6f7dc66 commit a6778e1
Show file tree
Hide file tree
Showing 12 changed files with 100 additions and 120 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/sonar.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Sonar
on:
workflow_run:
workflows: ["Java CI with Gradle"]
workflows: [ "Play Integration Tests" ]
types:
- completed
jobs:
Expand Down Expand Up @@ -61,8 +61,8 @@ jobs:
PR_NUMBER=$(<build/PR)
BASE_REF=$(<build/base_ref)
HEAD_REF=$(<build/head_ref)
./gradlew sonarqube -Dsonar.pullrequest.base=$BASE_REF -Dsonar.pullrequest.branch=$HEAD_REF -Dsonar.pullrequest.key=$PR_NUMBER -Dsonar.pullrequest.provider=GitHub -Dsonar.pullrequest.github.repository=${{github.repository}}
./gradlew sonar -Dsonar.pullrequest.base=$BASE_REF -Dsonar.pullrequest.branch=$HEAD_REF -Dsonar.pullrequest.key=$PR_NUMBER -Dsonar.pullrequest.provider=GitHub -Dsonar.pullrequest.github.repository=${{github.repository}}
else
./gradlew sonarqube
./gradlew sonar
fi
shell: bash
2 changes: 1 addition & 1 deletion .github/workflows/validate_IJ_versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
IJ: [ IU-2022.1, IU-2022.2, IU-2022.3, IU-2023.1, IU-2023.2 ]
IJ: [ IU-2022.1, IU-2022.2, IU-2022.3, IU-2023.1, IU-2023.2, IU-2023.3 ]

steps:
- name: Checkout Code
Expand Down
18 changes: 13 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ buildscript {
ext.sinceIdeaBuild = 0
}

if (ext.sinceIdeaBuild >= 223) {
if (ext.sinceIdeaBuild.toInteger() >= 223) {
ext.java_version = "17"
} else {
ext.java_version = "11"
}
}

plugins {
id 'org.jetbrains.intellij' version '1.16.0'
id 'org.jetbrains.intellij' version '1.16.1'
id 'com.adarshr.test-logger' version '3.2.0'
id 'idea'
id 'java'
Expand Down Expand Up @@ -115,6 +115,10 @@ tasks.register('integrationTest', Test) {
showFullStackTraces true
}
jvmArgs "-Djava.awt.headless=true"
jacoco {
includeNoLocationClasses = true
excludes = ["jdk.internal.*"]
}
}

tasks.register('integrationUITest', Test) {
Expand All @@ -135,6 +139,10 @@ tasks.register('integrationUITest', Test) {
showFullStackTraces true
}
jvmArgs "-Djava.awt.headless=true"
jacoco {
includeNoLocationClasses = true
excludes = ["jdk.internal.*"]
}
}

dependencies {
Expand Down Expand Up @@ -176,18 +184,18 @@ dependencies {
}
}

sonarqube {
sonar {
properties {
property "sonar.projectKey", "redhat-developer_intellij-openshift-connector"
property "sonar.organization", "redhat-developer"
property "sonar.host.url", "https://sonarcloud.io"
property "sonar.junit.reportsPath", "$buildDir/test-results/"
property "sonar.junit.reportsPath", layout.buildDirectory.dir("test-results").get().asFile.absolutePath
property "sonar.gradle.skipCompile", "true"
}
}

jacocoTestReport {
getExecutionData().setFrom(fileTree(buildDir).include("/jacoco/*.exec"))
getExecutionData().setFrom(fileTree(layout.buildDirectory).include("/jacoco/*.exec"))
reports {
xml.required = true
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ideaVersion=IU-2023.2
ideaVersion=IU-2023.3
projectVersion=1.8.0-SNAPSHOT
jetBrainsToken=invalid
jetBrainsChannel=stable
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
29 changes: 17 additions & 12 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -133,26 +131,29 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -197,11 +198,15 @@ if "$cygwin" || "$msys" ; then
done
fi

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,12 @@
******************************************************************************/
package org.jboss.tools.intellij.openshift.utils.odo;

import org.junit.Test;

import java.io.IOException;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;

import static org.awaitility.Awaitility.with;
import static org.junit.Assert.assertTrue;

public class OdoCliCatalogTest extends OdoCliTest {

Expand All @@ -27,7 +24,7 @@ public void testCheckGetComponentTypes() throws IOException, ExecutionException,
try {
createProject(project);
List<DevfileComponentType> components = odo.getComponentTypes();
assertTrue(components.size() > 0);
assertFalse(components.isEmpty());
} finally {
odo.deleteProject(project);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import com.redhat.devtools.intellij.common.utils.ExecHelper;
import org.fest.util.Files;
import org.junit.After;
import org.junit.Assume;
import org.junit.Before;
import org.junit.Ignore;
Expand All @@ -27,7 +28,6 @@
import java.util.concurrent.ExecutionException;

import static org.jboss.tools.intellij.openshift.Constants.DebugStatus;
import static org.junit.Assert.*;

@RunWith(Parameterized.class)
public class OdoCliComponentTest extends OdoCliTest {
Expand All @@ -36,6 +36,8 @@ public class OdoCliComponentTest extends OdoCliTest {
private String component;
private String service;

private final boolean projectCreationSkipped = true;

public OdoCliComponentTest(ComponentFeature feature) {
this.feature = feature;
}
Expand All @@ -52,113 +54,94 @@ public void initTestEnv() {
service = SERVICE_PREFIX + random.nextInt();
}

@Test
public void checkCreateComponent() throws IOException, ExecutionException, InterruptedException {
try {
createComponent(project, component, feature);
List<Component> components = odo.getComponents(project);
assertNotNull(components);
assertEquals(feature == ComponentFeature.DEV? 1 : 0, components.size());
} finally {
@After
public void cleanUp() throws IOException {
if (odo.isStarted(project, COMPONENT_PATH, component, ComponentFeature.DEV)) {
odo.stop(project, COMPONENT_PATH, component, ComponentFeature.DEV);
}
if (project.equals(odo.getCurrentNamespace())) {
odo.deleteProject(project);
}
}

@Test
public void checkCreateComponent() throws IOException, ExecutionException, InterruptedException {
createComponent(project, component, feature);
List<Component> components = odo.getComponents(project);
assertNotNull(components);
assertEquals(feature == ComponentFeature.DEV ? 1 : 0, components.size());
}

@Test
public void checkCreateAndDiscoverComponent() throws IOException, ExecutionException, InterruptedException {
try {
createComponent(project, component, feature);
List<ComponentDescriptor> components = odo.discover(COMPONENT_PATH);
assertNotNull(components);
assertEquals(1, components.size());
assertEquals(new File(COMPONENT_PATH).getAbsolutePath(), components.get(0).getPath());
assertEquals(component, components.get(0).getName());
} finally {
odo.deleteProject(project);
}
createComponent(project, component, feature);
List<ComponentDescriptor> components = odo.discover(COMPONENT_PATH);
assertNotNull(components);
assertEquals(1, components.size());
assertEquals(new File(COMPONENT_PATH).getAbsolutePath(), components.get(0).getPath());
assertEquals(component, components.get(0).getName());
}

@Test
public void checkCreateAndDeleteComponent() throws IOException, ExecutionException, InterruptedException {
try {
createComponent(project, component, feature);
odo.deleteComponent(project, COMPONENT_PATH, component, ComponentKind.DEVFILE);
} finally {
odo.deleteProject(project);
}
createComponent(project, component, feature);
odo.deleteComponent(project, COMPONENT_PATH, component, ComponentKind.DEVFILE);
}

@Test
@Ignore
public void checkCreateComponentAndLinkService() throws IOException, ExecutionException, InterruptedException {
Assume.assumeTrue(feature != null);
try {
createComponent(project, component, feature);
ServiceTemplate serviceTemplate = getServiceTemplate();
OperatorCRD crd = getOperatorCRD(serviceTemplate);
odo.createService(project, serviceTemplate, crd, service, null, true);
List<Service> deployedServices = odo.getServices(project);
assertNotNull(deployedServices);
assertEquals(1, deployedServices.size());
Service deployedService = deployedServices.get(0);
assertNotNull(deployedService);
Binding binding = odo.link(project, COMPONENT_PATH, component, deployedService.getKind() + "/" + deployedService.getName());
} finally {
odo.deleteProject(project);
}
createComponent(project, component, feature);
ServiceTemplate serviceTemplate = getServiceTemplate();
OperatorCRD crd = getOperatorCRD(serviceTemplate);
odo.createService(project, serviceTemplate, crd, service, null, true);
List<Service> deployedServices = odo.getServices(project);
assertNotNull(deployedServices);
assertEquals(1, deployedServices.size());
Service deployedService = deployedServices.get(0);
assertNotNull(deployedService);
Binding binding = odo.link(project, COMPONENT_PATH, component, deployedService.getKind() + "/" + deployedService.getName());
assertNotNull(binding);
}

@Test
public void checkCreateComponentAndListURLs() throws IOException, ExecutionException, InterruptedException {
Assume.assumeTrue(feature != null);
try {
createComponent(project, component, feature);
List<URL> urls = odo.listURLs(project, COMPONENT_PATH, component);
assertEquals(1, urls.size());
} finally {
odo.deleteProject(project);
}
createComponent(project, component, feature);
List<URL> urls = odo.listURLs(project, COMPONENT_PATH, component);
assertEquals(1, urls.size());
}

@Test
public void checkCreateComponentAndDebug() throws IOException, ExecutionException, InterruptedException {
Assume.assumeTrue(feature != null);
try {
createComponent(project, component, feature);
odo.start(project, COMPONENT_PATH, component, ComponentFeature.DEV, null, null);
List<URL> urls = odo.listURLs(project, COMPONENT_PATH, component);
assertEquals(odo.isOpenShift() ? 2 : 1, urls.size());
int debugPort;
try (ServerSocket serverSocket = new ServerSocket(0)) {
debugPort = serverSocket.getLocalPort();
}
ExecHelper.submit(() -> {
try {
odo.debug(project, COMPONENT_PATH, component, debugPort);
DebugStatus status = odo.debugStatus(project, COMPONENT_PATH, component);
assertEquals(DebugStatus.RUNNING, status);
} catch (IOException e) {
fail("Should not raise Exception");
}
});

} finally {
odo.deleteProject(project);
createComponent(project, component, feature);
odo.start(project, COMPONENT_PATH, component, ComponentFeature.DEV, null, null);
List<URL> urls = odo.listURLs(project, COMPONENT_PATH, component);
assertEquals(odo.isOpenShift() ? 2 : 1, urls.size());
int debugPort;
try (ServerSocket serverSocket = new ServerSocket(0)) {
debugPort = serverSocket.getLocalPort();
}
ExecHelper.submit(() -> {
try {
odo.debug(project, COMPONENT_PATH, component, debugPort);
DebugStatus status = odo.debugStatus(project, COMPONENT_PATH, component);
assertEquals(DebugStatus.RUNNING, status);
} catch (IOException e) {
fail("Should not raise Exception");
}
});
}

@Test
public void checkCreateComponentStarter() throws IOException, ExecutionException, InterruptedException {
try {
createProject(project);
odo.createComponent(project, "java-springboot", REGISTRY_NAME, component,
Files.newTemporaryFolder().getAbsolutePath(), null, "springbootproject");
List<Component> components = odo.getComponents(project);
assertNotNull(components);
assertEquals(0, components.size());
} finally {
odo.deleteProject(project);
}
createProject(project);
odo.createComponent(project, "java-springboot", REGISTRY_NAME, component,
Files.newTemporaryFolder().getAbsolutePath(), null, "springbootproject");
List<Component> components = odo.getComponents(project);
assertNotNull(components);
assertEquals(0, components.size());
}
}
Loading

0 comments on commit a6778e1

Please sign in to comment.