Skip to content

Commit

Permalink
Remove warningMessages
Browse files Browse the repository at this point in the history
  • Loading branch information
basil committed Jan 31, 2023
1 parent 2db71d8 commit 7d10076
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 67 deletions.
8 changes: 2 additions & 6 deletions src/main/java/org/jenkins/tools/test/PluginCompatTester.java
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,6 @@ public PluginCompatReport testPlugins()
continue; // Don't do anything : we are in the cached interval ! :-)
}

List<String> warningMessages = new ArrayList<>();
Set<String> testDetails = new TreeSet<>();
if (errorMessage == null) {
try {
Expand All @@ -286,7 +285,6 @@ public PluginCompatReport testPlugins()
} else {
status = TestStatus.TEST_FAILURES;
}
warningMessages.addAll(result.pomWarningMessages);
testDetails.addAll(config.isStoreAll() ? result.getTestDetails().getAll() : result.getTestDetails().hasFailures() ? result.getTestDetails().getFailed() : Collections.emptySet());
} catch (PomExecutionException e) {
if(!e.succeededPluginArtifactIds.contains("maven-compiler-plugin")){
Expand All @@ -299,7 +297,6 @@ public PluginCompatReport testPlugins()
status = TestStatus.INTERNAL_ERROR;
}
errorMessage = e.getErrorMessage();
warningMessages.addAll(e.getPomWarningMessages());
testDetails.addAll(config.isStoreAll() ? e.getTestDetails().getAll() : e.getTestDetails().hasFailures() ? e.getTestDetails().getFailed() : Collections.emptySet());
} catch (Error e){
// Rethrow the error ... something is wrong !
Expand All @@ -323,7 +320,7 @@ public PluginCompatReport testPlugins()
actualCoreCoordinates = new MavenCoordinates(actualCoreCoordinates.groupId, actualCoreCoordinates.artifactId, solveVersionFromModel(new MavenBom(config.getBom()).getModel()));
}

PluginCompatResult result = new PluginCompatResult(actualCoreCoordinates, status, errorMessage, warningMessages, testDetails, buildLogFilePath);
PluginCompatResult result = new PluginCompatResult(actualCoreCoordinates, status, errorMessage, testDetails, buildLogFilePath);
report.add(pluginInfos, result);

if(config.reportFile != null){
Expand Down Expand Up @@ -525,11 +522,10 @@ private TestExecutionResult testPluginAgainst(MavenCoordinates coreCoordinates,

// Execute with tests
runner.run(mconfig, pluginCheckoutDir, buildLogFile, args.toArray(new String[0]));
return new TestExecutionResult(((PomData)forExecutionHooks.get("pomData")).getWarningMessages(), new ExecutedTestNamesSolver().solve(types, runner.getExecutedTests(), pluginCheckoutDir));
return new TestExecutionResult(new ExecutedTestNamesSolver().solve(types, runner.getExecutedTests(), pluginCheckoutDir));
} catch (ExecutedTestNamesSolverException e) {
throw new PomExecutionException(e);
} catch (PomExecutionException e){
e.getPomWarningMessages().addAll(pomData.getWarningMessages());
if (ranCompile) {
// So the status cannot be considered COMPILATION_ERROR
e.succeededPluginArtifactIds.add("maven-compiler-plugin");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,20 @@
public class PomExecutionException extends Exception {
private final List<Throwable> exceptionsThrown;
public final List<String> succeededPluginArtifactIds;
private final List<String> pomWarningMessages;
private final ExecutedTestNamesDetails testDetails;

public PomExecutionException(Throwable cause) {
this(cause.toString(), Collections.emptyList(), List.of(cause), Collections.emptyList(), new ExecutedTestNamesDetails());
this(cause.toString(), Collections.emptyList(), List.of(cause), new ExecutedTestNamesDetails());
}

public PomExecutionException(PomExecutionException exceptionToCopy){
this(exceptionToCopy.getMessage(), exceptionToCopy.succeededPluginArtifactIds, exceptionToCopy.exceptionsThrown, exceptionToCopy.pomWarningMessages, exceptionToCopy.testDetails);
this(exceptionToCopy.getMessage(), exceptionToCopy.succeededPluginArtifactIds, exceptionToCopy.exceptionsThrown, exceptionToCopy.testDetails);
}

public PomExecutionException(String message, List<String> succeededPluginArtifactIds, List<Throwable> exceptionsThrown, List<String> pomWarningMessages, ExecutedTestNamesDetails testDetails){
public PomExecutionException(String message, List<String> succeededPluginArtifactIds, List<Throwable> exceptionsThrown, ExecutedTestNamesDetails testDetails){
super(message, exceptionsThrown.isEmpty() ? null : exceptionsThrown.iterator().next());
this.exceptionsThrown = new ArrayList<>(exceptionsThrown);
this.succeededPluginArtifactIds = new ArrayList<>(succeededPluginArtifactIds);
this.pomWarningMessages = new ArrayList<>(pomWarningMessages);
this.testDetails = testDetails;
}

Expand All @@ -74,10 +72,6 @@ public String getErrorMessage(){
return strBldr.toString();
}

public List<String> getPomWarningMessages() {
return pomWarningMessages;
}

public ExecutedTestNamesDetails getTestDetails() {
return testDetails;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.Map;
import org.jenkins.tools.test.model.TestExecutionResult;
import org.jenkins.tools.test.model.hook.PluginCompatTesterHookBeforeCheckout;
import org.jenkins.tools.test.util.ExecutedTestNamesDetails;

/**
* Short circuit running any UI plugins that function as a helper methods. These are installed as
Expand Down Expand Up @@ -34,7 +35,7 @@ public List<String> transformedPlugins() {
@Override
public Map<String, Object> action(Map<String, Object> moreInfo) {
moreInfo.put("executionResult",
new TestExecutionResult(List.of("Plugin unsupported at this time, skipping")));
new TestExecutionResult(new ExecutedTestNamesDetails()));
moreInfo.put("runCheckout", false);
return moreInfo;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public void run(Config config, File baseDirectory, File buildLogFile, String...
}
if (p.waitFor() != 0) {
throw new PomExecutionException(cmd + " failed in " + baseDirectory, succeededPluginArtifactIds,
/* TODO */Collections.emptyList(), Collections.emptyList(),
/* TODO */Collections.emptyList(),
new ExecutedTestNamesSolver().solve(getTypes(config), getExecutedTests(), baseDirectory));
}
} catch (PomExecutionException x) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,6 @@ public String toString(){
return "MavenCoordinates[groupId="+groupId+", artifactId="+artifactId+", version="+version+"]";
}

public String toGAV(){
return groupId+":"+artifactId+":"+version;
}

public static MavenCoordinates fromGAV(String gav){
String[] chunks = gav.split(":");
return new MavenCoordinates(chunks[0], chunks[1], chunks[2]);
}

@Override
public int compareTo(MavenCoordinates o) {
if((groupId+":"+artifactId).equals(o.groupId+":"+o.artifactId)){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,27 +43,25 @@ public class PluginCompatResult implements Comparable<PluginCompatResult> {
public final Date compatTestExecutedOn;

public final String errorMessage;
public final List<String> warningMessages;

private final Set<String> testDetails;

private String buildLogPath = "";

public PluginCompatResult(MavenCoordinates coreCoordinates, TestStatus status,
String errorMessage, List<String> warningMessages, Set<String> testDetails,
String errorMessage, Set<String> testDetails,
String buildLogPath){
// Create new result with current date
this(coreCoordinates, status, errorMessage, warningMessages, testDetails, buildLogPath, new Date());
this(coreCoordinates, status, errorMessage, testDetails, buildLogPath, new Date());
}
private PluginCompatResult(MavenCoordinates coreCoordinates, TestStatus status,
String errorMessage, List<String> warningMessages, Set<String> testDetails,
String errorMessage, Set<String> testDetails,
String buildLogPath, Date compatTestExecutedOn){
this.coreCoordinates = coreCoordinates;

this.status = status;

this.errorMessage = errorMessage;
this.warningMessages = warningMessages;

this.testDetails = testDetails;
this.buildLogPath = buildLogPath;
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/org/jenkins/tools/test/model/PluginRemoting.java
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,15 @@ public static void computeScmConnection(PomData pomData) {
if(transformedConnectionUrl.isEmpty()){
transformedConnectionUrl = "scm:git:git://github.com/jenkinsci/"+pomData.artifactId.replaceAll("jenkins", "")+"-plugin.git";
if(!oldUrl.equals(transformedConnectionUrl)){
pomData.getWarningMessages().add("project.scm.connectionUrl is not present in plugin's pom .. isn't it residing somewhere on a parent pom ?");
LOGGER.log(Level.WARNING, "project.scm.connectionUrl is not present in plugin's pom .. isn't it residing somewhere on a parent pom ?");
}
}

// Java.net SVN migration
oldUrl = transformedConnectionUrl;
transformedConnectionUrl = transformedConnectionUrl.replaceAll("(svn|hudson)\\.dev\\.java\\.net/svn/hudson/", "svn.java.net/svn/hudson~svn/");
if(!oldUrl.equals(transformedConnectionUrl)){
pomData.getWarningMessages().add("project.scm.connectionUrl is pointing to svn.dev.java.net/svn/hudson/ instead of svn.java.net/svn/hudson~svn/");
LOGGER.log(Level.WARNING, "project.scm.connectionUrl is pointing to svn.dev.java.net/svn/hudson/ instead of svn.java.net/svn/hudson~svn/");
}

// ${project.artifactId}
Expand All @@ -244,27 +244,27 @@ public static void computeScmConnection(PomData pomData) {
oldUrl = transformedConnectionUrl;
transformedConnectionUrl = transformedConnectionUrl.replaceAll("(http(s)?://)?[^@:]+@github\\.com", "git://github.com");
if(!oldUrl.equals(transformedConnectionUrl)){
pomData.getWarningMessages().add("project.scm.connectionUrl is using a github account instead of a read-only url git://github.com/...");
LOGGER.log(Level.WARNING, "project.scm.connectionUrl is using a github account instead of a read-only url git://github.com/...");
}
*/

//Convert things like scm:git:git://git@github.com:jenkinsci/dockerhub-notification-plugin.git
oldUrl = transformedConnectionUrl;
transformedConnectionUrl = transformedConnectionUrl.replaceAll("scm:git:git://git@github\\.com:jenkinsci", "scm:git:git://github.com/jenkinsci");
if(!oldUrl.equals(transformedConnectionUrl)){
pomData.getWarningMessages().add("project.scm.connectionUrl should should be accessed in read-only mode (with git:// protocol)");
LOGGER.log(Level.WARNING, "project.scm.connectionUrl should should be accessed in read-only mode (with git:// protocol)");
}

oldUrl = transformedConnectionUrl;
transformedConnectionUrl = transformedConnectionUrl.replaceAll("://github\\.com[^/]", "://github.com/");
if(!oldUrl.equals(transformedConnectionUrl)){
pomData.getWarningMessages().add("project.scm.connectionUrl should have a '/' after the github.com url");
LOGGER.log(Level.WARNING, "project.scm.connectionUrl should have a '/' after the github.com url");
}

oldUrl = transformedConnectionUrl;
transformedConnectionUrl = transformedConnectionUrl.replaceAll("://github\\.com/hudson/", "://github.com/jenkinsci/");
if(!oldUrl.equals(transformedConnectionUrl)){
pomData.getWarningMessages().add("project.scm.connectionUrl should not reference hudson project anymore (no plugin repository there))");
LOGGER.log(Level.WARNING, "project.scm.connectionUrl should not reference hudson project anymore (no plugin repository there))");
}

// Just fixing some scm-sync-configuration issues...
Expand All @@ -274,7 +274,7 @@ public static void computeScmConnection(PomData pomData) {
transformedConnectionUrl = transformedConnectionUrl.substring(0, transformedConnectionUrl.length()-4)+"-plugin.git";
}
if(!oldUrl.equals(transformedConnectionUrl)){
pomData.getWarningMessages().add("project.scm.connectionUrl should be ending with '-plugin.git'");
LOGGER.log(Level.WARNING, "project.scm.connectionUrl should be ending with '-plugin.git'");
}

pomData.setConnectionUrl(transformedConnectionUrl);
Expand Down
13 changes: 0 additions & 13 deletions src/main/java/org/jenkins/tools/test/model/PomData.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public class PomData {
public final MavenCoordinates parent;
private String connectionUrl;
private String scmTag;
private List<String> warningMessages = new ArrayList<>();

public PomData(String artifactId, @CheckForNull String packaging, String connectionUrl, String scmTag, @CheckForNull MavenCoordinates parent, String groupId){
this.artifactId = artifactId;
Expand All @@ -65,10 +64,6 @@ public void setConnectionUrl(String connectionUrl) {
this.connectionUrl = connectionUrl;
}

public List<String> getWarningMessages() {
return warningMessages;
}

@NonNull
public String getPackaging() {
return packaging;
Expand All @@ -77,12 +72,4 @@ public String getPackaging() {
public String getScmTag() {
return scmTag;
}

public boolean isPluginPOM() {
if (parent != null) {
return parent.matches("org.jenkins-ci.plugins", "plugin");
} else { // Interpolate by packaging
return "hpi".equalsIgnoreCase(packaging);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,7 @@ public class TestExecutionResult {

private final ExecutedTestNamesDetails testDetails;

public final List<String> pomWarningMessages;

public TestExecutionResult(List<String> pomWarningMessages){
this(pomWarningMessages, new ExecutedTestNamesDetails());
}

public TestExecutionResult(List<String> pomWarningMessages, ExecutedTestNamesDetails testDetails){
this.pomWarningMessages = Collections.unmodifiableList(pomWarningMessages);
public TestExecutionResult(ExecutedTestNamesDetails testDetails){
this.testDetails = testDetails;
}

Expand Down
8 changes: 0 additions & 8 deletions src/main/resources/org/jenkins/tools/test/resultToReport.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,6 @@
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="count($compatResult/warningMessages//string) &gt; 0">
<xsl:call-template name="display-img">
<xsl:with-param name="id"><xsl:value-of select="$cellId"/>-warns</xsl:with-param>
<xsl:with-param name="title">Warnings !</xsl:with-param>
<xsl:with-param name="img">document.png</xsl:with-param>
<xsl:with-param name="error"><xsl:value-of select="$compatResult/warningMessages//string" /></xsl:with-param>
</xsl:call-template>
</xsl:if>
<xsl:if test="$compatResult/buildLogPath != ''">
<xsl:element name="a">
<xsl:attribute name="href"><xsl:value-of select="$compatResult/buildLogPath" /></xsl:attribute>
Expand Down

0 comments on commit 7d10076

Please sign in to comment.